Class PrefixedName

  • All Implemented Interfaces:
    java.lang.Comparable<PrefixedName>

    public final class PrefixedName
    extends java.lang.Object
    implements java.lang.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 Detail

      • mPrefix

        private java.lang.String mPrefix
      • mLocalName

        private java.lang.String mLocalName
      • mHash

        volatile int mHash
    • Constructor Detail

      • PrefixedName

        public PrefixedName​(java.lang.String prefix,
                            java.lang.String localName)
    • Method Detail

      • reset

        public PrefixedName reset​(java.lang.String prefix,
                                  java.lang.String localName)
      • valueOf

        public static PrefixedName valueOf​(javax.xml.namespace.QName n)
      • getPrefix

        public java.lang.String getPrefix()
      • getLocalName

        public java.lang.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,
                                         java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public int compareTo​(PrefixedName other)
        Specified by:
        compareTo in interface java.lang.Comparable<PrefixedName>