1 16 19 package com.sun.org.apache.xpath.internal.compiler; 20 21 import com.sun.org.apache.xpath.internal.Expression; 22 import com.sun.org.apache.xpath.internal.functions.Function; 23 24 27 public class FunctionTable 28 { 29 30 31 public static final int FUNC_CURRENT = 0; 32 33 34 public static final int FUNC_LAST = 1; 35 36 37 public static final int FUNC_POSITION = 2; 38 39 40 public static final int FUNC_COUNT = 3; 41 42 43 public static final int FUNC_ID = 4; 44 45 46 public static final int FUNC_KEY = 5; 47 48 49 public static final int FUNC_LOCAL_PART = 7; 50 51 52 public static final int FUNC_NAMESPACE = 8; 53 54 55 public static final int FUNC_QNAME = 9; 56 57 58 public static final int FUNC_GENERATE_ID = 10; 59 60 61 public static final int FUNC_NOT = 11; 62 63 64 public static final int FUNC_TRUE = 12; 65 66 67 public static final int FUNC_FALSE = 13; 68 69 70 public static final int FUNC_BOOLEAN = 14; 71 72 73 public static final int FUNC_NUMBER = 15; 74 75 76 public static final int FUNC_FLOOR = 16; 77 78 79 public static final int FUNC_CEILING = 17; 80 81 82 public static final int FUNC_ROUND = 18; 83 84 85 public static final int FUNC_SUM = 19; 86 87 88 public static final int FUNC_STRING = 20; 89 90 91 public static final int FUNC_STARTS_WITH = 21; 92 93 94 public static final int FUNC_CONTAINS = 22; 95 96 97 public static final int FUNC_SUBSTRING_BEFORE = 23; 98 99 100 public static final int FUNC_SUBSTRING_AFTER = 24; 101 102 103 public static final int FUNC_NORMALIZE_SPACE = 25; 104 105 106 public static final int FUNC_TRANSLATE = 26; 107 108 109 public static final int FUNC_CONCAT = 27; 110 111 112 public static final int FUNC_SUBSTRING = 29; 113 114 115 public static final int FUNC_STRING_LENGTH = 30; 116 117 118 public static final int FUNC_SYSTEM_PROPERTY = 31; 119 120 121 public static final int FUNC_LANG = 32; 122 123 124 public static final int FUNC_EXT_FUNCTION_AVAILABLE = 33; 125 126 127 public static final int FUNC_EXT_ELEM_AVAILABLE = 34; 128 129 130 public static final int FUNC_UNPARSED_ENTITY_URI = 36; 131 132 134 135 public static final int FUNC_DOCLOCATION = 35; 136 137 140 private static FuncLoader m_functions[]; 141 142 146 private static final int NUM_BUILT_IN_FUNCS = 37; 147 148 151 private static final int NUM_ALLOWABLE_ADDINS = 30; 152 153 156 static int m_funcNextFreeIndex = NUM_BUILT_IN_FUNCS; 157 158 static 159 { 160 m_functions = new FuncLoader[NUM_BUILT_IN_FUNCS + NUM_ALLOWABLE_ADDINS]; 161 m_functions[FUNC_CURRENT] = new FuncLoader("FuncCurrent", FUNC_CURRENT); 162 m_functions[FUNC_LAST] = new FuncLoader("FuncLast", FUNC_LAST); 163 m_functions[FUNC_POSITION] = new FuncLoader("FuncPosition", 164 FUNC_POSITION); 165 m_functions[FUNC_COUNT] = new FuncLoader("FuncCount", FUNC_COUNT); 166 m_functions[FUNC_ID] = new FuncLoader("FuncId", FUNC_ID); 167 m_functions[FUNC_KEY] = 168 new FuncLoader("com.sun.org.apache.xalan.internal.templates.FuncKey", FUNC_KEY); 169 170 m_functions[FUNC_LOCAL_PART] = new FuncLoader("FuncLocalPart", 172 FUNC_LOCAL_PART); 173 m_functions[FUNC_NAMESPACE] = new FuncLoader("FuncNamespace", 174 FUNC_NAMESPACE); 175 m_functions[FUNC_QNAME] = new FuncLoader("FuncQname", FUNC_QNAME); 176 m_functions[FUNC_GENERATE_ID] = new FuncLoader("FuncGenerateId", 177 FUNC_GENERATE_ID); 178 m_functions[FUNC_NOT] = new FuncLoader("FuncNot", FUNC_NOT); 179 m_functions[FUNC_TRUE] = new FuncLoader("FuncTrue", FUNC_TRUE); 180 m_functions[FUNC_FALSE] = new FuncLoader("FuncFalse", FUNC_FALSE); 181 m_functions[FUNC_BOOLEAN] = new FuncLoader("FuncBoolean", FUNC_BOOLEAN); 182 m_functions[FUNC_LANG] = new FuncLoader("FuncLang", FUNC_LANG); 183 m_functions[FUNC_NUMBER] = new FuncLoader("FuncNumber", FUNC_NUMBER); 184 m_functions[FUNC_FLOOR] = new FuncLoader("FuncFloor", FUNC_FLOOR); 185 m_functions[FUNC_CEILING] = new FuncLoader("FuncCeiling", FUNC_CEILING); 186 m_functions[FUNC_ROUND] = new FuncLoader("FuncRound", FUNC_ROUND); 187 m_functions[FUNC_SUM] = new FuncLoader("FuncSum", FUNC_SUM); 188 m_functions[FUNC_STRING] = new FuncLoader("FuncString", FUNC_STRING); 189 m_functions[FUNC_STARTS_WITH] = new FuncLoader("FuncStartsWith", 190 FUNC_STARTS_WITH); 191 m_functions[FUNC_CONTAINS] = new FuncLoader("FuncContains", 192 FUNC_CONTAINS); 193 m_functions[FUNC_SUBSTRING_BEFORE] = new FuncLoader("FuncSubstringBefore", 194 FUNC_SUBSTRING_BEFORE); 195 m_functions[FUNC_SUBSTRING_AFTER] = new FuncLoader("FuncSubstringAfter", 196 FUNC_SUBSTRING_AFTER); 197 m_functions[FUNC_NORMALIZE_SPACE] = new FuncLoader("FuncNormalizeSpace", 198 FUNC_NORMALIZE_SPACE); 199 m_functions[FUNC_TRANSLATE] = new FuncLoader("FuncTranslate", 200 FUNC_TRANSLATE); 201 m_functions[FUNC_CONCAT] = new FuncLoader("FuncConcat", FUNC_CONCAT); 202 203 m_functions[FUNC_SYSTEM_PROPERTY] = new FuncLoader("FuncSystemProperty", 205 FUNC_SYSTEM_PROPERTY); 206 m_functions[FUNC_EXT_FUNCTION_AVAILABLE] = 207 new FuncLoader("FuncExtFunctionAvailable", FUNC_EXT_FUNCTION_AVAILABLE); 208 m_functions[FUNC_EXT_ELEM_AVAILABLE] = 209 new FuncLoader("FuncExtElementAvailable", FUNC_EXT_ELEM_AVAILABLE); 210 m_functions[FUNC_SUBSTRING] = new FuncLoader("FuncSubstring", 211 FUNC_SUBSTRING); 212 m_functions[FUNC_STRING_LENGTH] = new FuncLoader("FuncStringLength", 213 FUNC_STRING_LENGTH); 214 m_functions[FUNC_DOCLOCATION] = new FuncLoader("FuncDoclocation", 215 FUNC_DOCLOCATION); 216 m_functions[FUNC_UNPARSED_ENTITY_URI] = 217 new FuncLoader("FuncUnparsedEntityURI", FUNC_UNPARSED_ENTITY_URI); 218 } 219 220 224 static String getFunctionName(int funcID) { 225 return m_functions[funcID].getName(); 226 } 227 228 240 public static Function getFunction(int which) 241 throws javax.xml.transform.TransformerException 242 { 243 return m_functions[which].getFunction(); 244 } 245 246 252 public static int installFunction(String name, Expression func) 253 { 254 255 int funcIndex; 256 Object funcIndexObj = Keywords.m_functions.get(name); 257 258 if (null != funcIndexObj) 259 { 260 funcIndex = ((Integer ) funcIndexObj).intValue(); 261 } 262 else 263 { 264 funcIndex = m_funcNextFreeIndex; 265 266 m_funcNextFreeIndex++; 267 268 Keywords.m_functions.put(name, new Integer (funcIndex)); 269 } 270 271 FuncLoader loader = new FuncLoader(func.getClass().getName(), funcIndex); 272 273 m_functions[funcIndex] = loader; 274 275 return funcIndex; 276 } 277 278 286 public static void installFunction(Expression func, int funcIndex) 287 { 288 289 FuncLoader loader = new FuncLoader(func.getClass().getName(), funcIndex); 290 291 m_functions[funcIndex] = loader; 292 } 293 } 294 | Popular Tags |