author | joehw |
Tue, 09 Jul 2013 16:34:52 -0700 | |
changeset 18890 | 25bdeca3173b |
parent 17991 | 4a8c5120a8d4 |
child 20968 | dde41f8b7b96 |
permissions | -rw-r--r-- |
12005 | 1 |
/* |
2 |
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. |
|
3 |
*/ |
|
4 |
||
5 |
/* |
|
6 |
* Copyright 2005 The Apache Software Foundation. |
|
7 |
* |
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
9 |
* you may not use this file except in compliance with the License. |
|
10 |
* You may obtain a copy of the License at |
|
11 |
* |
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
13 |
* |
|
14 |
* Unless required by applicable law or agreed to in writing, software |
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17 |
* See the License for the specific language governing permissions and |
|
18 |
* limitations under the License. |
|
19 |
*/ |
|
20 |
||
21 |
package com.sun.org.apache.xerces.internal.impl; |
|
22 |
||
17534 | 23 |
import com.sun.org.apache.xerces.internal.utils.SecuritySupport; |
12005 | 24 |
import java.util.Enumeration; |
25 |
import java.util.NoSuchElementException; |
|
26 |
||
27 |
/** |
|
28 |
* Commonly used constants. |
|
29 |
* |
|
30 |
* @xerces.internal |
|
31 |
* |
|
32 |
* @author Andy Clark, IBM |
|
33 |
* |
|
34 |
* @version $Id: Constants.java,v 1.14 2010-11-01 04:39:40 joehw Exp $ |
|
35 |
*/ |
|
36 |
public final class Constants { |
|
37 |
||
38 |
// |
|
39 |
// Constants |
|
40 |
// |
|
41 |
// Schema Types: |
|
42 |
public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern(); |
|
43 |
public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern(); |
|
44 |
||
45 |
// Schema features |
|
46 |
public static final String SUN_SCHEMA_FEATURE_PREFIX = "http://java.sun.com/xml/schema/features/"; |
|
47 |
public static final String SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE = "report-ignored-element-content-whitespace"; |
|
48 |
||
49 |
//stax properties |
|
50 |
||
51 |
public static final String ZEPHYR_PROPERTY_PREFIX = "http://java.sun.com/xml/stream/properties/" ; |
|
52 |
public static final String STAX_PROPERTIES = "stax-properties" ; |
|
53 |
public static final String STAX_ENTITY_RESOLVER_PROPERTY = "internal/stax-entity-resolver"; |
|
54 |
public static final String STAX_REPORT_CDATA_EVENT = "report-cdata-event"; |
|
55 |
public static final String READER_IN_DEFINED_STATE = ZEPHYR_PROPERTY_PREFIX + "reader-in-defined-state" ; |
|
56 |
public static final String ADD_NAMESPACE_DECL_AS_ATTRIBUTE = "add-namespacedecl-as-attrbiute"; |
|
57 |
public static final String ESCAPE_CHARACTERS = "escapeCharacters"; |
|
58 |
public static final String REUSE_INSTANCE = "reuse-instance" ; |
|
59 |
||
60 |
//DOM properties |
|
61 |
public static final String SUN_DOM_PROPERTY_PREFIX = "http://java.sun.com/xml/dom/properties/" ; |
|
62 |
public static final String SUN_DOM_ANCESTOR_CHECCK = "ancestor-check"; |
|
63 |
||
64 |
/** |
|
65 |
* If true, ignore DOCTYPE declaration as if it wasn't present at all. |
|
66 |
* Note that this is a violation of the XML recommendation. |
|
67 |
* The full property name is prefixed by {@link #ZEPHYR_PROPERTY_PREFIX}. |
|
68 |
*/ |
|
69 |
public static final String IGNORE_EXTERNAL_DTD = "ignore-external-dtd"; |
|
70 |
||
71 |
// sax features |
|
72 |
||
73 |
/** SAX feature prefix ("http://xml.org/sax/features/"). */ |
|
74 |
public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/"; |
|
75 |
||
76 |
public static final String NAMESPACES_FEATURE = "namespaces"; |
|
77 |
||
78 |
/** Namespace prefixes feature ("namespace-prefixes"). */ |
|
79 |
public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes"; |
|
80 |
||
81 |
/** String interning feature ("string-interning"). */ |
|
82 |
public static final String STRING_INTERNING_FEATURE = "string-interning"; |
|
83 |
||
84 |
/** Validation feature ("validation"). */ |
|
85 |
public static final String VALIDATION_FEATURE = "validation"; |
|
86 |
||
87 |
/** External general entities feature ("external-general-entities "). */ |
|
88 |
public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities"; |
|
89 |
||
90 |
/** External parameter entities feature ("external-parameter-entities "). */ |
|
91 |
public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities"; |
|
92 |
||
93 |
/** Lexical handler parameter entities feature ("lexical-handler/parameter-entities"). */ |
|
94 |
public static final String LEXICAL_HANDLER_PARAMETER_ENTITIES_FEATURE = "lexical-handler/parameter-entities"; |
|
95 |
||
96 |
/** Is standalone feature ("is-standalone"). */ |
|
97 |
public static final String IS_STANDALONE_FEATURE = "is-standalone"; |
|
98 |
||
99 |
/** Resolve DTD URIs feature ("resolve-dtd-uris"). */ |
|
100 |
public static final String RESOLVE_DTD_URIS_FEATURE = "resolve-dtd-uris"; |
|
101 |
||
102 |
/** Use Attributes2 feature ("use-attributes2"). */ |
|
103 |
public static final String USE_ATTRIBUTES2_FEATURE = "use-attributes2"; |
|
104 |
||
105 |
/** Use Locator2 feature ("use-locator2"). */ |
|
106 |
public static final String USE_LOCATOR2_FEATURE = "use-locator2"; |
|
107 |
||
108 |
/** Use EntityResolver2 feature ("use-entity-resolver2"). */ |
|
109 |
public static final String USE_ENTITY_RESOLVER2_FEATURE = "use-entity-resolver2"; |
|
110 |
||
111 |
/** Unicode normalization checking feature ("unicode-normalization-checking"). */ |
|
112 |
public static final String UNICODE_NORMALIZATION_CHECKING_FEATURE = "unicode-normalization-checking"; |
|
113 |
||
114 |
/** xmlns URIs feature ("xmlns-uris"). */ |
|
115 |
public static final String XMLNS_URIS_FEATURE = "xmlns-uris"; |
|
116 |
||
117 |
/** XML 1.1 feature ("xml-1.1"). */ |
|
118 |
public static final String XML_11_FEATURE = "xml-1.1"; |
|
119 |
||
120 |
/** Allow unparsed entity and notation declaration events to be sent after the end DTD event ("allow-dtd-events-after-endDTD") */ |
|
121 |
public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD"; |
|
122 |
||
123 |
// sax properties |
|
124 |
||
125 |
/** SAX property prefix ("http://xml.org/sax/properties/"). */ |
|
126 |
public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/"; |
|
127 |
||
128 |
/** Declaration handler property ("declaration-handler"). */ |
|
129 |
public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler"; |
|
130 |
||
131 |
/** Lexical handler property ("lexical-handler"). */ |
|
132 |
public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler"; |
|
133 |
||
134 |
/** DOM node property ("dom-node"). */ |
|
135 |
public static final String DOM_NODE_PROPERTY = "dom-node"; |
|
136 |
||
137 |
/** XML string property ("xml-string"). */ |
|
138 |
public static final String XML_STRING_PROPERTY = "xml-string"; |
|
139 |
||
12458 | 140 |
public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing"; |
141 |
||
17534 | 142 |
// Oracle Feature: |
143 |
/** |
|
144 |
* <p>Use Service Mechanism</p> |
|
145 |
* |
|
146 |
* <ul> |
|
147 |
* <li> |
|
148 |
* {@code true} instruct an object to use service mechanism to |
|
149 |
* find a service implementation. This is the default behavior. |
|
150 |
* </li> |
|
151 |
* <li> |
|
152 |
* {@code false} instruct an object to skip service mechanism and |
|
153 |
* use the default implementation for that service. |
|
154 |
* </li> |
|
155 |
* </ul> |
|
156 |
*/ |
|
12458 | 157 |
public static final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism"; |
12005 | 158 |
|
159 |
/** Document XML version property ("document-xml-version"). */ |
|
160 |
public static final String DOCUMENT_XML_VERSION_PROPERTY = "document-xml-version"; |
|
161 |
||
162 |
||
163 |
// |
|
164 |
// JAXP properties |
|
165 |
// |
|
166 |
||
167 |
/** JAXP property prefix ("http://java.sun.com/xml/jaxp/properties/"). */ |
|
168 |
public static final String JAXP_PROPERTY_PREFIX = |
|
169 |
"http://java.sun.com/xml/jaxp/properties/"; |
|
170 |
||
171 |
/** JAXP schemaSource property: when used internally may include DTD sources (DOM) */ |
|
172 |
public static final String SCHEMA_SOURCE = "schemaSource"; |
|
173 |
||
174 |
/** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */ |
|
175 |
public static final String SCHEMA_LANGUAGE = "schemaLanguage"; |
|
176 |
||
177 |
public static final String SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ; |
|
178 |
||
17534 | 179 |
/** JAXP Standard property prefix ("http://javax.xml.XMLConstants/property/"). */ |
180 |
public static final String JAXPAPI_PROPERTY_PREFIX = |
|
181 |
"http://javax.xml.XMLConstants/property/"; |
|
182 |
||
183 |
/** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */ |
|
184 |
public static final String ORACLE_JAXP_PROPERTY_PREFIX = |
|
185 |
"http://www.oracle.com/xml/jaxp/properties/"; |
|
186 |
||
18890
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
187 |
public static final String XML_SECURITY_PROPERTY_MANAGER = |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
188 |
ORACLE_JAXP_PROPERTY_PREFIX + "xmlSecurityPropertyManager"; |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
189 |
|
17534 | 190 |
//System Properties corresponding to ACCESS_EXTERNAL_* properties |
191 |
public static final String SP_ACCESS_EXTERNAL_DTD = "javax.xml.accessExternalDTD"; |
|
192 |
public static final String SP_ACCESS_EXTERNAL_SCHEMA = "javax.xml.accessExternalSchema"; |
|
193 |
//all access keyword |
|
194 |
public static final String ACCESS_EXTERNAL_ALL = "all"; |
|
195 |
||
196 |
/** |
|
197 |
* Default value when FEATURE_SECURE_PROCESSING (FSP) is set to true |
|
198 |
*/ |
|
199 |
public static final String EXTERNAL_ACCESS_DEFAULT_FSP = ""; |
|
200 |
||
201 |
/** |
|
202 |
* FEATURE_SECURE_PROCESSING (FSP) is true by default |
|
203 |
*/ |
|
17991
4a8c5120a8d4
8015630: Remove default restriction settings of jaxp 1.5 properties in JDK8
joehw
parents:
17534
diff
changeset
|
204 |
public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; |
17534 | 205 |
|
18890
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
206 |
/** |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
207 |
* Check if we're in jdk8 or above |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
208 |
*/ |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
209 |
public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8); |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
210 |
|
12005 | 211 |
// |
212 |
// DOM features |
|
213 |
// |
|
214 |
||
215 |
/** Comments feature ("include-comments"). */ |
|
216 |
public static final String INCLUDE_COMMENTS_FEATURE = "include-comments"; |
|
217 |
||
218 |
/** Create cdata nodes feature ("create-cdata-nodes"). */ |
|
219 |
public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes"; |
|
220 |
||
221 |
/** Feature id: load as infoset. */ |
|
222 |
public static final String LOAD_AS_INFOSET = "load-as-infoset"; |
|
223 |
||
224 |
||
225 |
// |
|
226 |
// Constants: DOM Level 3 feature ids |
|
227 |
// |
|
228 |
||
229 |
public static final String DOM_CANONICAL_FORM = "canonical-form"; |
|
230 |
public static final String DOM_CDATA_SECTIONS ="cdata-sections"; |
|
231 |
||
232 |
public static final String DOM_COMMENTS = "comments"; |
|
233 |
||
234 |
// REVISIT: this feature seems to have no effect for Xerces |
|
235 |
||
236 |
public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = |
|
237 |
"charset-overrides-xml-encoding"; |
|
238 |
||
239 |
public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization"; |
|
240 |
||
241 |
public static final String DOM_ENTITIES = "entities"; |
|
242 |
public static final String DOM_INFOSET = "infoset"; |
|
243 |
public static final String DOM_NAMESPACES = "namespaces"; |
|
244 |
public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations"; |
|
245 |
public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = |
|
246 |
"supported-media-types-only"; |
|
247 |
||
248 |
public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema"; |
|
249 |
public static final String DOM_VALIDATE = "validate"; |
|
250 |
public static final String DOM_ELEMENT_CONTENT_WHITESPACE = |
|
251 |
"element-content-whitespace"; |
|
252 |
||
253 |
// DOM Level 3 features defined in Core: |
|
254 |
public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content"; |
|
255 |
public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters"; |
|
256 |
public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization"; |
|
257 |
public static final String DOM_WELLFORMED = "well-formed"; |
|
258 |
public static final String DOM_SPLIT_CDATA = "split-cdata-sections"; |
|
259 |
||
260 |
// Load and Save |
|
261 |
public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print"; |
|
262 |
public static final String DOM_XMLDECL = "xml-declaration"; |
|
263 |
public static final String DOM_UNKNOWNCHARS = "unknown-characters"; |
|
264 |
public static final String DOM_CERTIFIED = "certified"; |
|
265 |
public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype"; |
|
266 |
public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations"; |
|
267 |
||
268 |
// DOM Properties |
|
269 |
public static final String DOM_RESOURCE_RESOLVER = "resource-resolver"; |
|
270 |
public static final String DOM_ERROR_HANDLER = "error-handler"; |
|
271 |
public static final String DOM_SCHEMA_TYPE = "schema-type"; |
|
272 |
public static final String DOM_SCHEMA_LOCATION = "schema-location"; |
|
273 |
public static final String DOM_ANCESTOR_CHECCK = "ancestor-check"; |
|
274 |
// XSModel |
|
275 |
public static final String DOM_PSVI = "psvi"; |
|
276 |
||
277 |
||
278 |
// xerces features |
|
279 |
||
280 |
/** Xerces features prefix ("http://apache.org/xml/features/"). */ |
|
281 |
public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/"; |
|
282 |
||
283 |
/** Schema validation feature ("validation/schema"). */ |
|
284 |
public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema"; |
|
285 |
||
286 |
/** Expose schema normalized values */ |
|
287 |
public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value"; |
|
288 |
||
289 |
/** Send schema default value via characters() */ |
|
290 |
public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default"; |
|
291 |
||
292 |
/** Schema full constraint checking ("validation/schema-full-checking"). */ |
|
293 |
public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking"; |
|
294 |
||
295 |
/** Augment Post-Schema-Validation-Infoset */ |
|
296 |
public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi"; |
|
297 |
||
298 |
/** Dynamic validation feature ("validation/dynamic"). */ |
|
299 |
public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic"; |
|
300 |
||
301 |
/** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */ |
|
302 |
public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef"; |
|
303 |
||
304 |
/** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */ |
|
305 |
public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef"; |
|
306 |
||
307 |
/** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */ |
|
308 |
public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef"; |
|
309 |
||
310 |
/** Allow Java encoding names feature ("allow-java-encodings"). */ |
|
311 |
public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings"; |
|
312 |
||
313 |
/** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */ |
|
314 |
public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl"; |
|
315 |
||
316 |
/** Continue after fatal error feature ("continue-after-fatal-error"). */ |
|
317 |
public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error"; |
|
318 |
||
319 |
/** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */ |
|
320 |
public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar"; |
|
321 |
||
322 |
/** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */ |
|
323 |
public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd"; |
|
324 |
||
325 |
/** Defer node expansion feature ("dom/defer-node-expansion"). */ |
|
326 |
public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion"; |
|
327 |
||
328 |
/** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */ |
|
329 |
public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes"; |
|
330 |
||
331 |
/** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */ |
|
332 |
public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace"; |
|
333 |
||
334 |
/** Default attribute values feature ("validation/default-attribute-values"). */ |
|
335 |
public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values"; |
|
336 |
||
337 |
/** Validate content models feature ("validation/validate-content-models"). */ |
|
338 |
public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models"; |
|
339 |
||
340 |
/** Validate datatypes feature ("validation/validate-datatypes"). */ |
|
341 |
public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes"; |
|
342 |
||
343 |
/** Balance syntax trees feature ("validation/balance-syntax-trees"). */ |
|
344 |
public static final String BALANCE_SYNTAX_TREES = "validation/balance-syntax-trees"; |
|
345 |
||
346 |
/** Notify character references feature (scanner/notify-char-refs"). */ |
|
347 |
public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs"; |
|
348 |
||
349 |
/** Notify built-in (&amp;, etc.) references feature (scanner/notify-builtin-refs"). */ |
|
350 |
public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs"; |
|
351 |
||
352 |
/** Standard URI conformant feature ("standard-uri-conformant"). */ |
|
353 |
public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant"; |
|
354 |
||
355 |
/** Generate synthetic annotations feature ("generate-synthetic-annotations"). */ |
|
356 |
public static final String GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE = "generate-synthetic-annotations"; |
|
357 |
||
358 |
/** Validate annotations feature ("validate-annotations"). */ |
|
359 |
public static final String VALIDATE_ANNOTATIONS_FEATURE = "validate-annotations"; |
|
360 |
||
361 |
||
362 |
/** Honour all schemaLocations feature ("honour-all-schemaLocations"). */ |
|
363 |
public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations"; |
|
364 |
||
365 |
/** Namespace growth feature ("namespace-growth"). */ |
|
366 |
public static final String NAMESPACE_GROWTH_FEATURE = "namespace-growth"; |
|
367 |
||
368 |
/** Tolerate duplicates feature ("internal/tolerate-duplicates"). */ |
|
369 |
public static final String TOLERATE_DUPLICATES_FEATURE = "internal/tolerate-duplicates"; |
|
370 |
||
371 |
/** XInclude processing feature ("xinclude"). */ |
|
372 |
public static final String XINCLUDE_FEATURE = "xinclude"; |
|
373 |
||
374 |
/** XInclude fixup base URIs feature ("xinclude/fixup-base-uris"). */ |
|
375 |
public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris"; |
|
376 |
||
377 |
/** XInclude fixup language feature ("xinclude/fixup-language"). */ |
|
378 |
public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language"; |
|
379 |
||
380 |
/** |
|
381 |
* Internal feature. When set to true the schema validator will only use |
|
382 |
* schema components from the grammar pool provided. |
|
383 |
*/ |
|
384 |
public static final String USE_GRAMMAR_POOL_ONLY_FEATURE = "internal/validation/schema/use-grammar-pool-only"; |
|
385 |
||
386 |
/** Internal performance related feature: |
|
387 |
* false - the parser settings (features/properties) have not changed between 2 parses |
|
388 |
* true - the parser settings have changed between 2 parses |
|
389 |
* NOTE: this feature should only be set by the parser configuration. |
|
390 |
*/ |
|
391 |
public static final String PARSER_SETTINGS = "internal/parser-settings"; |
|
392 |
||
393 |
||
394 |
/** Feature to make XML Processor XInclude Aware */ |
|
395 |
public static final String XINCLUDE_AWARE = "xinclude-aware"; |
|
396 |
||
397 |
/** Ignore xsi:schemaLocation and xsi:noNamespaceSchemaLocation. */ |
|
398 |
public static final String IGNORE_SCHEMA_LOCATION_HINTS = "validation/schema/ignore-schema-location-hints"; |
|
399 |
||
400 |
/** |
|
401 |
* When true, the schema processor will change characters events |
|
402 |
* to ignorableWhitespaces events, when characters are expected to |
|
403 |
* only contain ignorable whitespaces. |
|
404 |
*/ |
|
405 |
public static final String CHANGE_IGNORABLE_CHARACTERS_INTO_IGNORABLE_WHITESPACES = |
|
406 |
"validation/change-ignorable-characters-into-ignorable-whitespaces"; |
|
407 |
||
408 |
// xerces properties |
|
409 |
||
410 |
/** Xerces properties prefix ("http://apache.org/xml/properties/"). */ |
|
411 |
public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/"; |
|
412 |
||
413 |
/** Current element node property ("dom/current-element-node"). */ |
|
414 |
public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node"; |
|
415 |
||
416 |
/** Document class name property ("dom/document-class-name"). */ |
|
417 |
public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name"; |
|
418 |
||
419 |
/** Symbol table property ("internal/symbol-table"). */ |
|
420 |
public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table"; |
|
421 |
||
422 |
/** Error reporter property ("internal/error-reporter"). */ |
|
423 |
public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter"; |
|
424 |
||
425 |
/** Error handler property ("internal/error-handler"). */ |
|
426 |
public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler"; |
|
427 |
||
428 |
/** XInclude handler property ("internal/xinclude-handler"). */ |
|
429 |
public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler"; |
|
430 |
||
431 |
/** XPointer handler property ("internal/xpointer-handler"). */ |
|
432 |
public static final String XPOINTER_HANDLER_PROPERTY = "internal/xpointer-handler"; |
|
433 |
||
434 |
/** Entity manager property ("internal/entity-manager"). */ |
|
435 |
public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager"; |
|
436 |
/** Input buffer size property ("input-buffer-size"). */ |
|
437 |
public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size"; |
|
438 |
||
439 |
/** Security manager property ("security-manager"). */ |
|
440 |
public static final String SECURITY_MANAGER_PROPERTY = "security-manager"; |
|
441 |
||
442 |
/** Locale property ("locale"). */ |
|
443 |
public static final String LOCALE_PROPERTY = "locale"; |
|
444 |
||
445 |
/** property identifier: security manager. */ |
|
446 |
protected static final String SECURITY_MANAGER = |
|
447 |
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY; |
|
448 |
||
449 |
||
450 |
public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver"; |
|
451 |
||
452 |
/** Grammar pool property ("internal/grammar-pool"). */ |
|
453 |
public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool"; |
|
454 |
||
455 |
/** Datatype validator factory ("internal/datatype-validator-factory"). */ |
|
456 |
public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory"; |
|
457 |
||
458 |
/** Document scanner property ("internal/document-scanner"). */ |
|
459 |
public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner"; |
|
460 |
||
461 |
/** DTD scanner property ("internal/dtd-scanner"). */ |
|
462 |
public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner"; |
|
463 |
||
464 |
/** DTD processor property ("internal/dtd-processor"). */ |
|
465 |
public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor"; |
|
466 |
||
467 |
/** Validator property ("internal/validator"). */ |
|
468 |
public static final String VALIDATOR_PROPERTY = "internal/validator"; |
|
469 |
||
470 |
/** Validator property ("internal/validator/dtd"). */ |
|
471 |
public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd"; |
|
472 |
||
473 |
/** Validator property ("internal/validator/schema"). */ |
|
474 |
public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema"; |
|
475 |
||
476 |
/** No namespace schema location property ("schema/external-schemaLocation"). */ |
|
477 |
public static final String SCHEMA_LOCATION = "schema/external-schemaLocation"; |
|
478 |
||
479 |
/** Schema location property ("schema/external-noNamespaceSchemaLocation"). */ |
|
480 |
public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation"; |
|
481 |
||
482 |
/** Namespace binder property ("internal/namespace-binder"). */ |
|
483 |
public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder"; |
|
484 |
||
485 |
/** Namespace context property ("internal/namespace-context"). */ |
|
486 |
public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context"; |
|
487 |
||
488 |
/** Validation manager property ("internal/validation-manager"). */ |
|
489 |
public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager"; |
|
490 |
||
491 |
||
492 |
/** XPointer Schema property ("xpointer-schema"). */ |
|
493 |
public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema"; |
|
494 |
||
495 |
/** Schema element declaration for the root element in a document ("internal/validation/schema/dv-factory"). */ |
|
496 |
public static final String SCHEMA_DV_FACTORY_PROPERTY = "internal/validation/schema/dv-factory"; |
|
497 |
||
498 |
||
499 |
// general constants |
|
500 |
||
501 |
/** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */ |
|
502 |
public final static String ELEMENT_PSVI = "ELEMENT_PSVI"; |
|
503 |
||
504 |
/** Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */ |
|
505 |
public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI"; |
|
506 |
||
507 |
/** |
|
508 |
* Boolean indicating whether an attribute is declared in the DTD is stored |
|
509 |
* in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this |
|
510 |
* augmentation indicates that the attribute was not declared in the DTD. |
|
511 |
*/ |
|
512 |
public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED"; |
|
513 |
||
514 |
public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit"; |
|
515 |
||
516 |
public final static String MAX_OCCUR_LIMIT = "maxOccurLimit"; |
|
517 |
||
518 |
/** |
|
519 |
* {@link org.w3c.dom.TypeInfo} associated with current element/attribute |
|
520 |
* is stored in augmentations using this string as the key. |
|
521 |
* |
|
522 |
* This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} |
|
523 |
* regarding what object the DOM will return from |
|
524 |
* {@link org.w3c.dom.Attr#getSchemaTypeInfo()} and |
|
525 |
* {@link org.w3c.dom.Element#getSchemaTypeInfo()} and |
|
526 |
*/ |
|
527 |
public final static String TYPEINFO = "org.w3c.dom.TypeInfo"; |
|
528 |
||
529 |
/** |
|
530 |
* Whether an attribute is an id or not is stored in augmentations |
|
531 |
* using this string as the key. The value is {@link Boolean#TRUE} |
|
532 |
* or {@link Boolean#FALSE}. |
|
533 |
* |
|
534 |
* This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} |
|
535 |
* about whether it will mark an attribute as ID or not. |
|
536 |
*/ |
|
537 |
public final static String ID_ATTRIBUTE = "ID_ATTRIBUTE"; |
|
538 |
||
539 |
// XML version constants |
|
540 |
||
541 |
/** |
|
542 |
* Boolean indicating whether an entity referenced in the document has |
|
543 |
* not been read is stored in augmentations using the string "ENTITY_SKIPPED". |
|
544 |
* The absence of this augmentation indicates that the entity had a |
|
545 |
* declaration and was expanded. |
|
546 |
*/ |
|
547 |
public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED"; |
|
548 |
||
549 |
/** |
|
550 |
* Boolean indicating whether a character is a probable white space |
|
551 |
* character (ch <= 0x20) that was the replacement text of a character |
|
552 |
* reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS". |
|
553 |
* The absence of this augmentation indicates that the character is not |
|
554 |
* probable white space and/or was not included from a character reference. |
|
555 |
*/ |
|
556 |
public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS"; |
|
557 |
||
558 |
/** Boolean indicating if this entity is the last opened entity. |
|
559 |
* |
|
560 |
*@see com.sun.org.apache.xerces.internal.impl.XMLEntityManager#endEntity() |
|
561 |
*@see com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl#endEntity() |
|
562 |
*@see com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl#endEntity() |
|
563 |
*/ |
|
564 |
public final static String LAST_ENTITY = "LAST_ENTITY"; |
|
565 |
||
566 |
// XML version constants |
|
567 |
public final static short XML_VERSION_ERROR = -1; |
|
568 |
public final static short XML_VERSION_1_0 = 1; |
|
569 |
public final static short XML_VERSION_1_1 = 2; |
|
570 |
||
571 |
||
572 |
||
573 |
// DOM related constants |
|
574 |
public final static String ANONYMOUS_TYPE_NAMESPACE = |
|
575 |
"http://apache.org/xml/xmlschema/1.0/anonymousTypes"; |
|
576 |
||
577 |
||
578 |
||
579 |
// Constant to enable Schema 1.1 support |
|
580 |
public final static boolean SCHEMA_1_1_SUPPORT = false; |
|
581 |
public final static short SCHEMA_VERSION_1_0 = 1; |
|
582 |
public final static short SCHEMA_VERSION_1_0_EXTENDED = 2; |
|
583 |
||
584 |
// private |
|
585 |
||
586 |
/** SAX features. */ |
|
587 |
private static final String[] fgSAXFeatures = { |
|
588 |
NAMESPACES_FEATURE, |
|
589 |
NAMESPACE_PREFIXES_FEATURE, |
|
590 |
STRING_INTERNING_FEATURE, |
|
591 |
VALIDATION_FEATURE, |
|
592 |
EXTERNAL_GENERAL_ENTITIES_FEATURE, |
|
593 |
EXTERNAL_PARAMETER_ENTITIES_FEATURE, |
|
594 |
}; |
|
595 |
||
596 |
/** SAX properties. */ |
|
597 |
private static final String[] fgSAXProperties = { |
|
598 |
DECLARATION_HANDLER_PROPERTY, |
|
599 |
LEXICAL_HANDLER_PROPERTY, |
|
600 |
DOM_NODE_PROPERTY, |
|
601 |
XML_STRING_PROPERTY, |
|
602 |
}; |
|
603 |
||
604 |
/** Xerces features. */ |
|
605 |
private static final String[] fgXercesFeatures = { |
|
606 |
||
607 |
SCHEMA_VALIDATION_FEATURE, |
|
608 |
SCHEMA_FULL_CHECKING, |
|
609 |
DYNAMIC_VALIDATION_FEATURE, |
|
610 |
WARN_ON_DUPLICATE_ATTDEF_FEATURE, |
|
611 |
WARN_ON_UNDECLARED_ELEMDEF_FEATURE, |
|
612 |
ALLOW_JAVA_ENCODINGS_FEATURE, |
|
613 |
CONTINUE_AFTER_FATAL_ERROR_FEATURE, |
|
614 |
LOAD_DTD_GRAMMAR_FEATURE, |
|
615 |
LOAD_EXTERNAL_DTD_FEATURE, |
|
616 |
//DEFER_NODE_EXPANSION_FEATURE, |
|
617 |
CREATE_ENTITY_REF_NODES_FEATURE, |
|
618 |
XINCLUDE_AWARE, |
|
619 |
INCLUDE_IGNORABLE_WHITESPACE, |
|
620 |
//GRAMMAR_ACCESS_FEATURE, |
|
621 |
DEFAULT_ATTRIBUTE_VALUES_FEATURE, |
|
622 |
VALIDATE_CONTENT_MODELS_FEATURE, |
|
623 |
VALIDATE_DATATYPES_FEATURE, |
|
624 |
BALANCE_SYNTAX_TREES, |
|
625 |
NOTIFY_CHAR_REFS_FEATURE, |
|
626 |
NOTIFY_BUILTIN_REFS_FEATURE, |
|
627 |
DISALLOW_DOCTYPE_DECL_FEATURE, |
|
628 |
STANDARD_URI_CONFORMANT_FEATURE, |
|
629 |
GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE, |
|
630 |
VALIDATE_ANNOTATIONS_FEATURE, |
|
631 |
HONOUR_ALL_SCHEMALOCATIONS_FEATURE, |
|
632 |
XINCLUDE_FEATURE, |
|
633 |
XINCLUDE_FIXUP_BASE_URIS_FEATURE, |
|
634 |
XINCLUDE_FIXUP_LANGUAGE_FEATURE, |
|
635 |
NAMESPACE_GROWTH_FEATURE, |
|
636 |
TOLERATE_DUPLICATES_FEATURE, |
|
637 |
}; |
|
638 |
||
639 |
/** Xerces properties. */ |
|
640 |
private static final String[] fgXercesProperties = { |
|
641 |
CURRENT_ELEMENT_NODE_PROPERTY, |
|
642 |
DOCUMENT_CLASS_NAME_PROPERTY, |
|
643 |
SYMBOL_TABLE_PROPERTY, |
|
644 |
ERROR_HANDLER_PROPERTY, |
|
645 |
ERROR_REPORTER_PROPERTY, |
|
646 |
ENTITY_MANAGER_PROPERTY, |
|
647 |
ENTITY_RESOLVER_PROPERTY, |
|
648 |
XMLGRAMMAR_POOL_PROPERTY, |
|
649 |
DATATYPE_VALIDATOR_FACTORY_PROPERTY, |
|
650 |
DOCUMENT_SCANNER_PROPERTY, |
|
651 |
DTD_SCANNER_PROPERTY, |
|
652 |
VALIDATOR_PROPERTY, |
|
653 |
SCHEMA_LOCATION, |
|
654 |
SCHEMA_NONS_LOCATION, |
|
655 |
VALIDATION_MANAGER_PROPERTY, |
|
656 |
BUFFER_SIZE_PROPERTY, |
|
657 |
SECURITY_MANAGER_PROPERTY, |
|
658 |
LOCALE_PROPERTY, |
|
659 |
SCHEMA_DV_FACTORY_PROPERTY, |
|
660 |
}; |
|
661 |
||
662 |
/** Empty enumeration. */ |
|
663 |
private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object[] {}); |
|
664 |
||
665 |
// |
|
666 |
// Constructors |
|
667 |
// |
|
668 |
||
669 |
/** This class cannot be instantiated. */ |
|
670 |
private Constants() {} |
|
671 |
||
672 |
// |
|
673 |
// Public methods |
|
674 |
// |
|
675 |
||
676 |
// sax |
|
677 |
||
678 |
/** Returns an enumeration of the SAX features. */ |
|
679 |
public static Enumeration getSAXFeatures() { |
|
680 |
return fgSAXFeatures.length > 0 |
|
681 |
? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration; |
|
682 |
} // getSAXFeatures():Enumeration |
|
683 |
||
684 |
/** Returns an enumeration of the SAX properties. */ |
|
685 |
public static Enumeration getSAXProperties() { |
|
686 |
return fgSAXProperties.length > 0 |
|
687 |
? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration; |
|
688 |
} // getSAXProperties():Enumeration |
|
689 |
||
690 |
// xerces |
|
691 |
||
692 |
/** Returns an enumeration of the Xerces features. */ |
|
693 |
public static Enumeration getXercesFeatures() { |
|
694 |
return fgXercesFeatures.length > 0 |
|
695 |
? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration; |
|
696 |
} // getXercesFeatures():Enumeration |
|
697 |
||
698 |
/** Returns an enumeration of the Xerces properties. */ |
|
699 |
public static Enumeration getXercesProperties() { |
|
700 |
return fgXercesProperties.length > 0 |
|
701 |
? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; |
|
702 |
} // getXercesProperties():Enumeration |
|
703 |
||
18890
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
704 |
/* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
705 |
* Check the version of the current JDK against that specified in the |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
706 |
* parameter |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
707 |
* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
708 |
* There is a proposal to change the java version string to: |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
709 |
* MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
710 |
* This method would work with both the current format and that proposed |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
711 |
* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
712 |
* @param compareTo a JDK version to be compared to |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
713 |
* @return true if the current version is the same or above that represented |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
714 |
* by the parameter |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
715 |
*/ |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
716 |
public static boolean isJavaVersionAtLeast(int compareTo) { |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
717 |
String javaVersion = SecuritySupport.getSystemProperty("java.version"); |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
718 |
String versions[] = javaVersion.split("\\.", 3); |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
719 |
if (Integer.parseInt(versions[0]) >= compareTo || |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
720 |
Integer.parseInt(versions[1]) >= compareTo) { |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
721 |
return true; |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
722 |
} |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
723 |
return false; |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
724 |
} |
17534 | 725 |
|
12005 | 726 |
// |
727 |
// Classes |
|
728 |
// |
|
729 |
||
730 |
/** |
|
731 |
* An array enumeration. |
|
732 |
* |
|
733 |
* @author Andy Clark, IBM |
|
734 |
*/ |
|
735 |
static class ArrayEnumeration |
|
736 |
implements Enumeration { |
|
737 |
||
738 |
// |
|
739 |
// Data |
|
740 |
// |
|
741 |
||
742 |
/** Array. */ |
|
743 |
private Object[] array; |
|
744 |
||
745 |
/** Index. */ |
|
746 |
private int index; |
|
747 |
||
748 |
// |
|
749 |
// Constructors |
|
750 |
// |
|
751 |
||
752 |
/** Constructs an array enumeration. */ |
|
753 |
public ArrayEnumeration(Object[] array) { |
|
754 |
this.array = array; |
|
755 |
} // <init>(Object[]) |
|
756 |
||
757 |
// |
|
758 |
// Enumeration methods |
|
759 |
// |
|
760 |
||
761 |
/** |
|
762 |
* Tests if this enumeration contains more elements. |
|
763 |
* |
|
764 |
* @return <code>true</code> if this enumeration contains more elements; |
|
765 |
* <code>false</code> otherwise. |
|
766 |
* @since JDK1.0 |
|
767 |
*/ |
|
768 |
public boolean hasMoreElements() { |
|
769 |
return index < array.length; |
|
770 |
} // hasMoreElement():boolean |
|
771 |
||
772 |
/** |
|
773 |
* Returns the next element of this enumeration. |
|
774 |
* |
|
775 |
* @return the next element of this enumeration. |
|
776 |
* @exception NoSuchElementException if no more elements exist. |
|
777 |
* @since JDK1.0 |
|
778 |
*/ |
|
779 |
public Object nextElement() { |
|
780 |
if (index < array.length) { |
|
781 |
return array[index++]; |
|
782 |
} |
|
783 |
throw new NoSuchElementException(); |
|
784 |
} // nextElement():Object |
|
785 |
||
786 |
} // class ArrayEnumeration |
|
787 |
||
788 |
// |
|
789 |
// MAIN |
|
790 |
// |
|
791 |
||
792 |
/** Prints all of the constants to standard output. */ |
|
793 |
public static void main(String[] argv) { |
|
794 |
||
795 |
print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures); |
|
796 |
print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties); |
|
797 |
print("Xerces features:", XERCES_FEATURE_PREFIX, fgXercesFeatures); |
|
798 |
print("Xerces properties:", XERCES_PROPERTY_PREFIX, fgXercesProperties); |
|
799 |
||
800 |
} // main(String[]) |
|
801 |
||
802 |
/** Prints a list of features/properties. */ |
|
803 |
private static void print(String header, String prefix, Object[] array) { |
|
804 |
System.out.print(header); |
|
805 |
if (array.length > 0) { |
|
806 |
System.out.println(); |
|
807 |
for (int i = 0; i < array.length; i++) { |
|
808 |
System.out.print(" "); |
|
809 |
System.out.print(prefix); |
|
810 |
System.out.println(array[i]); |
|
811 |
} |
|
812 |
} |
|
813 |
else { |
|
814 |
System.out.println(" none."); |
|
815 |
} |
|
816 |
} // print(String,String,Object[]) |
|
817 |
||
818 |
} // class Constants |