Class SMGlobalNamespace

java.lang.Object
org.codehaus.staxmate.out.SMNamespace
org.codehaus.staxmate.out.SMGlobalNamespace

public final class SMGlobalNamespace extends SMNamespace
Namespace that is global and shared for all SMOutputContext)s (~= XML documents or sub-trees). This includes the pre-defined namespaces (ones with "xml" and "xmlns" prefixes as well as the default "empty"/missing namespace, one bound to "" if no explicit declaration is made).
  • Field Details

    • _prefix

      protected final String _prefix
      Prefix this namespace is (permanently) bound to.
  • Constructor Details

    • SMGlobalNamespace

      protected SMGlobalNamespace(String uri, String prefix)
  • Method Details

    • getPreferredPrefix

      public String getPreferredPrefix()
      Specified by:
      getPreferredPrefix in class SMNamespace
      Returns:
      Prefix that the caller application has at some point indicated to be a prefix it'd like to see; StaxMate may try to use it as the prefix to bind if there are no
    • getBoundPrefix

      public String getBoundPrefix()
      Specified by:
      getBoundPrefix in class SMNamespace
    • getLastBoundPrefix

      public String getLastBoundPrefix()
      Specified by:
      getLastBoundPrefix in class SMNamespace
    • prefersDefaultNs

      public boolean prefersDefaultNs()
      Specified by:
      prefersDefaultNs in class SMNamespace
    • prefersDefaultNs

      public void prefersDefaultNs(boolean state)
      Specified by:
      prefersDefaultNs in class SMNamespace
    • setPreferredPrefix

      public void setPreferredPrefix(String prefPrefix)
      Description copied from class: SMNamespace
      Method that can be called to associate a "preferred" prefix; prefix that this namespace should be bound to instead of some automatically generated one (unless that prefix is already bound to another URI).
      Specified by:
      setPreferredPrefix in class SMNamespace
    • isValidIn

      protected boolean isValidIn(SMOutputContext ctxt)
      Description copied from class: SMNamespace
      Method used to verify that the namespace is actually valid within the specified output context.
      Specified by:
      isValidIn in class SMNamespace
    • _bindAs

      protected void _bindAs(String prefix)
      Global namespaces should never be bound/unbound, so if this gets called, an exception will be thrown (but note that this being an 'internal' method, this is more like an assertion).
      Specified by:
      _bindAs in class SMNamespace
    • _bindPermanentlyAs

      protected void _bindPermanentlyAs(String prefix)
      Description copied from class: SMNamespace
      Method used to permanently bind this (local) namespace to a prefix. Generally called if a new "global" binding is found at point where a global instance can not be created. Calling this method will essentially mark a local instace as behaving similar to a global one.
      Specified by:
      _bindPermanentlyAs in class SMNamespace
    • _unbind

      protected void _unbind()
      Description copied from class: SMNamespace
      Method called to indicate that the namespace is no longer bound to its current prefix within the current output context. Since default namespace declarations do not cause binding, this method will not be called for default namespaces either.
      Specified by:
      _unbind in class SMNamespace