Class XMLEventParserContextFactory


  • public class XMLEventParserContextFactory
    extends java.lang.Object
    Provides a global registry of XML parsers. Enables registration of parsers for specific mime types and namespace specialization. Parsers should generally be drawn from this class in order to ensure that parsers configured by World Wind and the application are used.
    • Constructor Detail

      • XMLEventParserContextFactory

        public XMLEventParserContextFactory()
    • Method Detail

      • addParserContext

        public static void addParserContext​(java.lang.String[] mimeTypes,
                                            XMLEventParserContext prototypeContext)
        Appends a specified prototype parser context to the list of those already registered.
        Parameters:
        mimeTypes - the list of mime types for which to use the specified prototype parser context.
        prototypeContext - the prototype parser context to use for the specified mime types. This parser context's class must provide a copy constructor, a constructor that takes an instance of its class as its only argument.
        Throws:
        java.lang.IllegalArgumentException - if the mime type list is null or empty or the prototype context is null or has no copy constructor.
      • prependParserContext

        public static void prependParserContext​(java.lang.String[] mimeTypes,
                                                XMLEventParserContext prototypeContext)
        Prepends a specified prototype parser context to the list of those already registered. Because the new entry is prepended to the list of registered parsers, it will be the first match for the specified mime types.
        Parameters:
        mimeTypes - the list of mime types for which to use the specified prototype parser context.
        prototypeContext - the prototype parser context to use for the specified mime types. This parser context's class must provide a copy constructor, a constructor that takes an instance of its class as its only argument.
        Throws:
        java.lang.IllegalArgumentException - if the mime type list is null or empty or the prototype context is null or has no copy constructor.
      • createParserContext

        public static XMLEventParserContext createParserContext​(java.lang.String mimeType,
                                                                java.lang.String defaultNamespace)
        Constructs and returns a parser context for a specified mime type and namespace. The list of registered parser contexts is searched from first to last. A parser context is constructed from the first entry matching the specified mime type and namespace. Null is returned if no match is found.

        Note that the empty namespace, XMLConstants.NULL_NS_URI does not match any other namespace. In order for a parser context with the empty namespace to be returned, one with the empty namespace must be registered.

        Parameters:
        mimeType - the mime type for which to construct a parser.
        defaultNamespace - a namespace qualifying the parser context to return. May be null, in which case a parser context for the specified mime type and an empty namespace, XMLConstants.NULL_NS_URI, is searched for.
        Returns:
        a new parser context constructed from the prototype context registered for the specified mime type and having the specified default namespace.
        Throws:
        java.lang.IllegalArgumentException - if the specified mime type is null.
      • createInstanceFromPrototype

        protected static XMLEventParserContext createInstanceFromPrototype​(XMLEventParserContext prototype)
                                                                    throws java.lang.Exception
        Constructs a new parser context given a prototype parser context.
        Parameters:
        prototype - the prototype parser context. This parser context's class must provide a copy constructor, a constructor that takes an instance of the class as its only argument.
        Returns:
        the new parser context.
        Throws:
        java.lang.Exception - if an exception occurs while attempting to construct the new context.