001: /*
002: * $Id: Constants.java,v 1.4 2007/04/02 20:38:18 spericas Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * [Name of File] [ver.__] [Date]
025: *
026: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027: */
028:
029: /*
030: * The Apache Software License, Version 1.1
031: *
032: *
033: * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
034: * reserved.
035: *
036: * Redistribution and use in source and binary forms, with or without
037: * modification, are permitted provided that the following conditions
038: * are met:
039: *
040: * 1. Redistributions of source code must retain the above copyright
041: * notice, this list of conditions and the following disclaimer.
042: *
043: * 2. Redistributions in binary form must reproduce the above copyright
044: * notice, this list of conditions and the following disclaimer in
045: * the documentation and/or other materials provided with the
046: * distribution.
047: *
048: * 3. The end-user documentation included with the redistribution,
049: * if any, must include the following acknowledgment:
050: * "This product includes software developed by the
051: * Apache Software Foundation (http://www.apache.org/)."
052: * Alternately, this acknowledgment may appear in the software itself,
053: * if and wherever such third-party acknowledgments normally appear.
054: *
055: * 4. The names "Xerces" and "Apache Software Foundation" must
056: * not be used to endorse or promote products derived from this
057: * software without prior written permission. For written
058: * permission, please contact apache@apache.org.
059: *
060: * 5. Products derived from this software may not be called "Apache",
061: * nor may "Apache" appear in their name, without prior written
062: * permission of the Apache Software Foundation.
063: *
064: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
065: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
066: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
067: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
068: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
069: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
070: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
071: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
072: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
073: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
074: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
075: * SUCH DAMAGE.
076: * ====================================================================
077: *
078: * This software consists of voluntary contributions made by many
079: * individuals on behalf of the Apache Software Foundation and was
080: * originally based on software copyright (c) 1999, International
081: * Business Machines, Inc., http://www.apache.org. For more
082: * information on the Apache Software Foundation, please see
083: * <http://www.apache.org/>.
084: */
085:
086: package com.sun.xml.stream;
087:
088: import java.util.Enumeration;
089: import java.util.NoSuchElementException;
090:
091: /**
092: * Commonly used constants.
093: *
094: * @author Andy Clark, IBM
095: *
096: * @version $Id: Constants.java,v 1.4 2007/04/02 20:38:18 spericas Exp $
097: */
098: public final class Constants {
099:
100: //
101: // Constants
102: //
103: // Schema Types:
104: public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema"
105: .intern();
106: public static final String NS_DTD = "http://www.w3.org/TR/REC-xml"
107: .intern();
108:
109: //stax properties
110: public static final String ESCAPE_CHARACTERS = "escapeCharacters";
111: public static final String STAX_PROPERTIES = "stax-properties";
112: public static final String STAX_ENTITY_RESOLVER_PROPERTY = "internal/stax-entity-resolver";
113: public static final String STAX_REPORT_CDATA_EVENT = "report-cdata-event";
114: public static final String IMPLEMENTATION_NAME = "implementation-name";
115: public static final String ZEPHYR_PROPERTY_PREFIX = "http://java.sun.com/xml/stream/properties/";
116: public static final String REUSE_INSTANCE = "reuse-instance";
117: public static final String OUTPUTSTREAM = "outputstream";
118:
119: /** Property identifier: entity manager. */
120: protected static final String ENTITY_MANAGER = Constants.XERCES_PROPERTY_PREFIX
121: + Constants.ENTITY_MANAGER_PROPERTY;
122:
123: /** Property identifier: Error Reporter. */
124: protected static final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX
125: + Constants.ERROR_REPORTER_PROPERTY;
126:
127: /** Property identifier: Symbol table. */
128: protected static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX
129: + Constants.SYMBOL_TABLE_PROPERTY;
130:
131: // sax features
132:
133: /** SAX feature prefix ("http://xml.org/sax/features/"). */
134: public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
135:
136: /** Namespaces feature ("namespaces"). */
137: public static final String NAMESPACES_FEATURE = "namespaces";
138:
139: /** Namespace prefixes feature ("namespace-prefixes"). */
140: public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
141:
142: /** String interning feature ("string-interning"). */
143: public static final String STRING_INTERNING_FEATURE = "string-interning";
144:
145: /** Validation feature ("validation"). */
146: public static final String VALIDATION_FEATURE = "validation";
147:
148: /** External general entities feature ("external-general-entities "). */
149: public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities";
150:
151: /** External parameter entities feature ("external-parameter-entities "). */
152: public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities";
153:
154: /** Allow unparsed entity and notation declaration events to be sent after the end DTD event ("allow-dtd-events-after-endDTD") */
155: public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD";
156:
157: // sax properties
158:
159: /** SAX property prefix ("http://xml.org/sax/properties/"). */
160: public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/";
161:
162: /** Declaration handler property ("declaration-handler"). */
163: public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler";
164:
165: /** Lexical handler property ("lexical-handler"). */
166: public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler";
167:
168: /** DOM node property ("dom-node"). */
169: public static final String DOM_NODE_PROPERTY = "dom-node";
170:
171: /** XML string property ("xml-string"). */
172: public static final String XML_STRING_PROPERTY = "xml-string";
173:
174: //
175: // JAXP properties
176: //
177:
178: /** JAXP property prefix ("http://java.sun.com/xml/jaxp/properties/"). */
179: public static final String JAXP_PROPERTY_PREFIX = "http://java.sun.com/xml/jaxp/properties/";
180:
181: /** JAXP schemaSource property: when used internally may include DTD sources (DOM) */
182: public static final String SCHEMA_SOURCE = "schemaSource";
183:
184: /** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */
185: public static final String SCHEMA_LANGUAGE = "schemaLanguage";
186:
187: //
188: // DOM features
189: //
190:
191: /** Comments feature ("include-comments"). */
192: public static final String INCLUDE_COMMENTS_FEATURE = "include-comments";
193:
194: /** Create cdata nodes feature ("create-cdata-nodes"). */
195: public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes";
196:
197: /** Feature id: load as infoset. */
198: public static final String LOAD_AS_INFOSET = "load-as-infoset";
199:
200: //
201: // Constants: DOM Level 3 feature ids
202: //
203:
204: public static final String DOM_CANONICAL_FORM = "canonical-form";
205: public static final String DOM_CDATA_SECTIONS = "cdata-sections";
206: public static final String DOM_COMMENTS = "comments";
207:
208: // REVISIT: this feature seems to have no effect for Xerces
209: public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = "charset-overrides-xml-encoding";
210:
211: public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization";
212: public static final String DOM_ENTITIES = "entities";
213: public static final String DOM_INFOSET = "infoset";
214: public static final String DOM_NAMESPACES = "namespaces";
215: public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations";
216: public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = "supported-mediatypes-only";
217:
218: public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema";
219: public static final String DOM_VALIDATE = "validate";
220: public static final String DOM_WHITESPACE_IN_ELEMENT_CONTENT = "whitespace-in-element-content";
221:
222: // DOM Level 3 features defined in Core:
223: public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content";
224: public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters";
225: public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization";
226: public static final String DOM_WELLFORMED = "well-formed";
227: public static final String DOM_SPLIT_CDATA = "split-cdata-sections";
228: public static final String DOM_IGNORE_CHAR_DENORMALIZATION = "ignore-unknown-character-denomalizations";
229:
230: // Load and Save
231: public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
232: public static final String DOM_XMLDECL = "xml-declaration";
233: public static final String DOM_UNKNOWNCHARS = "unknown-characters";
234: public static final String DOM_CERTIFIED = "certified";
235:
236: // DOM Properties
237: public static final String DOM_ENTITY_RESOLVER = "entity-resolver";
238: public static final String DOM_ERROR_HANDLER = "error-handler";
239: public static final String DOM_SCHEMA_TYPE = "schema-type";
240: public static final String DOM_SCHEMA_LOCATION = "schema-location";
241:
242: // XSModel
243: public static final String DOM_PSVI = "psvi";
244:
245: // xerces features
246:
247: /** Xerces features prefix ("http://apache.org/xml/features/"). */
248: public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/";
249:
250: /** Schema validation feature ("validation/schema"). */
251: public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema";
252:
253: /** Expose schema normalized values */
254: public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value";
255:
256: /** Send schema default value via characters() */
257: public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default";
258:
259: /** Schema full constraint checking ("validation/schema-full-checking"). */
260: public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking";
261:
262: /** Augment Post-Schema-Validation-Infoset */
263: public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi";
264:
265: /** Dynamic validation feature ("validation/dynamic"). */
266: public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic";
267:
268: /** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */
269: public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef";
270:
271: /** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */
272: public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef";
273:
274: /** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */
275: public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef";
276:
277: /** Allow Java encoding names feature ("allow-java-encodings"). */
278: public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings";
279:
280: /** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */
281: public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl";
282:
283: /** Continue after fatal error feature ("continue-after-fatal-error"). */
284: public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error";
285:
286: /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */
287: public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar";
288:
289: /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */
290: public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";
291:
292: /** Defer node expansion feature ("dom/defer-node-expansion"). */
293: public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion";
294:
295: /** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */
296: public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes";
297:
298: /** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */
299: public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace";
300:
301: /** Default attribute values feature ("validation/default-attribute-values"). */
302: public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values";
303:
304: /** Validate content models feature ("validation/validate-content-models"). */
305: public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models";
306:
307: /** Validate datatypes feature ("validation/validate-datatypes"). */
308: public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes";
309:
310: /** Notify character references feature (scanner/notify-char-refs"). */
311: public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs";
312:
313: /** Notify built-in (&amp;, etc.) references feature (scanner/notify-builtin-refs"). */
314: public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs";
315:
316: /** Standard URI conformant feature ("standard-uri-conformant"). */
317: public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant";
318:
319: // xerces properties
320:
321: /** Xerces properties prefix ("http://apache.org/xml/properties/"). */
322: public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/";
323:
324: /** Current element node property ("dom/current-element-node"). */
325: public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node";
326:
327: /** Document class name property ("dom/document-class-name"). */
328: public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name";
329:
330: /** Symbol table property ("internal/symbol-table"). */
331: public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table";
332:
333: /** Error reporter property ("internal/error-reporter"). */
334: public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter";
335:
336: /** Error handler property ("internal/error-handler"). */
337: public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
338:
339: /** XInclude handler property ("internal/xinclude-handler"). */
340: public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler";
341:
342: /** Entity manager property ("internal/entity-manager"). */
343: public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
344:
345: /** Input buffer size property ("input-buffer-size"). */
346: public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
347:
348: /** Security manager property ("security-manager"). */
349: public static final String SECURITY_MANAGER_PROPERTY = "security-manager";
350:
351: /** Entity resolver property ("internal/entity-resolver"). */
352: public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver";
353:
354: /** Grammar pool property ("internal/grammar-pool"). */
355: public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool";
356:
357: /** Datatype validator factory ("internal/datatype-validator-factory"). */
358: public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory";
359:
360: /** Document scanner property ("internal/document-scanner"). */
361: public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner";
362:
363: /** DTD scanner property ("internal/dtd-scanner"). */
364: public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner";
365:
366: /** DTD processor property ("internal/dtd-processor"). */
367: public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor";
368:
369: /** Validator property ("internal/validator"). */
370: public static final String VALIDATOR_PROPERTY = "internal/validator";
371:
372: /** Validator property ("internal/validator/dtd"). */
373: public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd";
374:
375: /** Validator property ("internal/validator/schema"). */
376: public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema";
377:
378: /** No namespace schema location property ("schema/external-schemaLocation"). */
379: public static final String SCHEMA_LOCATION = "schema/external-schemaLocation";
380:
381: /** Schema location property ("schema/external-noNamespaceSchemaLocation"). */
382: public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation";
383:
384: /** Namespace binder property ("internal/namespace-binder"). */
385: public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder";
386:
387: /** Namespace context property ("internal/namespace-context"). */
388: public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
389:
390: /** Validation manager property ("internal/validation-manager"). */
391: public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
392:
393: // general constants
394:
395: /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */
396: public final static String ELEMENT_PSVI = "ELEMENT_PSVI";
397:
398: /* Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */
399: public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI";
400:
401: // XML version constants
402: public final static short XML_VERSION_1_0 = 1;
403: public final static short XML_VERSION_1_1 = 2;
404:
405: // private
406:
407: /** SAX features. */
408: private static final String[] fgSAXFeatures = { NAMESPACES_FEATURE,
409: NAMESPACE_PREFIXES_FEATURE, STRING_INTERNING_FEATURE,
410: VALIDATION_FEATURE, EXTERNAL_GENERAL_ENTITIES_FEATURE,
411: EXTERNAL_PARAMETER_ENTITIES_FEATURE, };
412:
413: /** SAX properties. */
414: private static final String[] fgSAXProperties = {
415: DECLARATION_HANDLER_PROPERTY, LEXICAL_HANDLER_PROPERTY,
416: DOM_NODE_PROPERTY, XML_STRING_PROPERTY, };
417:
418: /** Xerces features. */
419: private static final String[] fgXercesFeatures = {
420: SCHEMA_VALIDATION_FEATURE,
421: SCHEMA_FULL_CHECKING,
422: DYNAMIC_VALIDATION_FEATURE,
423: WARN_ON_DUPLICATE_ATTDEF_FEATURE,
424: WARN_ON_UNDECLARED_ELEMDEF_FEATURE,
425: ALLOW_JAVA_ENCODINGS_FEATURE,
426: CONTINUE_AFTER_FATAL_ERROR_FEATURE,
427: LOAD_DTD_GRAMMAR_FEATURE,
428: LOAD_EXTERNAL_DTD_FEATURE,
429: //DEFER_NODE_EXPANSION_FEATURE,
430: CREATE_ENTITY_REF_NODES_FEATURE,
431: INCLUDE_IGNORABLE_WHITESPACE,
432: //GRAMMAR_ACCESS_FEATURE,
433: DEFAULT_ATTRIBUTE_VALUES_FEATURE,
434: VALIDATE_CONTENT_MODELS_FEATURE,
435: VALIDATE_DATATYPES_FEATURE, NOTIFY_CHAR_REFS_FEATURE };
436:
437: /** Xerces properties. */
438: private static final String[] fgXercesProperties = {
439: CURRENT_ELEMENT_NODE_PROPERTY,
440: DOCUMENT_CLASS_NAME_PROPERTY, SYMBOL_TABLE_PROPERTY,
441: ERROR_HANDLER_PROPERTY, ERROR_REPORTER_PROPERTY,
442: ENTITY_MANAGER_PROPERTY, ENTITY_RESOLVER_PROPERTY,
443: XMLGRAMMAR_POOL_PROPERTY,
444: DATATYPE_VALIDATOR_FACTORY_PROPERTY,
445: DOCUMENT_SCANNER_PROPERTY, DTD_SCANNER_PROPERTY,
446: VALIDATOR_PROPERTY, SCHEMA_LOCATION, SCHEMA_NONS_LOCATION,
447: VALIDATION_MANAGER_PROPERTY };
448:
449: private static final String[] zephyrFeatures = {
450: XERCES_FEATURE_PREFIX + NAMESPACES_FEATURE,
451: XERCES_FEATURE_PREFIX + WARN_ON_DUPLICATE_ATTDEF_FEATURE,
452: XERCES_FEATURE_PREFIX + WARN_ON_UNDECLARED_ELEMDEF_FEATURE,
453: XERCES_FEATURE_PREFIX + ALLOW_JAVA_ENCODINGS_FEATURE,
454:
455: };
456:
457: private static final String[] zephyrProperties = {
458: XERCES_PROPERTY_PREFIX + SYMBOL_TABLE_PROPERTY,
459: XERCES_PROPERTY_PREFIX + ERROR_REPORTER_PROPERTY,
460: XERCES_PROPERTY_PREFIX + ERROR_HANDLER_PROPERTY,
461: XERCES_PROPERTY_PREFIX + ENTITY_RESOLVER_PROPERTY,
462: XERCES_PROPERTY_PREFIX + DTD_SCANNER_PROPERTY };
463:
464: /** Empty enumeration. */
465: private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(
466: new Object[] {});
467:
468: //
469: // Constructors
470: //
471:
472: /** This class cannot be instantiated. */
473: private Constants() {
474: }
475:
476: //
477: // Public methods
478: //
479:
480: //ZEPHYR
481:
482: public static Enumeration getZephyrFeatures() {
483: return new ArrayEnumeration(zephyrFeatures);
484: }
485:
486: public static Enumeration getZephyrProperties() {
487: return new ArrayEnumeration(zephyrProperties);
488: }
489:
490: // sax
491:
492: /** Returns an enumeration of the SAX features. */
493: public static Enumeration getSAXFeatures() {
494: return fgSAXFeatures.length > 0 ? new ArrayEnumeration(
495: fgSAXFeatures) : fgEmptyEnumeration;
496: } // getSAXFeatures():Enumeration
497:
498: /** Returns an enumeration of the SAX properties. */
499: public static Enumeration getSAXProperties() {
500: return fgSAXProperties.length > 0 ? new ArrayEnumeration(
501: fgSAXProperties) : fgEmptyEnumeration;
502: } // getSAXProperties():Enumeration
503:
504: // xerces
505:
506: /** Returns an enumeration of the Xerces features. */
507: public static Enumeration getXercesFeatures() {
508: return fgXercesFeatures.length > 0 ? new ArrayEnumeration(
509: fgXercesFeatures) : fgEmptyEnumeration;
510: } // getXercesFeatures():Enumeration
511:
512: /** Returns an enumeration of the Xerces properties. */
513: public static Enumeration getXercesProperties() {
514: return fgXercesProperties.length > 0 ? new ArrayEnumeration(
515: fgXercesProperties) : fgEmptyEnumeration;
516: } // getXercesProperties():Enumeration
517:
518: //
519: // Classes
520: //
521:
522: /**
523: * An array enumeration.
524: *
525: * @author Andy Clark, IBM
526: */
527: static class ArrayEnumeration implements Enumeration {
528:
529: //
530: // Data
531: //
532:
533: /** Array. */
534: private Object[] array;
535:
536: /** Index. */
537: private int index;
538:
539: //
540: // Constructors
541: //
542:
543: /** Constructs an array enumeration. */
544: public ArrayEnumeration(Object[] array) {
545: this .array = array;
546: } // <init>(Object[])
547:
548: //
549: // Enumeration methods
550: //
551:
552: /**
553: * Tests if this enumeration contains more elements.
554: *
555: * @return <code>true</code> if this enumeration contains more elements;
556: * <code>false</code> otherwise.
557: * @since JDK1.0
558: */
559: public boolean hasMoreElements() {
560: return index < array.length;
561: } // hasMoreElement():boolean
562:
563: /**
564: * Returns the next element of this enumeration.
565: *
566: * @return the next element of this enumeration.
567: * @exception NoSuchElementException if no more elements exist.
568: * @since JDK1.0
569: */
570: public Object nextElement() {
571: if (index < array.length) {
572: return array[index++];
573: }
574: throw new NoSuchElementException();
575: } // nextElement():Object
576:
577: } // class ArrayEnumeration
578:
579: //
580: // MAIN
581: //
582:
583: /** Prints all of the constants to standard output. */
584: public static void main(String[] argv) {
585:
586: print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures);
587: print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties);
588: print("Xerces features:", XERCES_FEATURE_PREFIX,
589: fgXercesFeatures);
590: print("Xerces properties:", XERCES_PROPERTY_PREFIX,
591: fgXercesProperties);
592:
593: } // main(String[])
594:
595: /** Prints a list of features/properties. */
596: private static void print(String header, String prefix,
597: Object[] array) {
598: System.out.print(header);
599: if (array.length > 0) {
600: System.out.println();
601: for (int i = 0; i < array.length; i++) {
602: System.out.print(" ");
603: System.out.print(prefix);
604: System.out.println(array[i]);
605: }
606: } else {
607: System.out.println(" none.");
608: }
609: } // print(String,String,Object[])
610:
611: } // class Constants
|