Class AttributesImpl

  • All Implemented Interfaces:
    org.xml.sax.Attributes

    public final class AttributesImpl
    extends java.lang.Object
    implements org.xml.sax.Attributes
    An **** partial **** implementation of the SAX-interface Attributes which allows attributes without values using NO_VALUE.
    Version:
    1.0
    Author:
    Ernst Reissner
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ListMap<java.lang.String,​java.lang.String> name2value
      Maps the name of an attribute to its value.
      static java.lang.String NO_VALUE
      Used as a value in name2value to signify that the corresponding attribute has no value.
    • Constructor Summary

      Constructors 
      Constructor Description
      AttributesImpl​(ListMap<java.lang.String,​java.lang.String> name2value)
      Creates a new empty AttributesImpl which represents the given attribute list.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIndex​(java.lang.String qName)  
      int getIndex​(java.lang.String uri, java.lang.String localPart)  
      int getLength()  
      java.lang.String getLocalName​(int index)  
      java.lang.String getQName​(int index)  
      java.lang.String getType​(int index)  
      java.lang.String getType​(java.lang.String qName)  
      java.lang.String getType​(java.lang.String uri, java.lang.String localName)  
      java.lang.String getURI​(int index)  
      java.lang.String getValue​(int index)  
      java.lang.String getValue​(java.lang.String qName)  
      java.lang.String getValue​(java.lang.String uri, java.lang.String localName)  
      private static java.lang.String noValueToNull​(java.lang.Object valueOrNot)
      Converts NO_VALUE to null simply casting other arguments to type String.
      AttributesImpl toLowerCase()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NO_VALUE

        public static final java.lang.String NO_VALUE
        Used as a value in name2value to signify that the corresponding attribute has no value. This is much better than simply unsing null. The latter would not allow to rule out a multiple attribute without a value.
      • name2value

        private final ListMap<java.lang.String,​java.lang.String> name2value
        Maps the name of an attribute to its value. The name must be a string. If there is a value (which is mandatory in xml) the value is also a string value. Otherwise it is NO_VALUE.
    • Constructor Detail

      • AttributesImpl

        AttributesImpl​(ListMap<java.lang.String,​java.lang.String> name2value)
        Creates a new empty AttributesImpl which represents the given attribute list.
        Parameters:
        name2value - a ListMap representing an attribute list, as specified for name2value.
    • Method Detail

      • noValueToNull

        private static java.lang.String noValueToNull​(java.lang.Object valueOrNot)
        Converts NO_VALUE to null simply casting other arguments to type String.
        Parameters:
        valueOrNot - a String or the object NO_VALUE.
        Returns:
        a String which is
        • null for valueOrNot == NO_VALUE.
        • valueOrNot itself casted to a string otherwise.
      • getLength

        public int getLength()
        Specified by:
        getLength in interface org.xml.sax.Attributes
      • getURI

        public java.lang.String getURI​(int index)
        Specified by:
        getURI in interface org.xml.sax.Attributes
      • getLocalName

        public java.lang.String getLocalName​(int index)
        Specified by:
        getLocalName in interface org.xml.sax.Attributes
      • getQName

        public java.lang.String getQName​(int index)
        Specified by:
        getQName in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(int index)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(int index)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • getIndex

        public int getIndex​(java.lang.String uri,
                            java.lang.String localPart)
        Specified by:
        getIndex in interface org.xml.sax.Attributes
      • getIndex

        public int getIndex​(java.lang.String qName)
        Specified by:
        getIndex in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(java.lang.String uri,
                                        java.lang.String localName)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(java.lang.String qName)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(java.lang.String uri,
                                         java.lang.String localName)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(java.lang.String qName)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object