Class AbstractFunction

java.lang.Object
com.igormaznitsa.jcp.expression.functions.AbstractFunction
All Implemented Interfaces:
ExpressionItem
Direct Known Subclasses:
AbstractStrConverter, AbstractXMLFunction, FunctionABS, FunctionBINFILE, FunctionDefinedByUser, FunctionEVALFILE, FunctionIS, FunctionISSUBSTR, FunctionROUND, FunctionSTR2GO, FunctionSTR2JAVA, FunctionSTRLEN

public abstract class AbstractFunction extends Object implements ExpressionItem
The abstract class is the base for each function handler in the preprocessor
  • Field Details

    • EXECUTION_PREFIX

      public static final String EXECUTION_PREFIX
      The string contains the prefix for all executing methods of functions
      See Also:
    • ALL_FUNCTIONS

      public static final AbstractFunction[] ALL_FUNCTIONS
      Inside array contains all functions supported by the preprocessor
    • FUNCTION_NAME_MAP

      public static final Map<String,AbstractFunction> FUNCTION_NAME_MAP
    • UID_COUNTER

      protected static final AtomicLong UID_COUNTER
      Inside counter to generate UID for some cases
  • Constructor Details

    • AbstractFunction

      public AbstractFunction()
  • Method Details

    • findForClass

      public static <E extends AbstractFunction> E findForClass(Class<E> functionClass)
      Allows to find a function handler instance for its class
      Type Parameters:
      E - the class of the needed function handler extends the AbstractFunction class
      Parameters:
      functionClass - the class of the needed handler, must not be null
      Returns:
      an instance of the needed handler or null if there is not any such one
    • findForName

      public static AbstractFunction findForName(String str)
      Find a function handler for its name
      Parameters:
      str - the function name, must not be null
      Returns:
      an instance of the needed handler or null if there is not any such one
    • getName

      public abstract String getName()
      Get the function name
      Returns:
      the function name in lower case, must not be null
    • getReference

      public abstract String getReference()
      Get the function reference to be output for a help request
      Returns:
      the function information as a String, must not be null
    • getArity

      public abstract int getArity()
      Get the function arity
      Returns:
      the function arity (zero or greater)
    • getAllowedArgumentTypes

      @MustNotContainNull public abstract ValueType[][] getAllowedArgumentTypes()
      Get arrays of supported argument types
      Returns:
      the array of argument type combinations allowed by the function handler, must not be null
    • getResultType

      public abstract ValueType getResultType()
      Get the result type
      Returns:
      the result type of the function, must not be null
    • getExpressionItemPriority

      public ExpressionItemPriority getExpressionItemPriority()
      Get the priority of the function in the expression tree
      Specified by:
      getExpressionItemPriority in interface ExpressionItem
      Returns:
      the expression item priority for the function, must not be null
    • getExpressionItemType

      public ExpressionItemType getExpressionItemType()
      Get the expression item type
      Specified by:
      getExpressionItemType in interface ExpressionItem
      Returns:
      the expression item type, in the case it is always ExpressionItemType.FUNCTION
    • toString

      public String toString()
      Overrides:
      toString in class Object