Keywords.java revision 749:c494d4d1c5a1
1/* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 */ 4/** 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 */ 22/* 23 * $Id: Keywords.java,v 1.2.4.1 2005/09/14 19:46:01 jeffsuttor Exp $ 24 */ 25package com.sun.org.apache.xpath.internal.compiler; 26 27import java.util.Hashtable; 28 29/** 30 * Table of strings to operation code lookups. 31 * @xsl.usage internal 32 */ 33public class Keywords 34{ 35 36 /** Table of keywords to opcode associations. */ 37 private static Hashtable m_keywords = new Hashtable(); 38 39 /** Table of axes names to opcode associations. */ 40 private static Hashtable m_axisnames = new Hashtable(); 41 42 /** Table of function name to function ID associations. */ 43 private static Hashtable m_nodetests = new Hashtable(); 44 45 /** Table of node type strings to opcode associations. */ 46 private static Hashtable m_nodetypes = new Hashtable(); 47 48 /** ancestor axes string. */ 49 private static final String FROM_ANCESTORS_STRING = "ancestor"; 50 51 /** ancestor-or-self axes string. */ 52 private static final String FROM_ANCESTORS_OR_SELF_STRING = 53 "ancestor-or-self"; 54 55 /** attribute axes string. */ 56 private static final String FROM_ATTRIBUTES_STRING = "attribute"; 57 58 /** child axes string. */ 59 private static final String FROM_CHILDREN_STRING = "child"; 60 61 /** descendant-or-self axes string. */ 62 private static final String FROM_DESCENDANTS_STRING = "descendant"; 63 64 /** ancestor axes string. */ 65 private static final String FROM_DESCENDANTS_OR_SELF_STRING = 66 "descendant-or-self"; 67 68 /** following axes string. */ 69 private static final String FROM_FOLLOWING_STRING = "following"; 70 71 /** following-sibling axes string. */ 72 private static final String FROM_FOLLOWING_SIBLINGS_STRING = 73 "following-sibling"; 74 75 /** parent axes string. */ 76 private static final String FROM_PARENT_STRING = "parent"; 77 78 /** preceding axes string. */ 79 private static final String FROM_PRECEDING_STRING = "preceding"; 80 81 /** preceding-sibling axes string. */ 82 private static final String FROM_PRECEDING_SIBLINGS_STRING = 83 "preceding-sibling"; 84 85 /** self axes string. */ 86 private static final String FROM_SELF_STRING = "self"; 87 88 /** namespace axes string. */ 89 private static final String FROM_NAMESPACE_STRING = "namespace"; 90 91 /** self axes abreviated string. */ 92 private static final String FROM_SELF_ABBREVIATED_STRING = "."; 93 94 /** comment node test string. */ 95 private static final String NODETYPE_COMMENT_STRING = "comment"; 96 97 /** text node test string. */ 98 private static final String NODETYPE_TEXT_STRING = "text"; 99 100 /** processing-instruction node test string. */ 101 private static final String NODETYPE_PI_STRING = "processing-instruction"; 102 103 /** Any node test string. */ 104 private static final String NODETYPE_NODE_STRING = "node"; 105 106 /** Wildcard element string. */ 107 private static final String NODETYPE_ANYELEMENT_STRING = "*"; 108 109 /** current function string. */ 110 public static final String FUNC_CURRENT_STRING = "current"; 111 112 /** last function string. */ 113 public static final String FUNC_LAST_STRING = "last"; 114 115 /** position function string. */ 116 public static final String FUNC_POSITION_STRING = "position"; 117 118 /** count function string. */ 119 public static final String FUNC_COUNT_STRING = "count"; 120 121 /** id function string. */ 122 static final String FUNC_ID_STRING = "id"; 123 124 /** key function string (XSLT). */ 125 public static final String FUNC_KEY_STRING = "key"; 126 127 /** local-name function string. */ 128 public static final String FUNC_LOCAL_PART_STRING = "local-name"; 129 130 /** namespace-uri function string. */ 131 public static final String FUNC_NAMESPACE_STRING = "namespace-uri"; 132 133 /** name function string. */ 134 public static final String FUNC_NAME_STRING = "name"; 135 136 /** generate-id function string (XSLT). */ 137 public static final String FUNC_GENERATE_ID_STRING = "generate-id"; 138 139 /** not function string. */ 140 public static final String FUNC_NOT_STRING = "not"; 141 142 /** true function string. */ 143 public static final String FUNC_TRUE_STRING = "true"; 144 145 /** false function string. */ 146 public static final String FUNC_FALSE_STRING = "false"; 147 148 /** boolean function string. */ 149 public static final String FUNC_BOOLEAN_STRING = "boolean"; 150 151 /** lang function string. */ 152 public static final String FUNC_LANG_STRING = "lang"; 153 154 /** number function string. */ 155 public static final String FUNC_NUMBER_STRING = "number"; 156 157 /** floor function string. */ 158 public static final String FUNC_FLOOR_STRING = "floor"; 159 160 /** ceiling function string. */ 161 public static final String FUNC_CEILING_STRING = "ceiling"; 162 163 /** round function string. */ 164 public static final String FUNC_ROUND_STRING = "round"; 165 166 /** sum function string. */ 167 public static final String FUNC_SUM_STRING = "sum"; 168 169 /** string function string. */ 170 public static final String FUNC_STRING_STRING = "string"; 171 172 /** starts-with function string. */ 173 public static final String FUNC_STARTS_WITH_STRING = "starts-with"; 174 175 /** contains function string. */ 176 public static final String FUNC_CONTAINS_STRING = "contains"; 177 178 /** substring-before function string. */ 179 public static final String FUNC_SUBSTRING_BEFORE_STRING = 180 "substring-before"; 181 182 /** substring-after function string. */ 183 public static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after"; 184 185 /** normalize-space function string. */ 186 public static final String FUNC_NORMALIZE_SPACE_STRING = "normalize-space"; 187 188 /** translate function string. */ 189 public static final String FUNC_TRANSLATE_STRING = "translate"; 190 191 /** concat function string. */ 192 public static final String FUNC_CONCAT_STRING = "concat"; 193 194 /** system-property function string. */ 195 public static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property"; 196 197 /** function-available function string (XSLT). */ 198 public static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING = 199 "function-available"; 200 201 /** element-available function string (XSLT). */ 202 public static final String FUNC_EXT_ELEM_AVAILABLE_STRING = 203 "element-available"; 204 205 /** substring function string. */ 206 public static final String FUNC_SUBSTRING_STRING = "substring"; 207 208 /** string-length function string. */ 209 public static final String FUNC_STRING_LENGTH_STRING = "string-length"; 210 211 /** unparsed-entity-uri function string (XSLT). */ 212 public static final String FUNC_UNPARSED_ENTITY_URI_STRING = 213 "unparsed-entity-uri"; 214 215 /** here function string (XML Signature). */ 216 public static final String FUNC_HERE_STRING = "here"; 217 218 // Proprietary, built in functions 219 220 /** current function string (Proprietary). */ 221 public static final String FUNC_DOCLOCATION_STRING = "document-location"; 222 223 static 224 { 225 m_axisnames.put(FROM_ANCESTORS_STRING, 226 new Integer(OpCodes.FROM_ANCESTORS)); 227 m_axisnames.put(FROM_ANCESTORS_OR_SELF_STRING, 228 new Integer(OpCodes.FROM_ANCESTORS_OR_SELF)); 229 m_axisnames.put(FROM_ATTRIBUTES_STRING, 230 new Integer(OpCodes.FROM_ATTRIBUTES)); 231 m_axisnames.put(FROM_CHILDREN_STRING, 232 new Integer(OpCodes.FROM_CHILDREN)); 233 m_axisnames.put(FROM_DESCENDANTS_STRING, 234 new Integer(OpCodes.FROM_DESCENDANTS)); 235 m_axisnames.put(FROM_DESCENDANTS_OR_SELF_STRING, 236 new Integer(OpCodes.FROM_DESCENDANTS_OR_SELF)); 237 m_axisnames.put(FROM_FOLLOWING_STRING, 238 new Integer(OpCodes.FROM_FOLLOWING)); 239 m_axisnames.put(FROM_FOLLOWING_SIBLINGS_STRING, 240 new Integer(OpCodes.FROM_FOLLOWING_SIBLINGS)); 241 m_axisnames.put(FROM_PARENT_STRING, 242 new Integer(OpCodes.FROM_PARENT)); 243 m_axisnames.put(FROM_PRECEDING_STRING, 244 new Integer(OpCodes.FROM_PRECEDING)); 245 m_axisnames.put(FROM_PRECEDING_SIBLINGS_STRING, 246 new Integer(OpCodes.FROM_PRECEDING_SIBLINGS)); 247 m_axisnames.put(FROM_SELF_STRING, 248 new Integer(OpCodes.FROM_SELF)); 249 m_axisnames.put(FROM_NAMESPACE_STRING, 250 new Integer(OpCodes.FROM_NAMESPACE)); 251 m_nodetypes.put(NODETYPE_COMMENT_STRING, 252 new Integer(OpCodes.NODETYPE_COMMENT)); 253 m_nodetypes.put(NODETYPE_TEXT_STRING, 254 new Integer(OpCodes.NODETYPE_TEXT)); 255 m_nodetypes.put(NODETYPE_PI_STRING, 256 new Integer(OpCodes.NODETYPE_PI)); 257 m_nodetypes.put(NODETYPE_NODE_STRING, 258 new Integer(OpCodes.NODETYPE_NODE)); 259 m_nodetypes.put(NODETYPE_ANYELEMENT_STRING, 260 new Integer(OpCodes.NODETYPE_ANYELEMENT)); 261 m_keywords.put(FROM_SELF_ABBREVIATED_STRING, 262 new Integer(OpCodes.FROM_SELF)); 263 m_keywords.put(FUNC_ID_STRING, 264 new Integer(FunctionTable.FUNC_ID)); 265 m_keywords.put(FUNC_KEY_STRING, 266 new Integer(FunctionTable.FUNC_KEY)); 267 268 m_nodetests.put(NODETYPE_COMMENT_STRING, 269 new Integer(OpCodes.NODETYPE_COMMENT)); 270 m_nodetests.put(NODETYPE_TEXT_STRING, 271 new Integer(OpCodes.NODETYPE_TEXT)); 272 m_nodetests.put(NODETYPE_PI_STRING, 273 new Integer(OpCodes.NODETYPE_PI)); 274 m_nodetests.put(NODETYPE_NODE_STRING, 275 new Integer(OpCodes.NODETYPE_NODE)); 276 } 277 278 static Object getAxisName(String key){ 279 return m_axisnames.get(key); 280 } 281 282 static Object lookupNodeTest(String key){ 283 return m_nodetests.get(key); 284 } 285 286 static Object getKeyWord(String key){ 287 return m_keywords.get(key); 288 } 289 290 static Object getNodeType(String key){ 291 return m_nodetypes.get(key); 292 } 293} 294