intarsys runtime library

de.intarsys.tools.functor
Class ChainedArgs

java.lang.Object
  extended by de.intarsys.tools.functor.ChainedArgs
All Implemented Interfaces:
IArgs

public class ChainedArgs
extends Object
implements IArgs

An IArgs implementation allowing to concat two IArgs together. Lookup will be performed in "args" first. If nothing is found, lookup is done in "fallbackArgs".


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.intarsys.tools.functor.IArgs
IArgs.IBinding
 
Field Summary
 
Fields inherited from interface de.intarsys.tools.functor.IArgs
ARG_ARGS
 
Constructor Summary
ChainedArgs(IArgs args, IArgs fallbackArgs)
          Create new ChainedArgs where args are always looked up first.
 
Method Summary
 IArgs.IBinding add(Object object)
          Add an indexed value.
 Iterator<IArgs.IBinding> bindings()
          An Iterator over all available bindings.
 void clear()
          Clear all bindings.
 IArgs copy()
          Create a copy.
 IArgs.IBinding declare(String name)
          Declare a name for a binding.
 Object get(int index)
          The argument at position index.
 Object get(int index, Object defaultValue)
          The argument at position index
 Object get(String name)
          The argument named name or null if not available.
 Object get(String name, Object defaultValue)
          The argument named name or the defaultValue if not available.
 IArgs getArgs()
          The main (primary) IArgs.
 IArgs getFallbackArgs()
          The fallback (secondary) IArgs;
 boolean isDefined(String name)
          true if an argument named name is defined.
 boolean isIndexed()
           
 boolean isNamed()
           
 Set names()
          The set of all argument names in the argument list if this argument list is not indexed or null.
 IArgs.IBinding put(int index, Object value)
          Define an indexed binding for value.
 IArgs.IBinding put(String name, Object value)
          Define a named binding for value.
 int size()
          The total number of arguments.
 String toString()
           
 void undefine(int index)
          Undefine the binding at index.
 void undefine(String name)
          Undefine the binding for name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChainedArgs

public ChainedArgs(IArgs args,
                   IArgs fallbackArgs)
Create new ChainedArgs where args are always looked up first. If lookup fails, fallbackArgs are used.

Parameters:
args - The main IArgs to use for lookup
fallbackArgs - The fallback IArgs for lookup
Method Detail

add

public IArgs.IBinding add(Object object)
Description copied from interface: IArgs
Add an indexed value.

Specified by:
add in interface IArgs

bindings

public Iterator<IArgs.IBinding> bindings()
Description copied from interface: IArgs
An Iterator over all available bindings.

Specified by:
bindings in interface IArgs
Returns:
An Iterator over all available bindings.

clear

public void clear()
Description copied from interface: IArgs
Clear all bindings.

Specified by:
clear in interface IArgs

copy

public IArgs copy()
Description copied from interface: IArgs
Create a copy.

Specified by:
copy in interface IArgs
Returns:
The new copy.

declare

public IArgs.IBinding declare(String name)
Description copied from interface: IArgs
Declare a name for a binding.

Specified by:
declare in interface IArgs
Returns:
The binding resulting from the declaration.

get

public Object get(int index)
Description copied from interface: IArgs
The argument at position index.

Specified by:
get in interface IArgs
Parameters:
index - The index of the argument to return.
Returns:
The argument at position index.

get

public Object get(int index,
                  Object defaultValue)
Description copied from interface: IArgs
The argument at position index

Specified by:
get in interface IArgs
Parameters:
index - The index of the argument to return.
defaultValue - The default value to be returned if argument is not available.
Returns:
The argument at position index

get

public Object get(String name)
Description copied from interface: IArgs
The argument named name or null if not available.

Specified by:
get in interface IArgs
Parameters:
name - The name of the argument to return.
Returns:
The argument named name or null if not available.

get

public Object get(String name,
                  Object defaultValue)
Description copied from interface: IArgs
The argument named name or the defaultValue if not available.

Specified by:
get in interface IArgs
Parameters:
name - The name of the argument to return.
defaultValue - The default value to be returned if argument is not available.
Returns:
The argument named name

getArgs

public IArgs getArgs()
The main (primary) IArgs.

Returns:
The main (primary) IArgs.

getFallbackArgs

public IArgs getFallbackArgs()
The fallback (secondary) IArgs;

Returns:
The fallback (secondary) IArgs;

isDefined

public boolean isDefined(String name)
Description copied from interface: IArgs
true if an argument named name is defined.

Specified by:
isDefined in interface IArgs
Returns:
true if an argument named name is defined.

isIndexed

public boolean isIndexed()

isNamed

public boolean isNamed()

names

public Set names()
Description copied from interface: IArgs
The set of all argument names in the argument list if this argument list is not indexed or null.

Specified by:
names in interface IArgs
Returns:
The set of all argument names in the argument list if this argument list is not indexed or null.

put

public IArgs.IBinding put(int index,
                          Object value)
Description copied from interface: IArgs
Define an indexed binding for value.

Specified by:
put in interface IArgs

put

public IArgs.IBinding put(String name,
                          Object value)
Description copied from interface: IArgs
Define a named binding for value.

Specified by:
put in interface IArgs

size

public int size()
Description copied from interface: IArgs
The total number of arguments.

Specified by:
size in interface IArgs
Returns:
The total number of arguments.

toString

public String toString()
Overrides:
toString in class Object

undefine

public void undefine(int index)
Description copied from interface: IArgs
Undefine the binding at index.

Specified by:
undefine in interface IArgs

undefine

public void undefine(String name)
Description copied from interface: IArgs
Undefine the binding for name.

Specified by:
undefine in interface IArgs

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.