📄 functiontable.java
字号:
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; } static{ 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)); } public FunctionTable(){ } /** * Return the name of the a function in the static table. Needed to avoid * making the table publicly available. */ String getFunctionName(int funcID) { if (funcID < NUM_BUILT_IN_FUNCS) return m_functions[funcID].getName(); else return m_functions_customer[funcID - NUM_BUILT_IN_FUNCS].getName(); } /** * Obtain a new Function object from a function ID. * * @param which The function ID, which may correspond to one of the FUNC_XXX * values found in {@link com.sun.org.apache.xpath.internal.compiler.FunctionTable}, but may * be a value installed by an external module. * * @return a a new Function instance. * * @throws javax.xml.transform.TransformerException if ClassNotFoundException, * IllegalAccessException, or InstantiationException is thrown. */ Function getFunction(int which) throws javax.xml.transform.TransformerException { 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()); } } /** * Obtain a function ID from a given function name * @param key the function name in a java.lang.String format. * @return a function ID, which may correspond to one of the FUNC_XXX values * found in {@link com.sun.org.apache.xpath.internal.compiler.FunctionTable}, but may be a * value installed by an external module. */ Object getFunctionID(String key){ Object id = m_functionID_customer.get(key); if (null == id) id = m_functionID.get(key); return id; } /** * Install a built-in function. * @param name The unqualified name of the function, must not be null * @param func A Implementation of an XPath Function object. * @return the position of the function in the internal index. */ public int installFunction(String name, Class func) { 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; } /** * Tell if a built-in, non-namespaced function is available. * * @param methName The local name of the function. * * @return True if the function can be executed. */ public boolean functionAvailable(String methName) { Object tblEntry = m_functionID.get(methName); if (null != tblEntry) return true; else{ tblEntry = m_functionID_customer.get(methName); return (null != tblEntry)? true : false; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -