Class NamespaceContext

java.lang.Object
eu.maveniverse.domtrip.NamespaceContext

public class NamespaceContext extends Object
Represents a namespace context for XML elements, providing namespace URI resolution and prefix management functionality.
  • Constructor Details

    • NamespaceContext

      public NamespaceContext()
      Creates an empty namespace context.
    • NamespaceContext

      public NamespaceContext(Map<String,String> prefixToUri, String defaultNamespaceURI)
      Creates a namespace context with the given prefix-to-URI mappings.
  • Method Details

    • namespaceURI

      public String namespaceURI(String prefix)
      Gets the namespace URI for the given prefix. Returns null if the prefix is not bound to any namespace.
    • prefix

      public String prefix(String namespaceURI)
      Gets the first prefix bound to the given namespace URI. Returns null if no prefix is bound to the URI.
    • prefixes

      public Stream<String> prefixes(String namespaceURI)
      Gets all prefixes bound to the given namespace URI.
    • defaultNamespaceURI

      public String defaultNamespaceURI()
      Gets the default namespace URI.
    • isPrefixDeclared

      public boolean isPrefixDeclared(String prefix)
      Checks if the given prefix is declared in this context.
    • isNamespaceUriDeclared

      public boolean isNamespaceUriDeclared(String namespaceURI)
      Checks if the given namespace URI is declared in this context.
    • declaredPrefixes

      public Set<String> declaredPrefixes()
      Gets all declared prefixes (excluding xml and xmlns).
    • declaredNamespaceURIs

      public Set<String> declaredNamespaceURIs()
      Gets all declared namespace URIs.
    • toString

      public String toString()
      Overrides:
      toString in class Object