Class SimpleValue

    • Constructor Detail

      • SimpleValue

        public SimpleValue()
        Construct an empty SimpleValue. Also used by the ExternalizableLite implementation.
      • SimpleValue

        public SimpleValue​(Object oValue)
        Construct a SimpleValue. This form constructs an element's content value from the passed Object value. If the Object is a String, then the String should be un-escaped by this point; it must not still be in the form of the CDATA construct.
        Parameters:
        oValue - the initial value for this SimpleValue
        Throws:
        IllegalArgumentException - if the String value is illegal
      • SimpleValue

        public SimpleValue​(Object oValue,
                           boolean fAttribute)
        Construct a SimpleValue. This form constructs an element's content or attribute value from the passed String value. The String should be un-escaped by this point; it must not still be in the form of the CDATA construct.
        Parameters:
        oValue - the initial value for this SimpleValue
        fAttribute - true if this SimpleValue is an element attribute value; false if an element's content's value
        Throws:
        IllegalArgumentException - if the String value is illegal
      • SimpleValue

        public SimpleValue​(Object oValue,
                           boolean fAttribute,
                           boolean fReadOnly)
        Construct a SimpleValue. This form constructs an element's content or attribute value from the passed String value, and also allows the caller to specify that the value is immutable. The String should be un-escaped by this point; it must not still be in the form of the CDATA construct.
        Parameters:
        oValue - the initial value for this SimpleValue
        fAttribute - true if this SimpleValue is an element attribute value; false if an element's content's value
        fReadOnly - true if this SimpleValue is intended to be read- only once the constructor has finished
        Throws:
        IllegalArgumentException - if the String value is illegal
    • Method Detail

      • getBoolean

        public boolean getBoolean()
        Get the value as a boolean.
        Specified by:
        getBoolean in interface XmlValue
        Returns:
        the value as a boolean
      • getBoolean

        public boolean getBoolean​(boolean fDefault)
        Get the value as a boolean.
        Specified by:
        getBoolean in interface XmlValue
        Parameters:
        fDefault - the default return value if the internal value can not be translated into a legal value of type boolean
        Returns:
        the value as a boolean
      • setBoolean

        public void setBoolean​(boolean fVal)
        Set the boolean value.
        Specified by:
        setBoolean in interface XmlValue
        Parameters:
        fVal - a new value of type boolean
      • getInt

        public int getInt()
        Get the value as an int.
        Specified by:
        getInt in interface XmlValue
        Returns:
        the value as an int
      • getInt

        public int getInt​(int nDefault)
        Get the value as an int.
        Specified by:
        getInt in interface XmlValue
        Parameters:
        nDefault - the default return value if the internal value can not be translated into a legal value of type int
        Returns:
        the value as an int
      • setInt

        public void setInt​(int nVal)
        Set the int value.
        Specified by:
        setInt in interface XmlValue
        Parameters:
        nVal - a new value of type int
      • getLong

        public long getLong()
        Get the value as a long.
        Specified by:
        getLong in interface XmlValue
        Returns:
        the value as a long
      • getLong

        public long getLong​(long lDefault)
        Get the value as a long.
        Specified by:
        getLong in interface XmlValue
        Parameters:
        lDefault - the default return value if the internal value can not be translated into a legal value of type long
        Returns:
        the value as a long
      • setLong

        public void setLong​(long lVal)
        Set the long value.
        Specified by:
        setLong in interface XmlValue
        Parameters:
        lVal - a new value of type long
      • getDouble

        public double getDouble()
        Get the value as a double.
        Specified by:
        getDouble in interface XmlValue
        Returns:
        the value as a double
      • getDouble

        public double getDouble​(double dflDefault)
        Get the value as a double.
        Specified by:
        getDouble in interface XmlValue
        Parameters:
        dflDefault - the default return value if the internal value can not be translated into a legal value of type double
        Returns:
        the value as a double
      • setDouble

        public void setDouble​(double dflVal)
        Set the double value.
        Specified by:
        setDouble in interface XmlValue
        Parameters:
        dflVal - a new value of type double
      • getDecimal

        public BigDecimal getDecimal()
        Get the value as a decimal.
        Specified by:
        getDecimal in interface XmlValue
        Returns:
        the value as a BigDecimal
      • getDecimal

        public BigDecimal getDecimal​(BigDecimal decDefault)
        Get the value as a decimal.
        Specified by:
        getDecimal in interface XmlValue
        Parameters:
        decDefault - the default return value if the internal value can not be translated into a legal value of type decimal
        Returns:
        the value as a decimal
      • setDecimal

        public void setDecimal​(BigDecimal decVal)
        Set the dcimal value.
        Specified by:
        setDecimal in interface XmlValue
        Parameters:
        decVal - a new value of type BigDecimal
      • getString

        public String getString()
        Get the value as a String.
        Specified by:
        getString in interface XmlValue
        Returns:
        the value as a String
      • getString

        public String getString​(String sDefault)
        Get the value as a String.
        Specified by:
        getString in interface XmlValue
        Parameters:
        sDefault - the default return value if the internal value can not be translated into a legal value of type String
        Returns:
        the value as a String
      • getBinary

        public Binary getBinary()
        Get the value as binary. The XML format is expected to be Base64.
        Specified by:
        getBinary in interface XmlValue
        Returns:
        the value as a Binary
      • getBinary

        public Binary getBinary​(Binary binDefault)
        Get the value as binary. The XML format is expected to be Base64.
        Specified by:
        getBinary in interface XmlValue
        Parameters:
        binDefault - the default return value if the internal value can not be translated into a legal value of type Binary
        Returns:
        the value as a Binary
      • setBinary

        public void setBinary​(Binary binVal)
        Set the binary value.
        Specified by:
        setBinary in interface XmlValue
        Parameters:
        binVal - a new value of type Binary
        Throws:
        IllegalArgumentException - if the binary value is null
      • getDate

        public Date getDate()
        Get the value as a Date.
        Specified by:
        getDate in interface XmlValue
        Returns:
        the value as a Date
      • getDate

        public Date getDate​(Date dtDefault)
        Get the value as a Date.
        Specified by:
        getDate in interface XmlValue
        Parameters:
        dtDefault - the default return value if the internal value can not be translated into a legal value of type Date
        Returns:
        the value as a Date
      • setDate

        public void setDate​(Date dtVal)
        Set the Date value.
        Specified by:
        setDate in interface XmlValue
        Parameters:
        dtVal - a new value of type Date
      • getTime

        public Time getTime()
        Get the value as a Time.
        Specified by:
        getTime in interface XmlValue
        Returns:
        the value as a Time
      • getTime

        public Time getTime​(Time dtDefault)
        Get the value as a Time.
        Specified by:
        getTime in interface XmlValue
        Parameters:
        dtDefault - the default return value if the internal value can not be translated into a legal value of type Time
        Returns:
        the value as a Time
      • setTime

        public void setTime​(Time dtVal)
        Set the Time value.
        Specified by:
        setTime in interface XmlValue
        Parameters:
        dtVal - a new value of type Time
      • getDateTime

        public Timestamp getDateTime()
        Get the value as a Timestamp.
        Specified by:
        getDateTime in interface XmlValue
        Returns:
        the value as a Timestamp
      • getDateTime

        public Timestamp getDateTime​(Timestamp dtDefault)
        Get the value as a Timestamp.
        Specified by:
        getDateTime in interface XmlValue
        Parameters:
        dtDefault - the default return value if the internal value can not be translated into a legal value of type Timestamp
        Returns:
        the value as a Timestamp
      • setDateTime

        public void setDateTime​(Timestamp dtVal)
        Set the Timestamp value.
        Specified by:
        setDateTime in interface XmlValue
        Parameters:
        dtVal - a new value of type Timestamp
      • getValue

        public Object getValue()
        Get the value as an Object. The following types are supported: Boolean Integer Long Double BigDecimal String Binary Date Time Timestamp It is always legal for an implementation to return the value as a String, for example returning a binary value in a base64 encoding. This method exists to allow one value to copy from another value.
        Specified by:
        getValue in interface XmlValue
        Returns:
        the value as an Object or null if the XmlValue does not have a value; attributes never have a null value
      • getParent

        public XmlElement getParent()
        Get the parent element of this element.
        Specified by:
        getParent in interface XmlValue
        Returns:
        the parent element, or null if this element has no parent
      • isEmpty

        public boolean isEmpty()
        Determine if the value is empty.
        Specified by:
        isEmpty in interface XmlValue
        Returns:
        true if the value is empty
      • isAttribute

        public boolean isAttribute()
        Determine if this value is an element attribute.
        Specified by:
        isAttribute in interface XmlValue
        Returns:
        true if this value is an element attribute, otherwise false
      • isContent

        public boolean isContent()
        Determine if this value is an element's content.
        Specified by:
        isContent in interface XmlValue
        Returns:
        true if this value is an element's content, otherwise false
      • isMutable

        public boolean isMutable()
        Determine if this value can be modified. If the value cannot be modified, all mutating methods are required to throw an UnsupportedOperationException.
        Specified by:
        isMutable in interface XmlValue
        Returns:
        true if this value can be modified, otherwise false to indicate that this value is read-only
      • writeValue

        public void writeValue​(PrintWriter out,
                               boolean fPretty)
        Write the value as it will appear in XML.
        Specified by:
        writeValue in interface XmlValue
        Parameters:
        out - a PrintWriter object to use to write to
        fPretty - true to specify that the output is intended to be as human readable as possible
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Restore the contents of this object by loading the object's state from the passed DataInput object.
        Specified by:
        readExternal in interface ExternalizableLite
        Parameters:
        in - the DataInput stream to read data from in order to restore the state of this object
        Throws:
        IOException - if an I/O exception occurs
        NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Save the contents of this object by storing the object's state into the passed DataOutput object.
        Specified by:
        writeExternal in interface ExternalizableLite
        Parameters:
        out - the DataOutput stream to write the state of this object to
        Throws:
        IOException - if an I/O exception occurs
      • readExternal

        public void readExternal​(PofReader in)
                          throws IOException
        Restore the contents of a user type instance by reading its state using the specified PofReader object.
        Specified by:
        readExternal in interface PortableObject
        Parameters:
        in - the PofReader from which to read the object's state
        Throws:
        IOException - if an I/O error occurs
      • writeExternal

        public void writeExternal​(PofWriter out)
                           throws IOException
        Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
        Specified by:
        writeExternal in interface PortableObject
        Parameters:
        out - the PofWriter to which to write the object's state
        Throws:
        IOException - if an I/O error occurs
      • getInternalValue

        protected Object getInternalValue()
        Get the internal value of this XmlValue. This method acts as a single point to which all accessor calls route. As such, it is intended to be extended by inheriting implementations.
        Returns:
        the current value of this SimpleValue object or null
      • setInternalValue

        protected void setInternalValue​(Object oValue)
        Update the internal representation of the XmlValue. This method acts as a single point to which all mutator calls route. As such, it is intended to be extended by inheriting implementations.
        Parameters:
        oValue - the new value for this SimpleValue object
        Throws:
        UnsupportedOperationException - if this XmlValue is not mutable
      • ensureType

        protected Object ensureType​(int nType)
        Change the type of the internal representation of the XmlValue. A failed conversion will leave the value as null.
        Parameters:
        nType - the enumerated type to convert to
        Returns:
        the current value of this SimpleValue object as the specified type or null
      • convert

        protected Object convert​(Object o,
                                 int nType)
        Convert the passed Object to the specified type.
        Parameters:
        o - the object value
        nType - the enumerated type to convert to
        Returns:
        an object of the specified type
      • setAttribute

        protected void setAttribute​(boolean fAttribute)
        Specify that this value is an element attribute.
        Parameters:
        fAttribute - true if this value is an element attribute, false if this value is an element's content
      • setMutable

        protected void setMutable​(boolean fMutable)
        Specify whether this value can be modified or not.
        Parameters:
        fMutable - pass true to allow this value to be modified, otherwise false to indicate that this value is read-only
      • toString

        public String toString()
        Format the XML value into a String in a display format.
        Specified by:
        toString in interface XmlValue
        Overrides:
        toString in class Object
        Returns:
        a String representation of the XML value
      • hashCode

        public int hashCode()
        Provide a hash value for this XML value. The hash value is defined as one of the following:
        1. 0 if getValue() returns null
        2. otherwise the hash value is the hashCode() of the string representation of the value
        Specified by:
        hashCode in interface XmlValue
        Overrides:
        hashCode in class Object
        Returns:
        the hash value for this XML value
      • equals

        public boolean equals​(Object o)
        Compare this XML value with another XML value for equality.
        Specified by:
        equals in interface XmlValue
        Overrides:
        equals in class Object
        Returns:
        true if the values are equal, false otherwise
      • clone

        public Object clone()
        Creates and returns a copy of this SimpleValue. The returned copy is "unlinked" from the parent and mutable
        Specified by:
        clone in interface XmlValue
        Overrides:
        clone in class Object
        Returns:
        a clone of this instance.