org.millscript.millscript.functions
Class Function

java.lang.Object
  extended by org.millscript.millscript.functions.Function
Direct Known Subclasses:
AbstractOutputFunction, AddEntityFunction, AddFunctionFunction, AddLastFunction, AddLoaderFunction, AttributeFunction, AttributesMapFunction, BinaryFunction, BindingMatchedLimitsFunction, BindingMatchVarLimitsFunction, CacheFunction, CharCodeFunction, ChildrenFunction, ClassNameFunction, CloneFunction, ClosureFunction, CmpNumStringFunction, CmpStringFunction, CommentTextFunction, CronEmailListFunction, DatabaseLockfileFunction, DateFieldFunction, DeltaChildrenListFunction, ExplodeFunction, FormatFunction, FunctionNameFunction, GetCharSetFunction, GetDefaultFunction, GroupFunction, GroupPreserveOrderFunction, IndexByPrimaryKeyFunction, IndexFunction, IsCommentFunction, IsElementFunction, IsListFunction, IsMapFunction, IsStringFunction, JavaConstructorFunction, JavaFunctionFunction, JavaOptionsFunction, JavaRecognizerFunction, JConstructor, JdbcExecuteQueryFunction, JdbcExecuteUpdateFunction, JMethod, JOConstructor, JoinByPrimaryKeyFunction, JOMethod, JRecognizer, LambdaFunction, LengthFunction, LoadValueFromVEntryFunction, LogLevelFunction, ManyBodyFunction, MapKeysFunction, MapKeysListFunction, MapValuesFunction, MapValuesListFunction, MishapFunction, ModDefaultFunction, NewArrayListFunction, NewCDATAFunction, NewHashMapFunction, NewLinkedHashMapFunction, NewLinkedListFunction, NewLiteListFunction, NewMapletFunction, NewSymbolFunction, NewTreeMapFunction, NewWeakHashMapFunction, PrintFunction, PrintlnFunction, RemoveLastFunction, SetCharSetFunction, SetDefaultFunction, ShowExprFunction, ShowFunction, ShowImageFunction, ShowLimFunction, ShowlnFunction, ShowlnLimFunction, SlotFunction, SortByFunction, SortFunction, SpiceClassConstructorFunction, SplitStringFunction, StringToXMLFunction, SubrangeFunction, SubstituteAllFunction, ToDateFunction, ToNumberFunction, ToStringFunction, TrinaryFunction, UnaryFunction, VersionFunction, WarnAboutIllegalXML10CharactersFunction

public abstract class Function
extends java.lang.Object

This is the base class of all MillScript Functions.

Two constructors are provided here, no-args or a single Package argument. When adding functions via a package configuration file, the single arg version will be tried first and then the no-arg version. Hence if both are provided, the single argument version would not be used, unless an explicit reference is made.


Constructor Summary
protected Function()
          Constructs a new function with no additional parameters.
protected Function(Package p)
          Constructs a new function to be part of the specified pacakge.
 
Method Summary
abstract  void apply(Machine mc, int nargs)
          Performs this function using the specified machine, with the specified number of arguments.
 void applyUpdater(Machine mc, int nargs, int unargs)
          Performs this functions updater.
 void checkNargs(Machine mc, int required, int actual)
          Convenience method for checking if the right number of arguments are supplied when calling this function.
 void checkNargsGT(Machine mc, int required, int actual)
          Convenience method for checking if the right number of arguments are supplied when calling this function.
 void checkUNargs(Machine mc, int req, int actual, int ureq, int uactual)
          Convenience method for checking if the right number of arguments are supplied when calling this functions updater.
 java.lang.String getName()
          Returns this functions name.
 Function modName(java.lang.String s)
          Returns this function after having changed it's name to the specified value.
 void reportNargsError(Machine mc, int required, int actual)
          Generates a mishap for use when the wrong number of arguments are supplied when calling this function.
 void reportNargsGTError(Machine mc, int required, int actual)
          Generates a mishap for use when the wrong number of arguments are supplied when calling this function.
 void setName(java.lang.String s)
          Sets this functions name to the specified value.
 java.lang.String toString()
           
