1 16 19 package com.sun.org.apache.xpath.internal.compiler; 20 21 import java.util.Hashtable ; 22 23 27 public class Keywords 28 { 29 30 31 static Hashtable m_keywords = new Hashtable (); 32 33 34 static Hashtable m_axisnames = new Hashtable (); 35 36 37 static Hashtable m_functions = new Hashtable (); 38 39 40 static Hashtable m_nodetypes = new Hashtable (); 41 42 43 private static final String FROM_ANCESTORS_STRING = "ancestor"; 44 45 46 private static final String FROM_ANCESTORS_OR_SELF_STRING = 47 "ancestor-or-self"; 48 49 50 private static final String FROM_ATTRIBUTES_STRING = "attribute"; 51 52 53 private static final String FROM_CHILDREN_STRING = "child"; 54 55 56 private static final String FROM_DESCENDANTS_STRING = "descendant"; 57 58 59 private static final String FROM_DESCENDANTS_OR_SELF_STRING = 60 "descendant-or-self"; 61 62 63 private static final String FROM_FOLLOWING_STRING = "following"; 64 65 66 private static final String FROM_FOLLOWING_SIBLINGS_STRING = 67 "following-sibling"; 68 69 70 private static final String FROM_PARENT_STRING = "parent"; 71 72 73 private static final String FROM_PRECEDING_STRING = "preceding"; 74 75 76 private static final String FROM_PRECEDING_SIBLINGS_STRING = 77 "preceding-sibling"; 78 79 80 private static final String FROM_SELF_STRING = "self"; 81 82 83 private static final String FROM_NAMESPACE_STRING = "namespace"; 84 85 86 private static final String FROM_SELF_ABBREVIATED_STRING = "."; 87 88 89 private static final String NODETYPE_COMMENT_STRING = "comment"; 90 91 92 private static final String NODETYPE_TEXT_STRING = "text"; 93 94 95 private static final String NODETYPE_PI_STRING = "processing-instruction"; 96 97 98 private static final String NODETYPE_NODE_STRING = "node"; 99 100 101 private static final String NODETYPE_ANYELEMENT_STRING = "*"; 102 103 104 private static final String FUNC_CURRENT_STRING = "current"; 105 106 107 private static final String FUNC_LAST_STRING = "last"; 108 109 110 private static final String FUNC_POSITION_STRING = "position"; 111 112 113 private static final String FUNC_COUNT_STRING = "count"; 114 115 116 static final String FUNC_ID_STRING = "id"; 117 118 119 public static final String FUNC_KEY_STRING = "key"; 120 121 122 private static final String FUNC_LOCAL_PART_STRING = "local-name"; 123 124 125 private static final String FUNC_NAMESPACE_STRING = "namespace-uri"; 126 127 128 private static final String FUNC_NAME_STRING = "name"; 129 130 131 private static final String FUNC_GENERATE_ID_STRING = "generate-id"; 132 133 134 private static final String FUNC_NOT_STRING = "not"; 135 136 137 private static final String FUNC_TRUE_STRING = "true"; 138 139 140 private static final String FUNC_FALSE_STRING = "false"; 141 142 143 private static final String FUNC_BOOLEAN_STRING = "boolean"; 144 145 146 private static final String FUNC_LANG_STRING = "lang"; 147 148 149 private static final String FUNC_NUMBER_STRING = "number"; 150 151 152 private static final String FUNC_FLOOR_STRING = "floor"; 153 154 155 private static final String FUNC_CEILING_STRING = "ceiling"; 156 157 158 private static final String FUNC_ROUND_STRING = "round"; 159 160 161 private static final String FUNC_SUM_STRING = "sum"; 162 163 164 private static final String FUNC_STRING_STRING = "string"; 165 166 167 private static final String FUNC_STARTS_WITH_STRING = "starts-with"; 168 169 170 private static final String FUNC_CONTAINS_STRING = "contains"; 171 172 173 private static final String FUNC_SUBSTRING_BEFORE_STRING = 174 "substring-before"; 175 176 177 private static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after"; 178 179 180 private static final String FUNC_NORMALIZE_SPACE_STRING = "normalize-space"; 181 182 183 private static final String FUNC_TRANSLATE_STRING = "translate"; 184 185 186 private static final String FUNC_CONCAT_STRING = "concat"; 187 188 189 private static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property"; 190 191 192 private static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING = 193 "function-available"; 194 195 196 private static final String FUNC_EXT_ELEM_AVAILABLE_STRING = 197 "element-available"; 198 199 200 private static final String FUNC_SUBSTRING_STRING = "substring"; 201 202 203 private static final String FUNC_STRING_LENGTH_STRING = "string-length"; 204 205 206 private static final String FUNC_UNPARSED_ENTITY_URI_STRING = 207 "unparsed-entity-uri"; 208 209 211 212 private static final String FUNC_DOCLOCATION_STRING = "document-location"; 213 214 static 215 { 216 m_axisnames.put(FROM_ANCESTORS_STRING, 217 new Integer (OpCodes.FROM_ANCESTORS)); 218 m_axisnames.put(FROM_ANCESTORS_OR_SELF_STRING, 219 new Integer (OpCodes.FROM_ANCESTORS_OR_SELF)); 220 m_axisnames.put(FROM_ATTRIBUTES_STRING, 221 new Integer (OpCodes.FROM_ATTRIBUTES)); 222 m_axisnames.put(FROM_CHILDREN_STRING, 223 new Integer (OpCodes.FROM_CHILDREN)); 224 m_axisnames.put(FROM_DESCENDANTS_STRING, 225 new Integer (OpCodes.FROM_DESCENDANTS)); 226 m_axisnames.put(FROM_DESCENDANTS_OR_SELF_STRING, 227 new Integer (OpCodes.FROM_DESCENDANTS_OR_SELF)); 228 m_axisnames.put(FROM_FOLLOWING_STRING, 229 new Integer (OpCodes.FROM_FOLLOWING)); 230 m_axisnames.put(FROM_FOLLOWING_SIBLINGS_STRING, 231 new Integer (OpCodes.FROM_FOLLOWING_SIBLINGS)); 232 m_axisnames.put(FROM_PARENT_STRING, 233 new Integer (OpCodes.FROM_PARENT)); 234 m_axisnames.put(FROM_PRECEDING_STRING, 235 new Integer (OpCodes.FROM_PRECEDING)); 236 m_axisnames.put(FROM_PRECEDING_SIBLINGS_STRING, 237 new Integer (OpCodes.FROM_PRECEDING_SIBLINGS)); 238 m_axisnames.put(FROM_SELF_STRING, 239 new Integer (OpCodes.FROM_SELF)); 240 m_axisnames.put(FROM_NAMESPACE_STRING, 241 new Integer (OpCodes.FROM_NAMESPACE)); 242 m_nodetypes.put(NODETYPE_COMMENT_STRING, 243 new Integer (OpCodes.NODETYPE_COMMENT)); 244 m_nodetypes.put(NODETYPE_TEXT_STRING, 245 new Integer (OpCodes.NODETYPE_TEXT)); 246 m_nodetypes.put(NODETYPE_PI_STRING, 247 new Integer (OpCodes.NODETYPE_PI)); 248 m_nodetypes.put(NODETYPE_NODE_STRING, 249 new Integer (OpCodes.NODETYPE_NODE)); 250 m_nodetypes.put(NODETYPE_ANYELEMENT_STRING, 251 new Integer (OpCodes.NODETYPE_ANYELEMENT)); 252 m_keywords.put(FROM_SELF_ABBREVIATED_STRING, 253 new Integer (OpCodes.FROM_SELF)); 254 m_keywords.put(FUNC_ID_STRING, 255 new Integer (FunctionTable.FUNC_ID)); 256 m_keywords.put(FUNC_KEY_STRING, 257 new Integer (FunctionTable.FUNC_KEY)); 258 m_functions.put(FUNC_CURRENT_STRING, 259 new Integer (FunctionTable.FUNC_CURRENT)); 260 m_functions.put(FUNC_LAST_STRING, 261 new Integer (FunctionTable.FUNC_LAST)); 262 m_functions.put(FUNC_POSITION_STRING, 263 new Integer (FunctionTable.FUNC_POSITION)); 264 m_functions.put(FUNC_COUNT_STRING, 265 new Integer (FunctionTable.FUNC_COUNT)); 266 m_functions.put(FUNC_ID_STRING, 267 new Integer (FunctionTable.FUNC_ID)); 268 m_functions.put(FUNC_KEY_STRING, 269 new Integer (FunctionTable.FUNC_KEY)); 270 m_functions.put(FUNC_LOCAL_PART_STRING, 271 new Integer (FunctionTable.FUNC_LOCAL_PART)); 272 m_functions.put(FUNC_NAMESPACE_STRING, 273 new Integer (FunctionTable.FUNC_NAMESPACE)); 274 m_functions.put(FUNC_NAME_STRING, 275 new Integer (FunctionTable.FUNC_QNAME)); 276 m_functions.put(FUNC_GENERATE_ID_STRING, 277 new Integer (FunctionTable.FUNC_GENERATE_ID)); 278 m_functions.put(FUNC_NOT_STRING, 279 new Integer (FunctionTable.FUNC_NOT)); 280 m_functions.put(FUNC_TRUE_STRING, 281 new Integer (FunctionTable.FUNC_TRUE)); 282 m_functions.put(FUNC_FALSE_STRING, 283 new Integer (FunctionTable.FUNC_FALSE)); 284 m_functions.put(FUNC_BOOLEAN_STRING, 285 new Integer (FunctionTable.FUNC_BOOLEAN)); 286 m_functions.put(FUNC_LANG_STRING, 287 new Integer (FunctionTable.FUNC_LANG)); 288 m_functions.put(FUNC_NUMBER_STRING, 289 new Integer (FunctionTable.FUNC_NUMBER)); 290 m_functions.put(FUNC_FLOOR_STRING, 291 new Integer (FunctionTable.FUNC_FLOOR)); 292 m_functions.put(FUNC_CEILING_STRING, 293 new Integer (FunctionTable.FUNC_CEILING)); 294 m_functions.put(FUNC_ROUND_STRING, 295 new Integer (FunctionTable.FUNC_ROUND)); 296 m_functions.put(FUNC_SUM_STRING, 297 new Integer (FunctionTable.FUNC_SUM)); 298 m_functions.put(FUNC_STRING_STRING, 299 new Integer (FunctionTable.FUNC_STRING)); 300 m_functions.put(FUNC_STARTS_WITH_STRING, 301 new Integer (FunctionTable.FUNC_STARTS_WITH)); 302 m_functions.put(FUNC_CONTAINS_STRING, 303 new Integer (FunctionTable.FUNC_CONTAINS)); 304 m_functions.put(FUNC_SUBSTRING_BEFORE_STRING, 305 new Integer (FunctionTable.FUNC_SUBSTRING_BEFORE)); 306 m_functions.put(FUNC_SUBSTRING_AFTER_STRING, 307 new Integer (FunctionTable.FUNC_SUBSTRING_AFTER)); 308 m_functions.put(FUNC_NORMALIZE_SPACE_STRING, 309 new Integer (FunctionTable.FUNC_NORMALIZE_SPACE)); 310 m_functions.put(FUNC_TRANSLATE_STRING, 311 new Integer (FunctionTable.FUNC_TRANSLATE)); 312 m_functions.put(FUNC_CONCAT_STRING, 313 new Integer (FunctionTable.FUNC_CONCAT)); 314 315 m_functions.put(FUNC_SYSTEM_PROPERTY_STRING, 317 new Integer (FunctionTable.FUNC_SYSTEM_PROPERTY)); 318 m_functions.put(FUNC_EXT_FUNCTION_AVAILABLE_STRING, 319 new Integer (FunctionTable.FUNC_EXT_FUNCTION_AVAILABLE)); 320 m_functions.put(FUNC_EXT_ELEM_AVAILABLE_STRING, 321 new Integer (FunctionTable.FUNC_EXT_ELEM_AVAILABLE)); 322 m_functions.put(FUNC_SUBSTRING_STRING, 323 new Integer (FunctionTable.FUNC_SUBSTRING)); 324 m_functions.put(FUNC_STRING_LENGTH_STRING, 325 new Integer (FunctionTable.FUNC_STRING_LENGTH)); 326 m_functions.put(FUNC_UNPARSED_ENTITY_URI_STRING, 327 new Integer (FunctionTable.FUNC_UNPARSED_ENTITY_URI)); 328 329 m_functions.put(NODETYPE_COMMENT_STRING, 331 new Integer (OpCodes.NODETYPE_COMMENT)); 332 m_functions.put(NODETYPE_TEXT_STRING, 333 new Integer (OpCodes.NODETYPE_TEXT)); 334 m_functions.put(NODETYPE_PI_STRING, 335 new Integer (OpCodes.NODETYPE_PI)); 336 m_functions.put(NODETYPE_NODE_STRING, 337 new Integer (OpCodes.NODETYPE_NODE)); 338 m_functions.put(FUNC_DOCLOCATION_STRING, 339 new Integer (FunctionTable.FUNC_DOCLOCATION)); 340 } 341 342 349 public static boolean functionAvailable(String methName) 350 { 351 352 try 353 { 354 Object tblEntry = m_functions.get(methName); 355 356 if (null == tblEntry) 357 return false; 358 359 int funcType = ((Integer ) tblEntry).intValue(); 360 361 switch (funcType) 362 { 363 case OpCodes.NODETYPE_COMMENT : 364 case OpCodes.NODETYPE_TEXT : 365 case OpCodes.NODETYPE_PI : 366 case OpCodes.NODETYPE_NODE : 367 return false; default : 369 return true; 370 } 371 } 372 catch (Exception e) 373 { 374 return false; 375 } 376 } 377 } 378 | Popular Tags |