1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler.util; 21 22 import java.text.MessageFormat ; 23 import java.util.Locale ; 24 import java.util.ResourceBundle ; 25 26 import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet; 27 import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode; 28 29 36 public final class ErrorMsg { 37 38 private String _code; 39 private int _line; 40 private String _message = null; 41 private String _url = null; 42 Object [] _params = null; 43 44 public static final String MULTIPLE_STYLESHEET_ERR = "MULTIPLE_STYLESHEET_ERR"; 46 public static final String TEMPLATE_REDEF_ERR = "TEMPLATE_REDEF_ERR"; 47 public static final String TEMPLATE_UNDEF_ERR = "TEMPLATE_UNDEF_ERR"; 48 public static final String VARIABLE_REDEF_ERR = "VARIABLE_REDEF_ERR"; 49 public static final String VARIABLE_UNDEF_ERR = "VARIABLE_UNDEF_ERR"; 50 public static final String CLASS_NOT_FOUND_ERR = "CLASS_NOT_FOUND_ERR"; 51 public static final String METHOD_NOT_FOUND_ERR = "METHOD_NOT_FOUND_ERR"; 52 public static final String ARGUMENT_CONVERSION_ERR = "ARGUMENT_CONVERSION_ERR"; 53 public static final String FILE_NOT_FOUND_ERR = "FILE_NOT_FOUND_ERR"; 54 public static final String INVALID_URI_ERR = "INVALID_URI_ERR"; 55 public static final String FILE_ACCESS_ERR = "FILE_ACCESS_ERR"; 56 public static final String MISSING_ROOT_ERR = "MISSING_ROOT_ERR"; 57 public static final String NAMESPACE_UNDEF_ERR = "NAMESPACE_UNDEF_ERR"; 58 public static final String FUNCTION_RESOLVE_ERR = "FUNCTION_RESOLVE_ERR"; 59 public static final String NEED_LITERAL_ERR = "NEED_LITERAL_ERR"; 60 public static final String XPATH_PARSER_ERR = "XPATH_PARSER_ERR"; 61 public static final String REQUIRED_ATTR_ERR = "REQUIRED_ATTR_ERR"; 62 public static final String ILLEGAL_CHAR_ERR = "ILLEGAL_CHAR_ERR"; 63 public static final String ILLEGAL_PI_ERR = "ILLEGAL_PI_ERR"; 64 public static final String STRAY_ATTRIBUTE_ERR = "STRAY_ATTRIBUTE_ERR"; 65 public static final String ILLEGAL_ATTRIBUTE_ERR = "ILLEGAL_ATTRIBUTE_ERR"; 66 public static final String CIRCULAR_INCLUDE_ERR = "CIRCULAR_INCLUDE_ERR"; 67 public static final String RESULT_TREE_SORT_ERR = "RESULT_TREE_SORT_ERR"; 68 public static final String SYMBOLS_REDEF_ERR = "SYMBOLS_REDEF_ERR"; 69 public static final String XSL_VERSION_ERR = "XSL_VERSION_ERR"; 70 public static final String CIRCULAR_VARIABLE_ERR = "CIRCULAR_VARIABLE_ERR"; 71 public static final String ILLEGAL_BINARY_OP_ERR = "ILLEGAL_BINARY_OP_ERR"; 72 public static final String ILLEGAL_ARG_ERR = "ILLEGAL_ARG_ERR"; 73 public static final String DOCUMENT_ARG_ERR = "DOCUMENT_ARG_ERR"; 74 public static final String MISSING_WHEN_ERR = "MISSING_WHEN_ERR"; 75 public static final String MULTIPLE_OTHERWISE_ERR = "MULTIPLE_OTHERWISE_ERR"; 76 public static final String STRAY_OTHERWISE_ERR = "STRAY_OTHERWISE_ERR"; 77 public static final String STRAY_WHEN_ERR = "STRAY_WHEN_ERR"; 78 public static final String WHEN_ELEMENT_ERR = "WHEN_ELEMENT_ERR"; 79 public static final String UNNAMED_ATTRIBSET_ERR = "UNNAMED_ATTRIBSET_ERR"; 80 public static final String ILLEGAL_CHILD_ERR = "ILLEGAL_CHILD_ERR"; 81 public static final String ILLEGAL_ELEM_NAME_ERR = "ILLEGAL_ELEM_NAME_ERR"; 82 public static final String ILLEGAL_ATTR_NAME_ERR = "ILLEGAL_ATTR_NAME_ERR"; 83 public static final String ILLEGAL_TEXT_NODE_ERR = "ILLEGAL_TEXT_NODE_ERR"; 84 public static final String SAX_PARSER_CONFIG_ERR = "SAX_PARSER_CONFIG_ERR"; 85 public static final String INTERNAL_ERR = "INTERNAL_ERR"; 86 public static final String UNSUPPORTED_XSL_ERR = "UNSUPPORTED_XSL_ERR"; 87 public static final String UNSUPPORTED_EXT_ERR = "UNSUPPORTED_EXT_ERR"; 88 public static final String MISSING_XSLT_URI_ERR = "MISSING_XSLT_URI_ERR"; 89 public static final String MISSING_XSLT_TARGET_ERR = "MISSING_XSLT_TARGET_ERR"; 90 public static final String NOT_IMPLEMENTED_ERR = "NOT_IMPLEMENTED_ERR"; 91 public static final String NOT_STYLESHEET_ERR = "NOT_STYLESHEET_ERR"; 92 public static final String ELEMENT_PARSE_ERR = "ELEMENT_PARSE_ERR"; 93 public static final String KEY_USE_ATTR_ERR = "KEY_USE_ATTR_ERR"; 94 public static final String OUTPUT_VERSION_ERR = "OUTPUT_VERSION_ERR"; 95 public static final String ILLEGAL_RELAT_OP_ERR = "ILLEGAL_RELAT_OP_ERR"; 96 public static final String ATTRIBSET_UNDEF_ERR = "ATTRIBSET_UNDEF_ERR"; 97 public static final String ATTR_VAL_TEMPLATE_ERR = "ATTR_VAL_TEMPLATE_ERR"; 98 public static final String UNKNOWN_SIG_TYPE_ERR = "UNKNOWN_SIG_TYPE_ERR"; 99 public static final String DATA_CONVERSION_ERR = "DATA_CONVERSION_ERR"; 100 101 public static final String NO_TRANSLET_CLASS_ERR = "NO_TRANSLET_CLASS_ERR"; 103 public static final String NO_MAIN_TRANSLET_ERR = "NO_MAIN_TRANSLET_ERR"; 104 public static final String TRANSLET_CLASS_ERR = "TRANSLET_CLASS_ERR"; 105 public static final String TRANSLET_OBJECT_ERR = "TRANSLET_OBJECT_ERR"; 106 public static final String ERROR_LISTENER_NULL_ERR = "ERROR_LISTENER_NULL_ERR"; 107 public static final String JAXP_UNKNOWN_SOURCE_ERR = "JAXP_UNKNOWN_SOURCE_ERR"; 108 public static final String JAXP_NO_SOURCE_ERR = "JAXP_NO_SOURCE_ERR"; 109 public static final String JAXP_COMPILE_ERR = "JAXP_COMPILE_ERR"; 110 public static final String JAXP_INVALID_ATTR_ERR = "JAXP_INVALID_ATTR_ERR"; 111 public static final String JAXP_SET_RESULT_ERR = "JAXP_SET_RESULT_ERR"; 112 public static final String JAXP_NO_TRANSLET_ERR = "JAXP_NO_TRANSLET_ERR"; 113 public static final String JAXP_NO_HANDLER_ERR = "JAXP_NO_HANDLER_ERR"; 114 public static final String JAXP_NO_RESULT_ERR = "JAXP_NO_RESULT_ERR"; 115 public static final String JAXP_UNKNOWN_PROP_ERR = "JAXP_UNKNOWN_PROP_ERR"; 116 public static final String SAX2DOM_ADAPTER_ERR = "SAX2DOM_ADAPTER_ERR"; 117 public static final String XSLTC_SOURCE_ERR = "XSLTC_SOURCE_ERR"; 118 public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; 119 public static final String JAXP_INVALID_SET_PARAM_VALUE = "JAXP_INVALID_SET_PARAM_VALUE"; 120 public static final String JAXP_SET_FEATURE_NULL_NAME = "JAXP_SET_FEATURE_NULL_NAME"; 121 public static final String JAXP_GET_FEATURE_NULL_NAME = "JAXP_GET_FEATURE_NULL_NAME"; 122 public static final String JAXP_UNSUPPORTED_FEATURE = "JAXP_UNSUPPORTED_FEATURE"; 123 124 public static final String COMPILE_STDIN_ERR = "COMPILE_STDIN_ERR"; 126 public static final String COMPILE_USAGE_STR = "COMPILE_USAGE_STR"; 127 public static final String TRANSFORM_USAGE_STR = "TRANSFORM_USAGE_STR"; 128 129 public static final String STRAY_SORT_ERR = "STRAY_SORT_ERR"; 131 public static final String UNSUPPORTED_ENCODING = "UNSUPPORTED_ENCODING"; 132 public static final String SYNTAX_ERR = "SYNTAX_ERR"; 133 public static final String CONSTRUCTOR_NOT_FOUND = "CONSTRUCTOR_NOT_FOUND"; 134 public static final String NO_JAVA_FUNCT_THIS_REF = "NO_JAVA_FUNCT_THIS_REF"; 135 public static final String TYPE_CHECK_ERR = "TYPE_CHECK_ERR"; 136 public static final String TYPE_CHECK_UNK_LOC_ERR = "TYPE_CHECK_UNK_LOC_ERR"; 137 public static final String ILLEGAL_CMDLINE_OPTION_ERR = "ILLEGAL_CMDLINE_OPTION_ERR"; 138 public static final String CMDLINE_OPT_MISSING_ARG_ERR = "CMDLINE_OPT_MISSING_ARG_ERR"; 139 public static final String WARNING_PLUS_WRAPPED_MSG = "WARNING_PLUS_WRAPPED_MSG"; 140 public static final String WARNING_MSG = "WARNING_MSG"; 141 public static final String FATAL_ERR_PLUS_WRAPPED_MSG = "FATAL_ERR_PLUS_WRAPPED_MSG"; 142 public static final String FATAL_ERR_MSG = "FATAL_ERR_MSG"; 143 public static final String ERROR_PLUS_WRAPPED_MSG = "ERROR_PLUS_WRAPPED_MSG"; 144 public static final String ERROR_MSG = "ERROR_MSG"; 145 public static final String TRANSFORM_WITH_TRANSLET_STR = "TRANSFORM_WITH_TRANSLET_STR"; 146 public static final String TRANSFORM_WITH_JAR_STR = "TRANSFORM_WITH_JAR_STR"; 147 public static final String COULD_NOT_CREATE_TRANS_FACT = "COULD_NOT_CREATE_TRANS_FACT"; 148 public static final String TRANSLET_NAME_JAVA_CONFLICT = 149 "TRANSLET_NAME_JAVA_CONFLICT"; 150 public static final String INVALID_QNAME_ERR = "INVALID_QNAME_ERR"; 151 public static final String INVALID_NCNAME_ERR = "INVALID_NCNAME_ERR"; 152 public static final String INVALID_METHOD_IN_OUTPUT = "INVALID_METHOD_IN_OUTPUT"; 153 154 private static ResourceBundle _bundle; 157 158 public final static String ERROR_MESSAGES_KEY = "ERROR_MESSAGES_KEY"; 159 public final static String COMPILER_ERROR_KEY = "COMPILER_ERROR_KEY"; 160 public final static String COMPILER_WARNING_KEY = "COMPILER_WARNING_KEY"; 161 public final static String RUNTIME_ERROR_KEY = "RUNTIME_ERROR_KEY"; 162 163 static { 164 _bundle = ResourceBundle.getBundle( 165 "com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMessages", 166 Locale.getDefault()); 167 } 168 169 public ErrorMsg(String code) { 170 _code = code; 171 _line = 0; 172 } 173 174 public ErrorMsg(Throwable e) { 175 _code = null; 176 _message = e.getMessage(); 177 _line = 0; 178 } 179 180 public ErrorMsg(String message, int line) { 181 _code = null; 182 _message = message; 183 _line = line; 184 } 185 186 public ErrorMsg(String code, int line, Object param) { 187 _code = code; 188 _line = line; 189 _params = new Object [] { param }; 190 } 191 192 public ErrorMsg(String code, Object param) { 193 this(code); 194 _params = new Object [1]; 195 _params[0] = param; 196 } 197 198 public ErrorMsg(String code, Object param1, Object param2) { 199 this(code); 200 _params = new Object [2]; 201 _params[0] = param1; 202 _params[1] = param2; 203 } 204 205 public ErrorMsg(String code, SyntaxTreeNode node) { 206 _code = code; 207 _url = getFileName(node); 208 _line = node.getLineNumber(); 209 } 210 211 public ErrorMsg(String code, Object param1, SyntaxTreeNode node) { 212 _code = code; 213 _url = getFileName(node); 214 _line = node.getLineNumber(); 215 _params = new Object [1]; 216 _params[0] = param1; 217 } 218 219 public ErrorMsg(String code, Object param1, Object param2, 220 SyntaxTreeNode node) { 221 _code = code; 222 _url = getFileName(node); 223 _line = node.getLineNumber(); 224 _params = new Object [2]; 225 _params[0] = param1; 226 _params[1] = param2; 227 } 228 229 private String getFileName(SyntaxTreeNode node) { 230 Stylesheet stylesheet = node.getStylesheet(); 231 if (stylesheet != null) 232 return stylesheet.getSystemId(); 233 else 234 return null; 235 } 236 237 private String formatLine() { 238 StringBuffer result = new StringBuffer (); 239 if (_url != null) { 240 result.append(_url); 241 result.append(": "); 242 } 243 if (_line > 0) { 244 result.append("line "); 245 result.append(Integer.toString(_line)); 246 result.append(": "); 247 } 248 return result.toString(); 249 } 250 251 256 public String toString() { 257 String suffix = (_params == null) ? 258 (null != _code ? new String (getErrorMessage()) : _message) 259 : MessageFormat.format(getErrorMessage(), _params); 260 return formatLine() + suffix; 261 } 262 263 public String toString(Object obj) { 264 Object params[] = new Object [1]; 265 params[0] = obj.toString(); 266 String suffix = MessageFormat.format(getErrorMessage(), params); 267 return formatLine() + suffix; 268 } 269 270 public String toString(Object obj0, Object obj1) { 271 Object params[] = new Object [2]; 272 params[0] = obj0.toString(); 273 params[1] = obj1.toString(); 274 String suffix = MessageFormat.format(getErrorMessage(), params); 275 return formatLine() + suffix; 276 } 277 278 285 private String getErrorMessage() { 286 return _bundle.getString(_code); 287 } 288 } 289 290 | Popular Tags |