Class NamespaceContextImpl

    • Constructor Detail

      • NamespaceContextImpl

        public NamespaceContextImpl()
    • Method Detail

      • reset

        public void reset()
        Resets the NamespaceSupport's state. Allows reusing the object.
      • startPrefixMapping

        public void startPrefixMapping​(String pPrefix,
                                       String pURI)
        Declares a new prefix. Typically called from within org.xml.sax.ContextHandler#startPrefixMapping(java.lang.String, java.lang.String).
        Throws:
        IllegalArgumentException - Prefix or URI are null.
      • getAttributePrefix

        public String getAttributePrefix​(String pURI)
        Returns a non-empty prefix currently mapped to the given URL or null, if there is no such mapping. This method may be used to find a possible prefix for an attributes namespace URI. For elements you should use getPrefix(String).
        Parameters:
        pURI - Thhe namespace URI in question
        Throws:
        IllegalArgumentException - The namespace URI is null.
      • isPrefixDeclared

        public boolean isPrefixDeclared​(String pPrefix)
        Returns whether a given prefix is currently declared.
      • checkContext

        public String checkContext​(int i)
        This method is used to restore the namespace state after an element is created. It takes as input a state, as returned by getContext().
        For any prefix, which was since saving the state, the prefix is returned and deleted from the internal list. In other words, a typical use looks like this:
           NamespaceSupport nss;
           ContentHandler h;
           int context = nss.getContext();
           h.startElement("foo", "bar", "f:bar", new AttributesImpl());
           ...
           h.endElement("foo", "bar", "f:bar");
           for (;;) {
             String prefix = nss.checkContext(context);
             if (prefix == null) {
               break;
             }
             h.endPrefixMapping(prefix);
           }
         
      • getPrefixes

        public List getPrefixes()
        Returns a list of all prefixes, which are currently declared, in the order of declaration. Duplicates are possible, if a prefix has been assigned to more than one URI, or repeatedly to the same URI.