public class ParameterTuple extends java.lang.Object implements StringRepresentation
Constructor and Description |
---|
ParameterTuple() |
Modifier and Type | Method and Description |
---|---|
ExecutionError |
checkCall(ExecutionReturn[] arguments)
Checks if the given evaluated arguments array contains arguments that fit to this parameter tuple.
|
void |
create(int size,
ScriptSystemInterface<?,?> scriptSystem,
int minimumArguments,
boolean unlimitedArguments)
Initializes an empty parameter tuple.
|
ExecutionError |
createFromString(java.lang.String declarations,
ScriptSystemInterface<?,?> scriptSystem)
Parses the given string to create the parameter tuple.
|
ExecutionResult<?> |
getDefaultArg(int paramIndex)
Returns the evaluated default argument of the parameter at the given index.
|
ExecutionResult<?>[] |
getDefaultArgs()
Returns the evaluated default arguments as an array, whereas the first entry is the first default argument, not
necessarily the first parameter.
|
int |
getMinArgumentCount()
Returns the minimum number of arguments a caller has to pass.
|
int |
getParamCount(boolean includeUnlimited)
Returns the number of parameters.
|
java.lang.String[] |
getParameterNames()
Returns the names of the parameters as an array.
|
ScriptType[] |
getParameterTypes()
Returns the types of the parameters as an array.
|
java.lang.String |
getParamName(int paramIndex)
Returns the name of the parameter at the given index.
|
ScriptType |
getParamType(int paramIndex)
Returns the type of the parameter at the given index.
|
java.lang.String |
getStringRepresentation()
Returns a user-readable string representation of the object.
|
boolean |
isEmpty() |
boolean |
isUnlimitedArguments()
Tells whether or not a caller can pass arguments at any number.
|
java.lang.String |
paramToString(int paramIndex,
java.lang.String whiteSpace)
Returns a string representation of the parameter at the given index.
|
void |
setDefaultValue(int paramIndex,
ExecutionResult<?> value)
Sets the default value of the parameter at the given index.
|
void |
setMinimumArgumentCount(int minimumArguments)
Sets the minimum number of arguments a caller has to pass.
|
void |
setParameter(int paramIndex,
java.lang.String name,
ScriptType type)
Sets the name and type of the parameter at the given index.
|
java.lang.String |
toString() |
public void create(int size, ScriptSystemInterface<?,?> scriptSystem, int minimumArguments, boolean unlimitedArguments)
size
- the number of parameters.scriptSystem
- a script system to evaluate default arguments.minimumArguments
- the minimum argument count a caller has to pass.unlimitedArguments
- if true, then the caller can give arguments of the last parameter type at any number.public ExecutionError createFromString(java.lang.String declarations, ScriptSystemInterface<?,?> scriptSystem) throws ParameterParseException
declarations
- the parameters, types and default values given as string. The syntax is equal to the syntax
of the parameters of signatures.scriptSystem
- a script system to evaluate the default arguments.ParameterParseException
- if an parameter is invalid.public final boolean isUnlimitedArguments()
public ScriptType[] getParameterTypes()
public java.lang.String[] getParameterNames()
public ExecutionResult<?>[] getDefaultArgs()
public void setParameter(int paramIndex, java.lang.String name, ScriptType type)
paramIndex
- the index of the parameter to set (starting at 0).name
- the new name of the parameter.type
- the new type of the parameter.public void setDefaultValue(int paramIndex, ExecutionResult<?> value)
paramIndex
- the index of the parameter to set the default value (starting at 0 for the first parameter).value
- the default value.public final int getParamCount(boolean includeUnlimited)
includeUnlimited
- if true and unlimited arguments can be passed (which is set in the initialization) then
Integer.MAX_VALUE is returned as an indicator for infinity. If false, then the
number of name-type-pairs is given.public java.lang.String getParamName(int paramIndex)
paramIndex
- the index of the parameter beginning at 0.public ScriptType getParamType(int paramIndex)
paramIndex
- the index of the parameter beginning at 0.public ExecutionResult<?> getDefaultArg(int paramIndex)
paramIndex
- the index of the parameter beginning at 0.public void setMinimumArgumentCount(int minimumArguments)
minimumArguments
- the minimum number of arguments the caller has to pass.public int getMinArgumentCount()
public java.lang.String paramToString(int paramIndex, java.lang.String whiteSpace)
paramIndex
- the index of the parameter beginning at 0.whiteSpace
- the white space to insert for the string representation. Can be "" as well for no white space.public ExecutionError checkCall(ExecutionReturn[] arguments)
arguments
- the arguments to check and to cast, if necessary.public java.lang.String getStringRepresentation()
StringRepresentation
getStringRepresentation
in interface StringRepresentation
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isEmpty()