001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.impl;
019:
020: import java.util.Enumeration;
021: import java.util.NoSuchElementException;
022:
023: /**
024: * Commonly used constants.
025: *
026: * @xerces.internal
027: *
028: * @author Andy Clark, IBM
029: *
030: * @version $Id: Constants.java 446761 2006-09-15 21:59:29Z mrglavas $
031: */
032: public final class Constants {
033:
034: //
035: // Constants
036: //
037: // Schema Types:
038: public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema"
039: .intern();
040: public static final String NS_DTD = "http://www.w3.org/TR/REC-xml"
041: .intern();
042:
043: // sax features
044:
045: /** SAX feature prefix ("http://xml.org/sax/features/"). */
046: public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
047:
048: /** Namespaces feature ("namespaces"). */
049: public static final String NAMESPACES_FEATURE = "namespaces";
050:
051: /** Namespace prefixes feature ("namespace-prefixes"). */
052: public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
053:
054: /** String interning feature ("string-interning"). */
055: public static final String STRING_INTERNING_FEATURE = "string-interning";
056:
057: /** Validation feature ("validation"). */
058: public static final String VALIDATION_FEATURE = "validation";
059:
060: /** External general entities feature ("external-general-entities "). */
061: public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities";
062:
063: /** External parameter entities feature ("external-parameter-entities "). */
064: public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities";
065:
066: /** Lexical handler parameter entities feature ("lexical-handler/parameter-entities"). */
067: public static final String LEXICAL_HANDLER_PARAMETER_ENTITIES_FEATURE = "lexical-handler/parameter-entities";
068:
069: /** Is standalone feature ("is-standalone"). */
070: public static final String IS_STANDALONE_FEATURE = "is-standalone";
071:
072: /** Resolve DTD URIs feature ("resolve-dtd-uris"). */
073: public static final String RESOLVE_DTD_URIS_FEATURE = "resolve-dtd-uris";
074:
075: /** Use Attributes2 feature ("use-attributes2"). */
076: public static final String USE_ATTRIBUTES2_FEATURE = "use-attributes2";
077:
078: /** Use Locator2 feature ("use-locator2"). */
079: public static final String USE_LOCATOR2_FEATURE = "use-locator2";
080:
081: /** Use EntityResolver2 feature ("use-entity-resolver2"). */
082: public static final String USE_ENTITY_RESOLVER2_FEATURE = "use-entity-resolver2";
083:
084: /** Unicode normalization checking feature ("unicode-normalization-checking"). */
085: public static final String UNICODE_NORMALIZATION_CHECKING_FEATURE = "unicode-normalization-checking";
086:
087: /** xmlns URIs feature ("xmlns-uris"). */
088: public static final String XMLNS_URIS_FEATURE = "xmlns-uris";
089:
090: /** XML 1.1 feature ("xml-1.1"). */
091: public static final String XML_11_FEATURE = "xml-1.1";
092:
093: /** Allow unparsed entity and notation declaration events to be sent after the end DTD event ("allow-dtd-events-after-endDTD") */
094: public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD";
095:
096: // sax properties
097:
098: /** SAX property prefix ("http://xml.org/sax/properties/"). */
099: public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/";
100:
101: /** Declaration handler property ("declaration-handler"). */
102: public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler";
103:
104: /** Lexical handler property ("lexical-handler"). */
105: public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler";
106:
107: /** DOM node property ("dom-node"). */
108: public static final String DOM_NODE_PROPERTY = "dom-node";
109:
110: /** XML string property ("xml-string"). */
111: public static final String XML_STRING_PROPERTY = "xml-string";
112:
113: /** Document XML version property ("document-xml-version"). */
114: public static final String DOCUMENT_XML_VERSION_PROPERTY = "document-xml-version";
115:
116: //
117: // JAXP properties
118: //
119:
120: /** JAXP property prefix ("http://java.sun.com/xml/jaxp/properties/"). */
121: public static final String JAXP_PROPERTY_PREFIX = "http://java.sun.com/xml/jaxp/properties/";
122:
123: /** JAXP schemaSource property: when used internally may include DTD sources (DOM) */
124: public static final String SCHEMA_SOURCE = "schemaSource";
125:
126: /** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */
127: public static final String SCHEMA_LANGUAGE = "schemaLanguage";
128:
129: //
130: // DOM features
131: //
132:
133: /** Comments feature ("include-comments"). */
134: public static final String INCLUDE_COMMENTS_FEATURE = "include-comments";
135:
136: /** Create cdata nodes feature ("create-cdata-nodes"). */
137: public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes";
138:
139: /** Feature id: load as infoset. */
140: public static final String LOAD_AS_INFOSET = "load-as-infoset";
141:
142: //
143: // Constants: DOM Level 3 feature ids
144: //
145:
146: public static final String DOM_CANONICAL_FORM = "canonical-form";
147: public static final String DOM_CDATA_SECTIONS = "cdata-sections";
148: public static final String DOM_COMMENTS = "comments";
149:
150: // REVISIT: this feature seems to have no effect for Xerces
151: public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = "charset-overrides-xml-encoding";
152:
153: public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization";
154: public static final String DOM_ENTITIES = "entities";
155: public static final String DOM_INFOSET = "infoset";
156: public static final String DOM_NAMESPACES = "namespaces";
157: public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations";
158: public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = "supported-media-types-only";
159:
160: public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema";
161: public static final String DOM_VALIDATE = "validate";
162: public static final String DOM_ELEMENT_CONTENT_WHITESPACE = "element-content-whitespace";
163:
164: // DOM Level 3 features defined in Core:
165: public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content";
166: public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters";
167: public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization";
168: public static final String DOM_WELLFORMED = "well-formed";
169: public static final String DOM_SPLIT_CDATA = "split-cdata-sections";
170:
171: // Load and Save
172: public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
173: public static final String DOM_XMLDECL = "xml-declaration";
174: public static final String DOM_UNKNOWNCHARS = "unknown-characters";
175: public static final String DOM_CERTIFIED = "certified";
176: public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype";
177: public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations";
178:
179: // DOM Properties
180: public static final String DOM_RESOURCE_RESOLVER = "resource-resolver";
181: public static final String DOM_ERROR_HANDLER = "error-handler";
182: public static final String DOM_SCHEMA_TYPE = "schema-type";
183: public static final String DOM_SCHEMA_LOCATION = "schema-location";
184:
185: // XSModel
186: public static final String DOM_PSVI = "psvi";
187:
188: // xerces features
189:
190: /** Xerces features prefix ("http://apache.org/xml/features/"). */
191: public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/";
192:
193: /** Schema validation feature ("validation/schema"). */
194: public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema";
195:
196: /** Expose schema normalized values */
197: public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value";
198:
199: /** Send schema default value via characters() */
200: public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default";
201:
202: /** Schema full constraint checking ("validation/schema-full-checking"). */
203: public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking";
204:
205: /** Augment Post-Schema-Validation-Infoset */
206: public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi";
207:
208: /** Dynamic validation feature ("validation/dynamic"). */
209: public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic";
210:
211: /** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */
212: public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef";
213:
214: /** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */
215: public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef";
216:
217: /** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */
218: public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef";
219:
220: /** Allow Java encoding names feature ("allow-java-encodings"). */
221: public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings";
222:
223: /** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */
224: public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl";
225:
226: /** Continue after fatal error feature ("continue-after-fatal-error"). */
227: public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error";
228:
229: /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */
230: public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar";
231:
232: /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */
233: public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";
234:
235: /** Defer node expansion feature ("dom/defer-node-expansion"). */
236: public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion";
237:
238: /** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */
239: public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes";
240:
241: /** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */
242: public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace";
243:
244: /** Default attribute values feature ("validation/default-attribute-values"). */
245: public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values";
246:
247: /** Validate content models feature ("validation/validate-content-models"). */
248: public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models";
249:
250: /** Validate datatypes feature ("validation/validate-datatypes"). */
251: public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes";
252:
253: /** Balance syntax trees feature ("validation/balance-syntax-trees"). */
254: public static final String BALANCE_SYNTAX_TREES = "validation/balance-syntax-trees";
255:
256: /** Notify character references feature (scanner/notify-char-refs"). */
257: public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs";
258:
259: /** Notify built-in (&, etc.) references feature (scanner/notify-builtin-refs"). */
260: public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs";
261:
262: /** Standard URI conformant feature ("standard-uri-conformant"). */
263: public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant";
264:
265: /** Generate synthetic annotations feature ("generate-synthetic-annotations"). */
266: public static final String GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE = "generate-synthetic-annotations";
267:
268: /** Validate annotations feature ("validate-annotations"). */
269: public static final String VALIDATE_ANNOTATIONS_FEATURE = "validate-annotations";
270:
271: /** Honour all schemaLocations feature ("honour-all-schemaLocations"). */
272: public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations";
273:
274: /** XInclude processing feature ("xinclude"). */
275: public static final String XINCLUDE_FEATURE = "xinclude";
276:
277: /** XInclude fixup base URIs feature ("xinclude/fixup-base-uris"). */
278: public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris";
279:
280: /** XInclude fixup language feature ("xinclude/fixup-language"). */
281: public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language";
282:
283: /**
284: * Feature to ignore xsi:type attributes on elements during validation,
285: * until a global element declaration is found. ("validation/schema/ignore-xsi-type-until-elemdecl")
286: * If this feature is on when validating a document, then beginning at the validation root
287: * element, xsi:type attributes are ignored until a global element declaration is
288: * found for an element. Once a global element declaration has been found, xsi:type
289: * attributes will start being processed for the sub-tree beginning at the element for
290: * which the declaration was found.
291: *
292: * Suppose an element A has two element children, B and C.
293: *
294: * If a global element declaration is found for A, xsi:type attributes on A, B and C,
295: * and all of B and C's descendents, will be processed.
296: *
297: * If no global element declaration is found for A or B, but one is found for C,
298: * then xsi:type attributes will be ignored on A and B (and any descendents of B,
299: * until a global element declaration is found), but xsi:type attributes will be
300: * processed for C and all of C's descendents.
301: *
302: * Once xsi:type attributes stop being ignored for a subtree, they do not start
303: * being ignored again, even if more elements are encountered for which no global
304: * element declaration can be found.
305: */
306: public static final String IGNORE_XSI_TYPE_FEATURE = "validation/schema/ignore-xsi-type-until-elemdecl";
307:
308: /** Perform checking of ID/IDREFs ("validation/id-idref-checking") */
309: public static final String ID_IDREF_CHECKING_FEATURE = "validation/id-idref-checking";
310:
311: /** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */
312: public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking";
313:
314: /** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */
315: public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking";
316:
317: /**
318: * Internal feature. When set to true the schema validator will only use
319: * schema components from the grammar pool provided.
320: */
321: public static final String USE_GRAMMAR_POOL_ONLY_FEATURE = "internal/validation/schema/use-grammar-pool-only";
322:
323: /** Internal performance related feature:
324: * false - the parser settings (features/properties) have not changed between 2 parses
325: * true - the parser settings have changed between 2 parses
326: * NOTE: this feature should only be set by the parser configuration.
327: */
328: public static final String PARSER_SETTINGS = "internal/parser-settings";
329:
330: // xerces properties
331:
332: /** Xerces properties prefix ("http://apache.org/xml/properties/"). */
333: public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/";
334:
335: /** Current element node property ("dom/current-element-node"). */
336: public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node";
337:
338: /** Document class name property ("dom/document-class-name"). */
339: public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name";
340:
341: /** Symbol table property ("internal/symbol-table"). */
342: public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table";
343:
344: /** Error reporter property ("internal/error-reporter"). */
345: public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter";
346:
347: /** Error handler property ("internal/error-handler"). */
348: public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
349:
350: /** XInclude handler property ("internal/xinclude-handler"). */
351: public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler";
352:
353: /** XPointer handler property ("internal/xpointer-handler"). */
354: public static final String XPOINTER_HANDLER_PROPERTY = "internal/xpointer-handler";
355:
356: /** Entity manager property ("internal/entity-manager"). */
357: public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
358:
359: /** Input buffer size property ("input-buffer-size"). */
360: public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
361:
362: /** Security manager property ("security-manager"). */
363: public static final String SECURITY_MANAGER_PROPERTY = "security-manager";
364:
365: /** Entity resolver property ("internal/entity-resolver"). */
366: public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver";
367:
368: /** Grammar pool property ("internal/grammar-pool"). */
369: public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool";
370:
371: /** Datatype validator factory ("internal/datatype-validator-factory"). */
372: public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory";
373:
374: /** Document scanner property ("internal/document-scanner"). */
375: public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner";
376:
377: /** DTD scanner property ("internal/dtd-scanner"). */
378: public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner";
379:
380: /** DTD processor property ("internal/dtd-processor"). */
381: public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor";
382:
383: /** Validator property ("internal/validator"). */
384: public static final String VALIDATOR_PROPERTY = "internal/validator";
385:
386: /** Validator property ("internal/validator/dtd"). */
387: public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd";
388:
389: /** Validator property ("internal/validator/schema"). */
390: public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema";
391:
392: /** No namespace schema location property ("schema/external-schemaLocation"). */
393: public static final String SCHEMA_LOCATION = "schema/external-schemaLocation";
394:
395: /** Schema location property ("schema/external-noNamespaceSchemaLocation"). */
396: public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation";
397:
398: /** Namespace binder property ("internal/namespace-binder"). */
399: public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder";
400:
401: /** Namespace context property ("internal/namespace-context"). */
402: public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
403:
404: /** Validation manager property ("internal/validation-manager"). */
405: public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
406:
407: /** Schema type of the root element in a document ("validation/schema/root-type-definition"). */
408: public static final String ROOT_TYPE_DEFINITION_PROPERTY = "validation/schema/root-type-definition";
409:
410: // general constants
411:
412: /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */
413: public final static String ELEMENT_PSVI = "ELEMENT_PSVI";
414:
415: /* Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */
416: public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI";
417:
418: /**
419: * Boolean indicating whether an attribute is declared in the DTD is stored
420: * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this
421: * augmentation indicates that the attribute was not declared in the DTD.
422: */
423: public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED";
424:
425: /**
426: * Boolean indicating whether an entity referenced in the document has
427: * not been read is stored in augmentations using the string "ENTITY_SKIPPED".
428: * The absence of this augmentation indicates that the entity had a
429: * declaration and was expanded.
430: */
431: public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED";
432:
433: /**
434: * Boolean indicating whether a character is a probable white space
435: * character (ch <= 0x20) that was the replacement text of a character
436: * reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS".
437: * The absence of this augmentation indicates that the character is not
438: * probable white space and/or was not included from a character reference.
439: */
440: public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS";
441:
442: // XML version constants
443: public final static short XML_VERSION_ERROR = -1;
444: public final static short XML_VERSION_1_0 = 1;
445: public final static short XML_VERSION_1_1 = 2;
446:
447: // Constant to enable Schema 1.1 support
448: public final static boolean SCHEMA_1_1_SUPPORT = false;
449:
450: // private
451:
452: /** SAX features. */
453: private static final String[] fgSAXFeatures = { NAMESPACES_FEATURE,
454: NAMESPACE_PREFIXES_FEATURE, STRING_INTERNING_FEATURE,
455: VALIDATION_FEATURE, EXTERNAL_GENERAL_ENTITIES_FEATURE,
456: EXTERNAL_PARAMETER_ENTITIES_FEATURE, };
457:
458: /** SAX properties. */
459: private static final String[] fgSAXProperties = {
460: DECLARATION_HANDLER_PROPERTY, LEXICAL_HANDLER_PROPERTY,
461: DOM_NODE_PROPERTY, XML_STRING_PROPERTY, };
462:
463: /** Xerces features. */
464: private static final String[] fgXercesFeatures = {
465: SCHEMA_VALIDATION_FEATURE,
466: SCHEMA_FULL_CHECKING,
467: DYNAMIC_VALIDATION_FEATURE,
468: WARN_ON_DUPLICATE_ATTDEF_FEATURE,
469: WARN_ON_UNDECLARED_ELEMDEF_FEATURE,
470: ALLOW_JAVA_ENCODINGS_FEATURE,
471: CONTINUE_AFTER_FATAL_ERROR_FEATURE,
472: LOAD_DTD_GRAMMAR_FEATURE,
473: LOAD_EXTERNAL_DTD_FEATURE,
474: //DEFER_NODE_EXPANSION_FEATURE,
475: CREATE_ENTITY_REF_NODES_FEATURE,
476: INCLUDE_IGNORABLE_WHITESPACE,
477: //GRAMMAR_ACCESS_FEATURE,
478: DEFAULT_ATTRIBUTE_VALUES_FEATURE,
479: VALIDATE_CONTENT_MODELS_FEATURE,
480: VALIDATE_DATATYPES_FEATURE, BALANCE_SYNTAX_TREES,
481: NOTIFY_CHAR_REFS_FEATURE, NOTIFY_BUILTIN_REFS_FEATURE,
482: DISALLOW_DOCTYPE_DECL_FEATURE,
483: STANDARD_URI_CONFORMANT_FEATURE,
484: GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE,
485: VALIDATE_ANNOTATIONS_FEATURE,
486: HONOUR_ALL_SCHEMALOCATIONS_FEATURE, XINCLUDE_FEATURE,
487: XINCLUDE_FIXUP_BASE_URIS_FEATURE,
488: XINCLUDE_FIXUP_LANGUAGE_FEATURE, IGNORE_XSI_TYPE_FEATURE,
489: ID_IDREF_CHECKING_FEATURE, IDC_CHECKING_FEATURE,
490: UNPARSED_ENTITY_CHECKING_FEATURE, };
491:
492: /** Xerces properties. */
493: private static final String[] fgXercesProperties = {
494: CURRENT_ELEMENT_NODE_PROPERTY,
495: DOCUMENT_CLASS_NAME_PROPERTY, SYMBOL_TABLE_PROPERTY,
496: ERROR_HANDLER_PROPERTY, ERROR_REPORTER_PROPERTY,
497: ENTITY_MANAGER_PROPERTY, ENTITY_RESOLVER_PROPERTY,
498: XMLGRAMMAR_POOL_PROPERTY,
499: DATATYPE_VALIDATOR_FACTORY_PROPERTY,
500: DOCUMENT_SCANNER_PROPERTY, DTD_SCANNER_PROPERTY,
501: VALIDATOR_PROPERTY, SCHEMA_LOCATION, SCHEMA_NONS_LOCATION,
502: VALIDATION_MANAGER_PROPERTY, BUFFER_SIZE_PROPERTY,
503: SECURITY_MANAGER_PROPERTY, ROOT_TYPE_DEFINITION_PROPERTY, };
504:
505: /** Empty enumeration. */
506: private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(
507: new Object[] {});
508:
509: //
510: // Constructors
511: //
512:
513: /** This class cannot be instantiated. */
514: private Constants() {
515: }
516:
517: //
518: // Public methods
519: //
520:
521: // sax
522:
523: /** Returns an enumeration of the SAX features. */
524: public static Enumeration getSAXFeatures() {
525: return fgSAXFeatures.length > 0 ? new ArrayEnumeration(
526: fgSAXFeatures) : fgEmptyEnumeration;
527: } // getSAXFeatures():Enumeration
528:
529: /** Returns an enumeration of the SAX properties. */
530: public static Enumeration getSAXProperties() {
531: return fgSAXProperties.length > 0 ? new ArrayEnumeration(
532: fgSAXProperties) : fgEmptyEnumeration;
533: } // getSAXProperties():Enumeration
534:
535: // xerces
536:
537: /** Returns an enumeration of the Xerces features. */
538: public static Enumeration getXercesFeatures() {
539: return fgXercesFeatures.length > 0 ? new ArrayEnumeration(
540: fgXercesFeatures) : fgEmptyEnumeration;
541: } // getXercesFeatures():Enumeration
542:
543: /** Returns an enumeration of the Xerces properties. */
544: public static Enumeration getXercesProperties() {
545: return fgXercesProperties.length > 0 ? new ArrayEnumeration(
546: fgXercesProperties) : fgEmptyEnumeration;
547: } // getXercesProperties():Enumeration
548:
549: //
550: // Classes
551: //
552:
553: /**
554: * An array enumeration.
555: *
556: * @author Andy Clark, IBM
557: */
558: static class ArrayEnumeration implements Enumeration {
559:
560: //
561: // Data
562: //
563:
564: /** Array. */
565: private Object[] array;
566:
567: /** Index. */
568: private int index;
569:
570: //
571: // Constructors
572: //
573:
574: /** Constructs an array enumeration. */
575: public ArrayEnumeration(Object[] array) {
576: this .array = array;
577: } // <init>(Object[])
578:
579: //
580: // Enumeration methods
581: //
582:
583: /**
584: * Tests if this enumeration contains more elements.
585: *
586: * @return <code>true</code> if this enumeration contains more elements;
587: * <code>false</code> otherwise.
588: * @since JDK1.0
589: */
590: public boolean hasMoreElements() {
591: return index < array.length;
592: } // hasMoreElement():boolean
593:
594: /**
595: * Returns the next element of this enumeration.
596: *
597: * @return the next element of this enumeration.
598: * @exception NoSuchElementException if no more elements exist.
599: * @since JDK1.0
600: */
601: public Object nextElement() {
602: if (index < array.length) {
603: return array[index++];
604: }
605: throw new NoSuchElementException();
606: } // nextElement():Object
607:
608: } // class ArrayEnumeration
609:
610: //
611: // MAIN
612: //
613:
614: /** Prints all of the constants to standard output. */
615: public static void main(String[] argv) {
616:
617: print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures);
618: print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties);
619: print("Xerces features:", XERCES_FEATURE_PREFIX,
620: fgXercesFeatures);
621: print("Xerces properties:", XERCES_PROPERTY_PREFIX,
622: fgXercesProperties);
623:
624: } // main(String[])
625:
626: /** Prints a list of features/properties. */
627: private static void print(String header, String prefix,
628: Object[] array) {
629: System.out.print(header);
630: if (array.length > 0) {
631: System.out.println();
632: for (int i = 0; i < array.length; i++) {
633: System.out.print(" ");
634: System.out.print(prefix);
635: System.out.println(array[i]);
636: }
637: } else {
638: System.out.println(" none.");
639: }
640: } // print(String,String,Object[])
641:
642: } // class Constants
|