com.davisor.data
Class GenericValue

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.VoidValue
          extended bycom.davisor.data.GenericValue
All Implemented Interfaces:
java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.io.Serializable, SerializableData
Direct Known Subclasses:
BooleanData, ObjectValue, PaintData, ShapeData, StrokeData, TextData, TupleData, URLData

public class GenericValue
extends VoidValue

GenericValue implements a generic base class for DataValue classes. In particular, GenericValue provides usefull generic implementations for all DataValue interface methods.

Since:
JDK1.1
See Also:
Type, VoidType, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Constructor Summary
  GenericValue()
          Default constructor.
  GenericValue(GenericValue data, boolean deep)
          Deep or shallow copy constructor.
protected GenericValue(Type type)
          Create a new data object.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this generic value to other values.
 DataValue max(DataValue value)
          Finds the larger of two data values.
 DataValue min(DataValue value)
          Finds the smaller of two data values.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Converts the data to a prepared statement input parameter.
 java.lang.String toXML()
          Gets the XML string representation of this value.
 
Methods inherited from class com.davisor.data.VoidValue
abs, add, ceil, deinterpolate, div, dup, floor, getFormat, interpolate, isNull, mul, negate, setValue, sub, unit
 
Methods inherited from class com.davisor.data.VoidData
equals, getDataValue, getType, hashCode, setType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.DataValue
toString
 
Methods inherited from interface com.davisor.data.Data
getType
 

Constructor Detail

GenericValue

public GenericValue()
Default constructor.


GenericValue

public GenericValue(GenericValue 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()

GenericValue

protected GenericValue(Type type)
Create a new data object.

Parameters:
type - The type of data.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this generic value to other values.

This default implementation compares the string values of this and given object.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class VoidValue
See Also:
max(com.davisor.data.DataValue), min(com.davisor.data.DataValue), Compare.compareTo(Object,Object)

max

public DataValue max(DataValue value)
              throws InvalidDataException
Finds the larger of two data values. This default implementation uses the compareTo method, so it may well suit the purposes of many sub-classes.

If the given value is null or an instance of GenericValue, a reference to this instance is returned.

Specified by:
max in interface DataValue
Overrides:
max in class VoidValue
Parameters:
value - a data value to be compared with this data value
Returns:
Returns the largest of the compared data values.
Throws:
InvalidDataException - if the data value cannot be compared.
See Also:
compareTo(java.lang.Object)

min

public DataValue min(DataValue value)
              throws InvalidDataException
Finds the smaller of two data values. This default implementation uses the compareTo method, so it may well suit the purposes of many sub-classes.

If the given value is null or an instance of GenericValue, a reference to this instance is returned.

Specified by:
min in interface DataValue
Overrides:
min in class VoidValue
Parameters:
value - a data value to be compared with this data value
Returns:
Returns the smallest of the compared data values.
Throws:
InvalidDataException - if the data value cannot be compared.
See Also:
compareTo(java.lang.Object)

toStatement

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

This default impelementation sets statement parameter equal to the string value of this object, if it is not null, and null (java.sql.Types.OTHER) otherwise.

Specified by:
toStatement in interface DataValue
Overrides:
toStatement in class VoidValue
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()

toXML

public java.lang.String toXML()
Gets the XML string representation of this value.

This default implementation takes the object string representation and runs it through XMLUnicodeEncoder.

Specified by:
toXML in interface DataValue
Overrides:
toXML in class VoidValue
See Also:
VoidData.toString(), XMLUnicodeEncoder.encode(java.lang.String, boolean)


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