Class XmlAttributes


  • public class XmlAttributes
    extends java.lang.Object
    A container class for creating XML attribute strings. For example, given the following code:
     XmlAttributes attrs = new XmlAttributes();
     attrs.add("FIVE", 32, true);
     attrs.add("BAR", "foo");
     attrs.add("PI", 3.14159);
     

    The output would be: FIVE="0x20" BAR="foo" PI="3.14159".
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlAttributes()
      Constructs a new empty XML attributes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAttribute​(java.lang.String name, boolean value)
      Add a new boolean attribute.
      void addAttribute​(java.lang.String name, byte value)
      Add a new byte attribute as decimal.
      void addAttribute​(java.lang.String name, byte value, boolean hex)
      Add a new byte attribute.
      void addAttribute​(java.lang.String name, double value)
      Add a new double attribute.
      void addAttribute​(java.lang.String name, float value)
      Add a new float attribute.
      void addAttribute​(java.lang.String name, int value)
      Add a new int attribute as decimal.
      void addAttribute​(java.lang.String name, int value, boolean hex)
      Add a new int attribute.
      void addAttribute​(java.lang.String name, long value)
      Add a new long attribute as decimal.
      void addAttribute​(java.lang.String name, long value, boolean hex)
      Add a new long attribute.
      void addAttribute​(java.lang.String name, short value)
      Add a new short attribute as decimal.
      void addAttribute​(java.lang.String name, short value, boolean hex)
      Add a new short attribute.
      void addAttribute​(java.lang.String name, java.lang.String value)
      Add a new string attribute.
      void addAttribute​(java.lang.String name, java.math.BigInteger value, boolean hex)
      Add a new big integer attribute.
      boolean isEmpty()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • XmlAttributes

        public XmlAttributes()
        Constructs a new empty XML attributes.
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 java.lang.String value)
        Add a new string attribute.
        Parameters:
        name - the name of the new attribute
        value - the string value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 boolean value)
        Add a new boolean attribute.
        Parameters:
        name - the name of the new attribute
        value - the boolean value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 float value)
        Add a new float attribute.
        Parameters:
        name - the name of the new attribute
        value - the float value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 double value)
        Add a new double attribute.
        Parameters:
        name - the name of the new attribute
        value - the double value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 byte value)
        Add a new byte attribute as decimal.
        Parameters:
        name - the name of the new attribute
        value - the byte value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 byte value,
                                 boolean hex)
        Add a new byte attribute.
        Parameters:
        name - the name of the new attribute
        value - the byte value
        hex - true if value should be written in hex
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 short value)
        Add a new short attribute as decimal.
        Parameters:
        name - the name of the new attribute
        value - the short value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 short value,
                                 boolean hex)
        Add a new short attribute.
        Parameters:
        name - the name of the new attribute
        value - the short value
        hex - true if value should be written in hex
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 int value)
        Add a new int attribute as decimal.
        Parameters:
        name - the name of the new attribute
        value - the int value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 int value,
                                 boolean hex)
        Add a new int attribute.
        Parameters:
        name - the name of the new attribute
        value - the int value
        hex - true if value should be written in hex
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 long value)
        Add a new long attribute as decimal.
        Parameters:
        name - the name of the new attribute
        value - the long value
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 long value,
                                 boolean hex)
        Add a new long attribute.
        Parameters:
        name - the name of the new attribute
        value - the long value
        hex - true if value should be written in hex
      • addAttribute

        public void addAttribute​(java.lang.String name,
                                 java.math.BigInteger value,
                                 boolean hex)
        Add a new big integer attribute.
        Parameters:
        name - the name of the new attribute
        value - the big integer value
      • isEmpty

        public boolean isEmpty()
        Returns:
        the number of attributes in this