Class NamespaceSupport

java.lang.Object
org.htmlunit.cyberneko.xerces.util.NamespaceSupport
All Implemented Interfaces:
NamespaceContext

public class NamespaceSupport extends Object implements NamespaceContext
Namespace support implementation for XML document handlers. This class doesn't perform any error checking and assumes that all strings passed as arguments to methods are unique symbols.
Author:
Andy Clark, IBM, Ronald Brill
  • Constructor Details

    • NamespaceSupport

      public NamespaceSupport()
      Constructs a default NamespaceSupport instance.
  • Method Details

    • reset

      public void reset()
      Resets this Namespace support object for reuse.

      It is necessary to invoke this method before reusing the Namespace support object for a new session.

      Note that implementations of this method need to ensure that the declarations of the prefixes "xmlns" and "xml" remain available.

      Specified by:
      reset in interface NamespaceContext
      See Also:
    • pushContext

      public void pushContext()
      Starts a new Namespace context.

      A new context should be pushed at the beginning of each XML element: the new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.

      Specified by:
      pushContext in interface NamespaceContext
      See Also:
    • popContext

      public void popContext()
      Reverts to the previous Namespace context.

      The context should be popped at the end of each XML element. After popping the context, all Namespace prefix mappings that were previously in force are restored.

      Users must not attempt to declare additional Namespace prefixes after popping a context unless another context is pushed first.

      Specified by:
      popContext in interface NamespaceContext
      See Also:
    • declarePrefix

      public boolean declarePrefix(String prefix, String uri)
      Declares a Namespace prefix.

      This method declares a prefix in the current Namespace context; the prefix will remain in force until this context is popped, unless it is shadowed in a descendant context.

      Note that to declare a default Namespace, use the empty string. The prefixes "xml" and "xmlns" cannot be rebound.

      Specified by:
      declarePrefix in interface NamespaceContext
      Parameters:
      prefix - the prefix to declare, or null or empty string for the default namespace
      uri - the Namespace URI to associate with the prefix
      Returns:
      true if the prefix was legal, false otherwise
      See Also:
    • getURI

      public String getURI(String prefix)
      Looks up a prefix and gets the currently-mapped Namespace URI.

      This method looks up the prefix in the current context. If no mapping is found, this method will continue lookup in the parent context(s). Use the empty string ("") for the default Namespace.

      Specified by:
      getURI in interface NamespaceContext
      Parameters:
      prefix - the prefix to look up
      Returns:
      the associated Namespace URI, or null if the prefix is undeclared
      See Also:
    • getDeclaredPrefixCount

      public int getDeclaredPrefixCount()
      Returns a count of locally declared prefixes, including the default prefix if bound.
      Specified by:
      getDeclaredPrefixCount in interface NamespaceContext
      Returns:
      the count of locally declared prefixes
      See Also:
    • getDeclaredPrefixAt

      public String getDeclaredPrefixAt(int index)
      Returns the prefix at the specified index in the current context.
      Specified by:
      getDeclaredPrefixAt in interface NamespaceContext
      Parameters:
      index - the zero-based index position of the declared prefix
      Returns:
      the prefix at the specified index, or null if out of bounds
      See Also: