Class XmlParserElement


  • public class XmlParserElement
    extends java.lang.Object
    A class to represent the start or end tag from an XML file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String[] getAttrNames()
      Returns an array containing the names of all attributes defined in this element.
      java.lang.String getAttrValue​(java.lang.String attrName)
      Returns the value of the specified attribute.
      boolean getAttrValueAsBool​(java.lang.String attrName)
      Returns the boolean value of the specified attribute.
      double getAttrValueAsDouble​(java.lang.String attrName)
      Returns the double value of the specified attribute.
      int getAttrValueAsInt​(java.lang.String attrName)
      Returns the integer value of the specified attribute.
      long getAttrValueAsLong​(java.lang.String attrName)
      Returns the long value of the specified attribute.
      int getLineNum()
      Returns the line number where this element was defined.
      java.lang.String getName()
      Returns the name of this element/tag.
      java.lang.String getText()
      Returns the text of this element.
      boolean hasAttr​(java.lang.String attrName)
      Returns true if this element contains an attribute with the specified name.
      boolean isEnd()
      Returns true if this element represents an end tag.
      boolean isStart()
      Returns true if this element represents a start tag.
      void setAttribute​(java.lang.String name, java.lang.String value)
      Sets the value of the specified attribute.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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

        public boolean isStart()
        Returns true if this element represents a start tag.
        Returns:
        true if this element represents a start tag
      • isEnd

        public boolean isEnd()
        Returns true if this element represents an end tag.
        Returns:
        true if this element represents an end tag
      • getName

        public java.lang.String getName()
        Returns the name of this element/tag.
        Returns:
        the name of this element/tag
      • getLineNum

        public int getLineNum()
        Returns the line number where this element was defined.
        Returns:
        the line number where this element was defined
      • getText

        public java.lang.String getText()
        Returns the text of this element. Or, null if no text existed in the XML.
        Returns:
        the text of this element
      • getAttrValue

        public java.lang.String getAttrValue​(java.lang.String attrName)
        Returns the value of the specified attribute. Or, null if no attribute exists with the specified name.
        Parameters:
        attrName - the name of the attribute
        Returns:
        the value of the specified attribute
      • getAttrValueAsBool

        public boolean getAttrValueAsBool​(java.lang.String attrName)
        Returns the boolean value of the specified attribute.
        Parameters:
        attrName - the name of the attribute
        Returns:
        the boolean value of the specified attribute
        Throws:
        XmlAttributeException - if no attribute exists with the specified name
      • getAttrValueAsInt

        public int getAttrValueAsInt​(java.lang.String attrName)
        Returns the integer value of the specified attribute.
        Parameters:
        attrName - the name of the attribute
        Returns:
        the integer value of the specified attribute
        Throws:
        XmlAttributeException - if no attribute exists with the specified name
      • getAttrValueAsLong

        public long getAttrValueAsLong​(java.lang.String attrName)
        Returns the long value of the specified attribute.
        Parameters:
        attrName - the name of the attribute
        Returns:
        the long value of the specified attribute
        Throws:
        XmlAttributeException - if no attribute exists with the specified name
      • getAttrValueAsDouble

        public double getAttrValueAsDouble​(java.lang.String attrName)
        Returns the double value of the specified attribute.
        Parameters:
        attrName - the name of the attribute
        Returns:
        the double value of the specified attribute
        Throws:
        XmlAttributeException - if no attribute exists with the specified name
      • getAttrNames

        public java.lang.String[] getAttrNames()
        Returns an array containing the names of all attributes defined in this element.
        Returns:
        an array containing the names of all attributes defined in this element
      • hasAttr

        public boolean hasAttr​(java.lang.String attrName)
        Returns true if this element contains an attribute with the specified name.
        Parameters:
        attrName - the name of the attribute
        Returns:
        true if this element contains an attribute with the specified name
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.String value)
        Sets the value of the specified attribute.
        Parameters:
        name - the name of the attribute
        value - the value of the attribute