Package de.intarsys.tools.functor
Class DeclaredArgs
- java.lang.Object
-
- de.intarsys.tools.functor.DeclaredArgs
-
- All Implemented Interfaces:
IArgs
public class DeclaredArgs extends java.lang.Object implements IArgs
ThisIArgsimplementation allows the declaration of arguments.The declaration is matched against the actual arguments defined in
args. The declaration defines a mapping from indexed to named and AND vice versa.If we have indexed args, a declaration associates a name with the argument in the sequence of declaration.
If we have named args, a declaration defines the index of the argument with the same name.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeclaredArgs(IArgs args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.Object object)voidclear()static DeclaredArgscreateStrict(IArgs args)static DeclaredArgscreateStrictIfDeclared(IArgs args)static DeclaredArgscreateTransparent(IArgs args)protected voiddeclare(IFunctorCall call, ArgumentDeclaration argDecl)protected voiddeclare(IFunctorCall call, java.lang.String name, int index, IFunctor defaultFunctor)java.lang.Objectget(int pIndex)The argument at positionindex.java.lang.Objectget(int pIndex, java.lang.Object defaultValue)The argument at positionindexjava.lang.Objectget(java.lang.String name)The argument namedname.java.lang.Objectget(java.lang.String name, java.lang.Object defaultValue)The argument namednameor the defaultValue if not available.IArgsgetArgsIn()booleanisDefined(int index)trueif an argument atindexis defined.booleanisDefined(java.lang.String name)trueif an argument namednameis defined.booleanisIndexed()trueif this argument list is indexed.protected booleanisLazy()booleanisNamed()trueif this argument list is named.protected booleanisStrict()java.util.Setnames()The set of all argument names in the argument list if this argument list is not indexed or null.voidput(int index, java.lang.Object value)voidput(java.lang.String name, java.lang.Object value)protected voidsetLazy(boolean lazy)protected voidsetStrict(boolean strict)intsize()The total number of arguments.protected voidswitchArgs()java.lang.StringtoString()
-
-
-
Constructor Detail
-
DeclaredArgs
protected DeclaredArgs(IArgs args)
-
-
Method Detail
-
createStrict
public static DeclaredArgs createStrict(IArgs args)
-
createStrictIfDeclared
public static DeclaredArgs createStrictIfDeclared(IArgs args)
-
createTransparent
public static DeclaredArgs createTransparent(IArgs args)
-
declare
protected void declare(IFunctorCall call, ArgumentDeclaration argDecl) throws DeclarationException
- Throws:
DeclarationException
-
declare
protected void declare(IFunctorCall call, java.lang.String name, int index, IFunctor defaultFunctor) throws DeclarationException
- Throws:
DeclarationException
-
get
public java.lang.Object get(int pIndex)
Description copied from interface:IArgsThe argument at positionindex.
-
get
public java.lang.Object get(int pIndex, java.lang.Object defaultValue)Description copied from interface:IArgsThe argument at positionindex
-
get
public java.lang.Object get(java.lang.String name)
Description copied from interface:IArgsThe argument namedname.
-
get
public java.lang.Object get(java.lang.String name, java.lang.Object defaultValue)Description copied from interface:IArgsThe argument namednameor the defaultValue if not available.
-
getArgsIn
public IArgs getArgsIn()
-
isDefined
public boolean isDefined(int index)
Description copied from interface:IArgstrueif an argument atindexis defined.
-
isDefined
public boolean isDefined(java.lang.String name)
Description copied from interface:IArgstrueif an argument namednameis defined.
-
isIndexed
public boolean isIndexed()
Description copied from interface:IArgstrueif this argument list is indexed. This means its elements are available via integer indexes.This does NOT mean the arguments are not available via names - there are implementations that can support both.
-
isLazy
protected boolean isLazy()
-
isNamed
public boolean isNamed()
Description copied from interface:IArgstrueif this argument list is named. This means its elements are available via names.This does NOT mean the arguments are not available via indexes - there are implementations that can support both.
-
isStrict
protected boolean isStrict()
-
names
public java.util.Set names()
Description copied from interface:IArgsThe set of all argument names in the argument list if this argument list is not indexed or null.
-
put
public void put(java.lang.String name, java.lang.Object value)
-
setLazy
protected void setLazy(boolean lazy)
-
setStrict
protected void setStrict(boolean strict)
-
size
public int size()
Description copied from interface:IArgsThe total number of arguments.
-
switchArgs
protected void switchArgs()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-