com.davisor.data
Class TextData

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.VoidValue
          extended bycom.davisor.data.GenericValue
              extended bycom.davisor.data.TextData
All Implemented Interfaces:
java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.io.Serializable, SerializableData
Direct Known Subclasses:
URLTextData

public class TextData
extends GenericValue

The TextData object represents plain text data.

Since:
JDK1.1
See Also:
TextType, Serialized Form

Field Summary
static TextData EMPTY
          Constant empty ("") text data value.
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Constructor Summary
TextData()
          Creates a new text data object with the default text type and value null.
TextData(java.lang.String value)
          Creates a new text data object with the default text type and given value.
TextData(TextData data, boolean deep)
          Deep or shallow copy constructor.
TextData(TextType type, java.lang.String value)
          Creates a new text data object with the given text type and value.
TextData(TextType type, java.lang.String value, java.text.ParsePosition status)
          Creates a new text data object with the given text type and value.
TextData(Type type)
          Creates a new text data object with the given text type and value null.
 
Method Summary
 DataValue add(DataValue value)
          Adds data values.
 int compareTo(java.lang.Object o)
          Compares this data object with other objects.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
 java.lang.String getValue()
          Gets the text value.
 int hashCode()
          Returns a hash code value for the object.
 boolean isNull()
          Tests if this data object value is undetermined.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets data value from a string value.
 DataValue sub(DataValue value)
          Substracts a data value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Converts the data to a prepared statement input parameter.
 java.lang.String toString()
          Gets the string representation of this text value.
 DataValue unit(DataValue targetValue, double maxSteps)
          Gets the largest suitable unit step to represent a value change between this value and the given target value.
 
Methods inherited from class com.davisor.data.GenericValue
max, min, toXML
 
Methods inherited from class com.davisor.data.VoidValue
abs, ceil, deinterpolate, div, floor, getFormat, interpolate, mul, negate
 
Methods inherited from class com.davisor.data.VoidData
getDataValue, getType, setType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.Data
getType
 

Field Detail

EMPTY

public static final TextData EMPTY
Constant empty ("") text data value.

Constructor Detail

TextData

public TextData()
Creates a new text data object with the default text type and value null.


TextData

public TextData(TextData data,
                boolean deep)
Deep or shallow copy constructor. If it is shallow, then the new object shares an underlying type with the original object. If it is deep, then the type is dupped.

Parameters:
data - source data (may be null)
deep - determines if the copying is deep or shallow
See Also:
VoidData.getType(), Type.dup()

TextData

public TextData(java.lang.String value)
Creates a new text data object with the default text type and given value.


TextData

public TextData(Type type)
Creates a new text data object with the given text type and value null.

Parameters:
type - the type of data

TextData

public TextData(TextType type,
                java.lang.String value)
         throws InvalidDataException
Creates a new text data object with the given text type and value.

Parameters:
type - the type of data
value - string value (may be null)
Throws:
InvalidDataException - if the value was invalid
See Also:
TextData(TextType,String,ParsePosition)

TextData

public TextData(TextType type,
                java.lang.String value,
                java.text.ParsePosition status)
         throws InvalidDataException
Creates a new text data object with the given text type and value.

Parameters:
type - the type of data
value - string value (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if the value was invalid
See Also:
setValue(String,ParsePosition)
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this data object with other objects.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class GenericValue
Parameters:
o - object to compare this object with
Throws:
java.lang.ClassCastException - if the given object is not a TextData object
See Also:
GenericValue.max(com.davisor.data.DataValue), GenericValue.min(com.davisor.data.DataValue), Compare.compareTo(Object,Object)

unit

public DataValue unit(DataValue targetValue,
                      double maxSteps)
               throws InvalidDataException
Gets the largest suitable unit step to represent a value change between this value and the given target value. If the values are equal, a type specific default unit step is returned. If the values are not equal, the given target value must be reached from this value by adding the returned unit step to this value once or more.

Text data does not support the concept of unit values. Calling this method raises a runtime error.

Specified by:
unit in interface DataValue
Overrides:
unit in class VoidValue
Parameters:
targetValue - target value to be reached (may be null)
maxSteps - maximum number of steps (zero leaves the choise open)
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if target value is unsuitable

isNull

public boolean isNull()
Tests if this data object value is undetermined.

Specified by:
isNull in interface SerializableData
Overrides:
isNull in class VoidValue
Returns:
always true

add

public DataValue add(DataValue value)
              throws InvalidDataException
Adds data values.

Specified by:
add in interface DataValue
Overrides:
add in class VoidValue
Parameters:
value - a data value to be added to this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if the data values cannot be added.

setValue

public void setValue(java.lang.String stringValue,
                     java.text.ParsePosition status)
              throws InvalidDataException
Sets data value from a string value.

Specified by:
setValue in interface DataValue
Overrides:
setValue in class VoidValue
Parameters:
stringValue - string value to be parsed (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
TextType.stringValue(String,ParsePosition)

sub

public DataValue sub(DataValue value)
              throws InvalidDataException
Substracts a data value.

Specified by:
sub in interface DataValue
Overrides:
sub in class VoidValue
Parameters:
value - a data value to be substracted from this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if value can not be substracted.

toString

public java.lang.String toString()
Gets the string representation of this text value.

Specified by:
toString in interface DataValue
Overrides:
toString in class VoidData
See Also:
GenericValue.toXML()

toStatement

public void toStatement(java.sql.PreparedStatement statement,
                        int parameter)
                 throws java.sql.SQLException
Converts the data to a prepared statement input parameter.

Specified by:
toStatement in interface DataValue
Overrides:
toStatement in class GenericValue
Parameters:
statement - statement to be updated
parameter - index of the statement parameter to be updated
Throws:
java.sql.SQLException - if a SQL error occurs.
See Also:
VoidData.toString()

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class VoidValue

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal with another object.

Text data objects are equal if their super-classes and values are.

Overrides:
equals in class VoidData
See Also:
Compare.equals(Object,Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class VoidData

getValue

public java.lang.String getValue()
Gets the text value.

Returns:
text value (may be null)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.