static java.lang.Object tryClone(java.lang.Object x)
          Attempts to clone the specified object by calling its public clone method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Function

protected Function()
Constructs a new function with no additional parameters.

This constructor is for general use and is the most commonly required. If the function requires access to the configuration during construction it should provide the single argument version instead.


Function

protected Function(Package p)
Constructs a new function to be part of the specified pacakge.

This constructor will be tried first when adding a function to a package via a configuration file. If this constructor is not available, the no argument version will be tried. This constructor should only be used if the package argument is required.

Parameters:
p - the Package this new function will be part of
Method Detail

apply

public abstract void apply(Machine mc,
                           int nargs)
Performs this function using the specified machine, with the specified number of arguments.

Parameters:
mc - the machine to perform this function on
nargs - the number of arguments the function is being invoked with

applyUpdater

public void applyUpdater(Machine mc,
                         int nargs,
                         int unargs)
Performs this functions updater. The function is performed on the specified machine, with the specified number of arguments and update values. You can override this method if you are confident that zero results are pushed, otherwise override the auxillary method update.

Parameters:
mc - the machine to perform this function on
nargs - the number of arguments the function is being invoked with
unargs - the number of update arguments

getName

public java.lang.String getName()
Returns this functions name.

Returns:
a String holding this functions name

modName

public Function modName(java.lang.String s)
Returns this function after having changed it's name to the specified value.

Parameters:
s - the new name for this function
Returns:
this function with it's name changed

setName

public void setName(java.lang.String s)
Sets this functions name to the specified value.

Parameters:
s - the new name for this function

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

checkNargs

public void checkNargs(Machine mc,
                       int required,
                       int actual)
Convenience method for checking if the right number of arguments are supplied when calling this function. This method would be used when the required number of arguments is a specific value.

Parameters:
mc - the machine to gather arguments from
required - the required number of arguments to this function
actual - the actual number of arguments to this function

checkNargsGT

public void checkNargsGT(Machine mc,
                         int required,
                         int actual)
Convenience method for checking if the right number of arguments are supplied when calling this function. This method would be used when the required number of arguments is at least a certain value.

Parameters:
mc - the machine to gather arguments from
required - the minimum number of arguments to this function
actual - the actual number of arguments to this function

checkUNargs

public void checkUNargs(Machine mc,
                        int req,
                        int actual,
                        int ureq,
                        int uactual)
Convenience method for checking if the right number of arguments are supplied when calling this functions updater.

Parameters:
mc - the machine to gather arguments from
req - the required number of arguments to this function
actual - the actual number of arguments to this function
ureq - the required number of update values for this updater
uactual - the actual number of update values for this updater

reportNargsError

public void reportNargsError(Machine mc,
                             int required,
                             int actual)
Generates a mishap for use when the wrong number of arguments are supplied when calling this function. This method would be used when the required number of arguments should be a specific value.

Parameters:
mc - the machine to gather arguments from
required - the required number of arguments to this function
actual - the actual number of arguments to this function

reportNargsGTError

public void reportNargsGTError(Machine mc,
                               int required,
                               int actual)
Generates a mishap for use when the wrong number of arguments are supplied when calling this function. This method would be used when the required number of arguments must be at least a certain value.

Parameters:
mc - the machine to gather arguments from
required - the minimum number of arguments to this function
actual - the actual number of arguments to this function

tryClone

public static java.lang.Object tryClone(java.lang.Object x)
Attempts to clone the specified object by calling its public clone method. If the object is successfully cloned, its clone will be returned otherwise the specified object is itself returned.

Parameters:
x - the object to try and clone
Returns:
the supplied object, or it's clone if successfully cloned


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.