Package org.htmlunit.xpath.compiler
Class FunctionTable
- java.lang.Object
-
- org.htmlunit.xpath.compiler.FunctionTable
-
public class FunctionTable extends java.lang.ObjectThe function table for XPath.
-
-
Field Summary
Fields Modifier and Type Field Description static intFUNC_BOOLEANThe 'boolean()' id.static intFUNC_CEILINGThe 'ceiling()' id.static intFUNC_CONCATThe 'concat()' id.static intFUNC_CONTAINSThe 'contains()' id.static intFUNC_COUNTThe 'count()' id.static intFUNC_CURRENTThe 'current()' id.static intFUNC_FALSEThe 'false()' id.static intFUNC_FLOORThe 'floor()' id.static intFUNC_IDThe 'id()' id.static intFUNC_LANGThe 'lang()' id.static intFUNC_LASTThe 'last()' id.static intFUNC_LOCAL_PARTThe 'local-name()' id.static intFUNC_NAMESPACEThe 'namespace-uri()' id.static intFUNC_NORMALIZE_SPACEThe 'normalize-space()' id.static intFUNC_NOTThe 'not()' id.static intFUNC_NUMBERThe 'number()' id.static intFUNC_POSITIONThe 'position()' id.static intFUNC_QNAMEThe 'name()' id.static intFUNC_ROUNDThe 'round()' id.static intFUNC_STARTS_WITHThe 'starts-with()' id.static intFUNC_STRINGThe 'string()' id.static intFUNC_STRING_LENGTHThe 'string-length()' id.static intFUNC_SUBSTRINGThe 'substring()' id.static intFUNC_SUBSTRING_AFTERThe 'substring-after()' id.static intFUNC_SUBSTRING_BEFOREThe 'substring-before()' id.static intFUNC_SUMThe 'sum()' id.static intFUNC_TRANSLATEThe 'translate()' id.static intFUNC_TRUEThe 'true()' id.private intm_funcNextFreeIndexThe index to the next free function index.private static java.util.HashMap<java.lang.String,java.lang.Integer>m_functionIDTable of function name to function ID associations.private java.util.HashMap<java.lang.String,java.lang.Integer>m_functionID_customerTable of function name to function ID associations for customized functionsprivate static java.lang.Class<?>[]m_functionsThe function table.private java.lang.Class<?>[]m_functions_customerThe function table contains customized functionsprivate static intNUM_ALLOWABLE_ADDINSNumber of built-in functions that may be added.private static intNUM_BUILT_IN_FUNCSNumber of built in functions.
-
Constructor Summary
Constructors Constructor Description FunctionTable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanfunctionAvailable(java.lang.String methName)Tell if a built-in, non-namespaced function is available.(package private) FunctiongetFunction(int which)Obtain a new Function object from a function ID.(package private) java.lang.ObjectgetFunctionID(java.lang.String key)Obtain a function ID from a given function name(package private) java.lang.StringgetFunctionName(int funcID)Return the name of the a function in the static table.intinstallFunction(java.lang.String name, java.lang.Class<?> func)Install a built-in function.
-
-
-
Field Detail
-
FUNC_CURRENT
public static final int FUNC_CURRENT
The 'current()' id.- See Also:
- Constant Field Values
-
FUNC_LAST
public static final int FUNC_LAST
The 'last()' id.- See Also:
- Constant Field Values
-
FUNC_POSITION
public static final int FUNC_POSITION
The 'position()' id.- See Also:
- Constant Field Values
-
FUNC_COUNT
public static final int FUNC_COUNT
The 'count()' id.- See Also:
- Constant Field Values
-
FUNC_ID
public static final int FUNC_ID
The 'id()' id.- See Also:
- Constant Field Values
-
FUNC_LOCAL_PART
public static final int FUNC_LOCAL_PART
The 'local-name()' id.- See Also:
- Constant Field Values
-
FUNC_NAMESPACE
public static final int FUNC_NAMESPACE
The 'namespace-uri()' id.- See Also:
- Constant Field Values
-
FUNC_QNAME
public static final int FUNC_QNAME
The 'name()' id.- See Also:
- Constant Field Values
-
FUNC_NOT
public static final int FUNC_NOT
The 'not()' id.- See Also:
- Constant Field Values
-
FUNC_TRUE
public static final int FUNC_TRUE
The 'true()' id.- See Also:
- Constant Field Values
-
FUNC_FALSE
public static final int FUNC_FALSE
The 'false()' id.- See Also:
- Constant Field Values
-
FUNC_BOOLEAN
public static final int FUNC_BOOLEAN
The 'boolean()' id.- See Also:
- Constant Field Values
-
FUNC_NUMBER
public static final int FUNC_NUMBER
The 'number()' id.- See Also:
- Constant Field Values
-
FUNC_FLOOR
public static final int FUNC_FLOOR
The 'floor()' id.- See Also:
- Constant Field Values
-
FUNC_CEILING
public static final int FUNC_CEILING
The 'ceiling()' id.- See Also:
- Constant Field Values
-
FUNC_ROUND
public static final int FUNC_ROUND
The 'round()' id.- See Also:
- Constant Field Values
-
FUNC_SUM
public static final int FUNC_SUM
The 'sum()' id.- See Also:
- Constant Field Values
-
FUNC_STRING
public static final int FUNC_STRING
The 'string()' id.- See Also:
- Constant Field Values
-
FUNC_STARTS_WITH
public static final int FUNC_STARTS_WITH
The 'starts-with()' id.- See Also:
- Constant Field Values
-
FUNC_CONTAINS
public static final int FUNC_CONTAINS
The 'contains()' id.- See Also:
- Constant Field Values
-
FUNC_SUBSTRING_BEFORE
public static final int FUNC_SUBSTRING_BEFORE
The 'substring-before()' id.- See Also:
- Constant Field Values
-
FUNC_SUBSTRING_AFTER
public static final int FUNC_SUBSTRING_AFTER
The 'substring-after()' id.- See Also:
- Constant Field Values
-
FUNC_NORMALIZE_SPACE
public static final int FUNC_NORMALIZE_SPACE
The 'normalize-space()' id.- See Also:
- Constant Field Values
-
FUNC_TRANSLATE
public static final int FUNC_TRANSLATE
The 'translate()' id.- See Also:
- Constant Field Values
-
FUNC_CONCAT
public static final int FUNC_CONCAT
The 'concat()' id.- See Also:
- Constant Field Values
-
FUNC_SUBSTRING
public static final int FUNC_SUBSTRING
The 'substring()' id.- See Also:
- Constant Field Values
-
FUNC_STRING_LENGTH
public static final int FUNC_STRING_LENGTH
The 'string-length()' id.- See Also:
- Constant Field Values
-
FUNC_LANG
public static final int FUNC_LANG
The 'lang()' id.- See Also:
- Constant Field Values
-
m_functions
private static final java.lang.Class<?>[] m_functions
The function table.
-
m_functionID
private static final java.util.HashMap<java.lang.String,java.lang.Integer> m_functionID
Table of function name to function ID associations.
-
m_functions_customer
private final java.lang.Class<?>[] m_functions_customer
The function table contains customized functions
-
m_functionID_customer
private final java.util.HashMap<java.lang.String,java.lang.Integer> m_functionID_customer
Table of function name to function ID associations for customized functions
-
NUM_BUILT_IN_FUNCS
private static final int NUM_BUILT_IN_FUNCS
Number of built in functions. Be sure to update this as built-in functions are added.- See Also:
- Constant Field Values
-
NUM_ALLOWABLE_ADDINS
private static final int NUM_ALLOWABLE_ADDINS
Number of built-in functions that may be added.- See Also:
- Constant Field Values
-
m_funcNextFreeIndex
private int m_funcNextFreeIndex
The index to the next free function index.
-
-
Method Detail
-
getFunctionName
java.lang.String getFunctionName(int funcID)
Return the name of the a function in the static table. Needed to avoid making the table publicly available.
-
getFunction
Function getFunction(int which) throws javax.xml.transform.TransformerException
Obtain a new Function object from a function ID.- Parameters:
which- The function ID, which may correspond to one of the FUNC_XXX values found inFunctionTable, but may be a value installed by an external module.- Returns:
- a a new Function instance.
- Throws:
javax.xml.transform.TransformerException- if ClassNotFoundException, IllegalAccessException, or InstantiationException is thrown.
-
getFunctionID
java.lang.Object getFunctionID(java.lang.String key)
Obtain a function ID from a given function name- Parameters:
key- the function name in a java.lang.String format.- Returns:
- a function ID, which may correspond to one of the FUNC_XXX values found in
FunctionTable, but may be a value installed by an external module.
-
installFunction
public int installFunction(java.lang.String name, java.lang.Class<?> func)Install a built-in function.- Parameters:
name- The unqualified name of the function, must not be nullfunc- A Implementation of an XPath Function object.- Returns:
- the position of the function in the internal index.
-
functionAvailable
public boolean functionAvailable(java.lang.String methName)
Tell if a built-in, non-namespaced function is available.- Parameters:
methName- The local name of the function.- Returns:
- True if the function can be executed.
-
-