FunctionTablepublic class FunctionTable extends Object The function table for XPath. |
Fields Summary |
---|
public static final int | FUNC_CURRENTThe 'current()' id. | public static final int | FUNC_LASTThe 'last()' id. | public static final int | FUNC_POSITIONThe 'position()' id. | public static final int | FUNC_COUNTThe 'count()' id. | public static final int | FUNC_IDThe 'id()' id. | public static final int | FUNC_KEYThe 'key()' id (XSLT). | public static final int | FUNC_LOCAL_PARTThe 'local-name()' id. | public static final int | FUNC_NAMESPACEThe 'namespace-uri()' id. | public static final int | FUNC_QNAMEThe 'name()' id. | public static final int | FUNC_GENERATE_IDThe 'generate-id()' id. | public static final int | FUNC_NOTThe 'not()' id. | public static final int | FUNC_TRUEThe 'true()' id. | public static final int | FUNC_FALSEThe 'false()' id. | public static final int | FUNC_BOOLEANThe 'boolean()' id. | public static final int | FUNC_NUMBERThe 'number()' id. | public static final int | FUNC_FLOORThe 'floor()' id. | public static final int | FUNC_CEILINGThe 'ceiling()' id. | public static final int | FUNC_ROUNDThe 'round()' id. | public static final int | FUNC_SUMThe 'sum()' id. | public static final int | FUNC_STRINGThe 'string()' id. | public static final int | FUNC_STARTS_WITHThe 'starts-with()' id. | public static final int | FUNC_CONTAINSThe 'contains()' id. | public static final int | FUNC_SUBSTRING_BEFOREThe 'substring-before()' id. | public static final int | FUNC_SUBSTRING_AFTERThe 'substring-after()' id. | public static final int | FUNC_NORMALIZE_SPACEThe 'normalize-space()' id. | public static final int | FUNC_TRANSLATEThe 'translate()' id. | public static final int | FUNC_CONCATThe 'concat()' id. | public static final int | FUNC_SUBSTRINGThe 'substring()' id. | public static final int | FUNC_STRING_LENGTHThe 'string-length()' id. | public static final int | FUNC_SYSTEM_PROPERTYThe 'system-property()' id. | public static final int | FUNC_LANGThe 'lang()' id. | public static final int | FUNC_EXT_FUNCTION_AVAILABLEThe 'function-available()' id (XSLT). | public static final int | FUNC_EXT_ELEM_AVAILABLEThe 'element-available()' id (XSLT). | public static final int | FUNC_UNPARSED_ENTITY_URIThe 'unparsed-entity-uri()' id (XSLT). | public static final int | FUNC_DOCLOCATIONThe 'document-location()' id (Proprietary). | private static Class[] | m_functionsThe function table. | private static HashMap | m_functionIDTable of function name to function ID associations. | private Class[] | m_functions_customerThe function table contains customized functions | private HashMap | m_functionID_customerTable of function name to function ID associations for customized functions | private static final int | NUM_BUILT_IN_FUNCSNumber of built in functions. Be sure to update this as
built-in functions are added. | private static final int | NUM_ALLOWABLE_ADDINSNumber of built-in functions that may be added. | private int | m_funcNextFreeIndexThe index to the next free function index. |
Constructors Summary |
---|
public FunctionTable()
m_functions = new Class[NUM_BUILT_IN_FUNCS];
m_functions[FUNC_CURRENT] = com.sun.org.apache.xpath.internal.functions.FuncCurrent.class;
m_functions[FUNC_LAST] = com.sun.org.apache.xpath.internal.functions.FuncLast.class;
m_functions[FUNC_POSITION] = com.sun.org.apache.xpath.internal.functions.FuncPosition.class;
m_functions[FUNC_COUNT] = com.sun.org.apache.xpath.internal.functions.FuncCount.class;
m_functions[FUNC_ID] = com.sun.org.apache.xpath.internal.functions.FuncId.class;
// J2SE does not support Xalan interpretive
// m_functions[FUNC_KEY] =
// com.sun.org.apache.xalan.internal.templates.FuncKey.class;
m_functions[FUNC_LOCAL_PART] =
com.sun.org.apache.xpath.internal.functions.FuncLocalPart.class;
m_functions[FUNC_NAMESPACE] =
com.sun.org.apache.xpath.internal.functions.FuncNamespace.class;
m_functions[FUNC_QNAME] = com.sun.org.apache.xpath.internal.functions.FuncQname.class;
m_functions[FUNC_GENERATE_ID] =
com.sun.org.apache.xpath.internal.functions.FuncGenerateId.class;
m_functions[FUNC_NOT] = com.sun.org.apache.xpath.internal.functions.FuncNot.class;
m_functions[FUNC_TRUE] = com.sun.org.apache.xpath.internal.functions.FuncTrue.class;
m_functions[FUNC_FALSE] = com.sun.org.apache.xpath.internal.functions.FuncFalse.class;
m_functions[FUNC_BOOLEAN] = com.sun.org.apache.xpath.internal.functions.FuncBoolean.class;
m_functions[FUNC_LANG] = com.sun.org.apache.xpath.internal.functions.FuncLang.class;
m_functions[FUNC_NUMBER] = com.sun.org.apache.xpath.internal.functions.FuncNumber.class;
m_functions[FUNC_FLOOR] = com.sun.org.apache.xpath.internal.functions.FuncFloor.class;
m_functions[FUNC_CEILING] = com.sun.org.apache.xpath.internal.functions.FuncCeiling.class;
m_functions[FUNC_ROUND] = com.sun.org.apache.xpath.internal.functions.FuncRound.class;
m_functions[FUNC_SUM] = com.sun.org.apache.xpath.internal.functions.FuncSum.class;
m_functions[FUNC_STRING] = com.sun.org.apache.xpath.internal.functions.FuncString.class;
m_functions[FUNC_STARTS_WITH] =
com.sun.org.apache.xpath.internal.functions.FuncStartsWith.class;
m_functions[FUNC_CONTAINS] = com.sun.org.apache.xpath.internal.functions.FuncContains.class;
m_functions[FUNC_SUBSTRING_BEFORE] =
com.sun.org.apache.xpath.internal.functions.FuncSubstringBefore.class;
m_functions[FUNC_SUBSTRING_AFTER] =
com.sun.org.apache.xpath.internal.functions.FuncSubstringAfter.class;
m_functions[FUNC_NORMALIZE_SPACE] =
com.sun.org.apache.xpath.internal.functions.FuncNormalizeSpace.class;
m_functions[FUNC_TRANSLATE] =
com.sun.org.apache.xpath.internal.functions.FuncTranslate.class;
m_functions[FUNC_CONCAT] = com.sun.org.apache.xpath.internal.functions.FuncConcat.class;
m_functions[FUNC_SYSTEM_PROPERTY] =
com.sun.org.apache.xpath.internal.functions.FuncSystemProperty.class;
m_functions[FUNC_EXT_FUNCTION_AVAILABLE] =
com.sun.org.apache.xpath.internal.functions.FuncExtFunctionAvailable.class;
m_functions[FUNC_EXT_ELEM_AVAILABLE] =
com.sun.org.apache.xpath.internal.functions.FuncExtElementAvailable.class;
m_functions[FUNC_SUBSTRING] =
com.sun.org.apache.xpath.internal.functions.FuncSubstring.class;
m_functions[FUNC_STRING_LENGTH] =
com.sun.org.apache.xpath.internal.functions.FuncStringLength.class;
m_functions[FUNC_DOCLOCATION] =
com.sun.org.apache.xpath.internal.functions.FuncDoclocation.class;
m_functions[FUNC_UNPARSED_ENTITY_URI] =
com.sun.org.apache.xpath.internal.functions.FuncUnparsedEntityURI.class;
m_functionID.put(Keywords.FUNC_CURRENT_STRING,
new Integer(FunctionTable.FUNC_CURRENT));
m_functionID.put(Keywords.FUNC_LAST_STRING,
new Integer(FunctionTable.FUNC_LAST));
m_functionID.put(Keywords.FUNC_POSITION_STRING,
new Integer(FunctionTable.FUNC_POSITION));
m_functionID.put(Keywords.FUNC_COUNT_STRING,
new Integer(FunctionTable.FUNC_COUNT));
m_functionID.put(Keywords.FUNC_ID_STRING,
new Integer(FunctionTable.FUNC_ID));
m_functionID.put(Keywords.FUNC_KEY_STRING,
new Integer(FunctionTable.FUNC_KEY));
m_functionID.put(Keywords.FUNC_LOCAL_PART_STRING,
new Integer(FunctionTable.FUNC_LOCAL_PART));
m_functionID.put(Keywords.FUNC_NAMESPACE_STRING,
new Integer(FunctionTable.FUNC_NAMESPACE));
m_functionID.put(Keywords.FUNC_NAME_STRING,
new Integer(FunctionTable.FUNC_QNAME));
m_functionID.put(Keywords.FUNC_GENERATE_ID_STRING,
new Integer(FunctionTable.FUNC_GENERATE_ID));
m_functionID.put(Keywords.FUNC_NOT_STRING,
new Integer(FunctionTable.FUNC_NOT));
m_functionID.put(Keywords.FUNC_TRUE_STRING,
new Integer(FunctionTable.FUNC_TRUE));
m_functionID.put(Keywords.FUNC_FALSE_STRING,
new Integer(FunctionTable.FUNC_FALSE));
m_functionID.put(Keywords.FUNC_BOOLEAN_STRING,
new Integer(FunctionTable.FUNC_BOOLEAN));
m_functionID.put(Keywords.FUNC_LANG_STRING,
new Integer(FunctionTable.FUNC_LANG));
m_functionID.put(Keywords.FUNC_NUMBER_STRING,
new Integer(FunctionTable.FUNC_NUMBER));
m_functionID.put(Keywords.FUNC_FLOOR_STRING,
new Integer(FunctionTable.FUNC_FLOOR));
m_functionID.put(Keywords.FUNC_CEILING_STRING,
new Integer(FunctionTable.FUNC_CEILING));
m_functionID.put(Keywords.FUNC_ROUND_STRING,
new Integer(FunctionTable.FUNC_ROUND));
m_functionID.put(Keywords.FUNC_SUM_STRING,
new Integer(FunctionTable.FUNC_SUM));
m_functionID.put(Keywords.FUNC_STRING_STRING,
new Integer(FunctionTable.FUNC_STRING));
m_functionID.put(Keywords.FUNC_STARTS_WITH_STRING,
new Integer(FunctionTable.FUNC_STARTS_WITH));
m_functionID.put(Keywords.FUNC_CONTAINS_STRING,
new Integer(FunctionTable.FUNC_CONTAINS));
m_functionID.put(Keywords.FUNC_SUBSTRING_BEFORE_STRING,
new Integer(FunctionTable.FUNC_SUBSTRING_BEFORE));
m_functionID.put(Keywords.FUNC_SUBSTRING_AFTER_STRING,
new Integer(FunctionTable.FUNC_SUBSTRING_AFTER));
m_functionID.put(Keywords.FUNC_NORMALIZE_SPACE_STRING,
new Integer(FunctionTable.FUNC_NORMALIZE_SPACE));
m_functionID.put(Keywords.FUNC_TRANSLATE_STRING,
new Integer(FunctionTable.FUNC_TRANSLATE));
m_functionID.put(Keywords.FUNC_CONCAT_STRING,
new Integer(FunctionTable.FUNC_CONCAT));
m_functionID.put(Keywords.FUNC_SYSTEM_PROPERTY_STRING,
new Integer(FunctionTable.FUNC_SYSTEM_PROPERTY));
m_functionID.put(Keywords.FUNC_EXT_FUNCTION_AVAILABLE_STRING,
new Integer(FunctionTable.FUNC_EXT_FUNCTION_AVAILABLE));
m_functionID.put(Keywords.FUNC_EXT_ELEM_AVAILABLE_STRING,
new Integer(FunctionTable.FUNC_EXT_ELEM_AVAILABLE));
m_functionID.put(Keywords.FUNC_SUBSTRING_STRING,
new Integer(FunctionTable.FUNC_SUBSTRING));
m_functionID.put(Keywords.FUNC_STRING_LENGTH_STRING,
new Integer(FunctionTable.FUNC_STRING_LENGTH));
m_functionID.put(Keywords.FUNC_UNPARSED_ENTITY_URI_STRING,
new Integer(FunctionTable.FUNC_UNPARSED_ENTITY_URI));
m_functionID.put(Keywords.FUNC_DOCLOCATION_STRING,
new Integer(FunctionTable.FUNC_DOCLOCATION));
|
Methods Summary |
---|
public boolean | functionAvailable(java.lang.String methName)Tell if a built-in, non-namespaced function is available.
Object tblEntry = m_functionID.get(methName);
if (null != tblEntry) return true;
else{
tblEntry = m_functionID_customer.get(methName);
return (null != tblEntry)? true : false;
}
| com.sun.org.apache.xpath.internal.functions.Function | getFunction(int which)Obtain a new Function object from a function ID.
try{
if (which < NUM_BUILT_IN_FUNCS)
return (Function) m_functions[which].newInstance();
else
return (Function) m_functions_customer[
which-NUM_BUILT_IN_FUNCS].newInstance();
}catch (IllegalAccessException ex){
throw new TransformerException(ex.getMessage());
}catch (InstantiationException ex){
throw new TransformerException(ex.getMessage());
}
| java.lang.Object | getFunctionID(java.lang.String key)Obtain a function ID from a given function name
Object id = m_functionID_customer.get(key);
if (null == id) id = m_functionID.get(key);
return id;
| 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.
if (funcID < NUM_BUILT_IN_FUNCS) return m_functions[funcID].getName();
else return m_functions_customer[funcID - NUM_BUILT_IN_FUNCS].getName();
| public int | installFunction(java.lang.String name, java.lang.Class func)Install a built-in function.
int funcIndex;
Object funcIndexObj = getFunctionID(name);
if (null != funcIndexObj)
{
funcIndex = ((Integer) funcIndexObj).intValue();
if (funcIndex < NUM_BUILT_IN_FUNCS){
funcIndex = m_funcNextFreeIndex++;
m_functionID_customer.put(name, new Integer(funcIndex));
}
m_functions_customer[funcIndex - NUM_BUILT_IN_FUNCS] = func;
}
else
{
funcIndex = m_funcNextFreeIndex++;
m_functions_customer[funcIndex-NUM_BUILT_IN_FUNCS] = func;
m_functionID_customer.put(name,
new Integer(funcIndex));
}
return funcIndex;
|
|