Class PrefixedName

java.lang.Object
com.ctc.wstx.util.PrefixedName
All Implemented Interfaces:
Comparable<PrefixedName>

public final class PrefixedName extends Object implements Comparable<PrefixedName>
Simple key Object to be used for storing/accessing of potentially namespace scoped element and attribute names.

One important note about usage is that two of the name components (prefix and local name) HAVE to have been interned some way, as all comparisons are done using identity comparison; whereas URI is NOT necessarily interned.

Note that the main reason this class is mutable -- unlike most key classes -- is that this allows reusing key objects for access, as long as the code using it knows ramifications of trying to modify a key that's used in a data structure.

Note, too, that the hash code is cached as this class is mostly used as a Map key, and hash code is used a lot.

  • Field Details

    • mPrefix

      private String mPrefix
    • mLocalName

      private String mLocalName
    • mHash

      volatile int mHash
  • Constructor Details

    • PrefixedName

      public PrefixedName(String prefix, String localName)
  • Method Details

    • reset

      public PrefixedName reset(String prefix, String localName)
    • valueOf

      public static PrefixedName valueOf(QName n)
    • getPrefix

      public String getPrefix()
    • getLocalName

      public String getLocalName()
    • isaNsDeclaration

      public boolean isaNsDeclaration()
      Returns:
      True, if this attribute name would result in a namespace binding (ie. it's "xmlns" or starts with "xmlns:").
    • isXmlReservedAttr

      public boolean isXmlReservedAttr(boolean nsAware, String localName)
      Method used to check for xml reserved attribute names, like "xml:space" and "xml:id".

      Note: it is assumed that the passed-in localName is also interned.

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(PrefixedName other)
      Specified by:
      compareTo in interface Comparable<PrefixedName>