com.davisor.data
Class Type

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
AbstractScale, AutoType, BooleanType, FontType, LocaleType, MetaType, PaintType, ShapeType, StrokeType, TextType, URLType, VoidType

public abstract class Type
extends java.text.Format
implements java.util.Comparator, com.davisor.core.Dupable

Type provides a base class for parametrized data types. Type objects are useful whenever data needs to be accepted and interpreted from strings or other data sources, or written and stored as strings or into other data objects. Typical example cases would be interpreting parameters received over a HTTP -protocol, from different user interface input forms, XML -documents and databases.

Type names

Data types descending from the Type class share a common data -manipulation interface. Different type implementations may also place configurable constraints on data values of those types.

Types define the following names that can be used to group and identify type instances:

Type identity defines an unique key that may be used to place types into maps or other similar structures. A typical example would be channel5. Data name describes the data the data objects of this type contain. A typical example would be temperature. Type name describes the type itself. A typical example would be integer. Type identity and data name may be typically freely assigned, but the type name is defined by the type class, and it can not be changed.

Type meta data

Applications may add additional meta data information to types by assosiating meta data maps to type instances. A meta data map may contain any key/value pairs that somehow describe the type further than is possible with mere type names and identities.

Applications are encouraged to pay special attention to type meta data copying. In particular, only Dupable type meta data is deep copied when types are, while other kind of meta data is only shallow copied. Any mutable but not Dupable meta data may therefore cause unexpected meta data value behaviour.

Type mapping

The Type -class provides a type mapping service that maps type names and SQL types to type objects. Type name mapping is initialized from types.properties resource file, located in the com.davisor.data package. This property file is expected to enumerate a set of initial type classes that should be made available for type name mapping. The names the types are to be bound to are queried from the type object getTypeName() methods (see register(Type)).

SQL type mapping is based on XOPEN type names and java.sql.Types integer codes. The mapping of which SQL type code is mapped to which type is controlled by sqltypes.properties resource file, located again in the com.davisor.data package. The property file is expected to enumerate XOPEN type names, each with a value that tells to what class that type is to be mapped to (see create(Integer,String,String,String)).

Data objects

Type and Data objects are closely related: each Data object refers a Type object that describes the value in the data object. Several data objects may share a common type object that describes the data values as a group. Type objects may also be used to produce data objects that will then remember their creator.

Type constraints and formatting details can be tuned with type specification strings. Encapsulating type parameters into a single string makes polymorphic type configuration mechanisms possible. Exactly what parameters these specification strings support then obviously depends on each type implementation.

All sub-classes are also assumed to provide at least the following public constructors:

Implementing these constructors is not strictly mandatory, but failing to provide them will make some polymorphic type services that rely on a Java reflection unavailable.

To ensure smooth expandability, all Type subclasses should also provide one protected constructor that just accepts values for all class parameter member variables. This constructor should then assign the given parameters to the member variables that it manages, and transparently forward the rest. The constructor should particularly not do any computing or method invocations.

Since:
JDK1.1
See Also:
getDataName(), getID(), getTypeName(), BooleanType, CountType, DateInputType, DateOutputType, DateType, DoubleType, EnumType, FloatType, IntegerRangeType, IntegerType, LocaleType, SQLTextType, TextType, TimestampInputType, TimestampOutputType, TimestampType, TupleType, URLType, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static java.lang.String METADATA_GROUP
          Meta data key for type group.
static java.lang.String METADATA_NAME
          Meta data key for type name.
static java.lang.String METADATA_PARENT
          Meta data key for type parent.
static java.lang.String METADATA_SUBCHANNELS
          Meta data key for type subchannels.
static java.lang.String TYPENAME
          Default type name ("TEXT").
 
Constructor Summary
protected Type(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData)
          Creates a new type.
protected Type(Type type)
          Deep copy constructor.
 
Method Summary
static DataValue ceil(DataValue zero, DataValue step, DataValue value)
          Quantizes a value up so that the range from given zero value to the given value will be an even multiply of given steps.
 java.lang.String check(java.lang.String value)
          Checks and reformats a data string.
 java.lang.String[] check(java.lang.String[] values)
          Checks and reformats data strings.
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two arguments.
static Type create(java.lang.Class typeClass, java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new type instance best suited for data elements represented as instances of of given Java class.
static Type create(java.lang.Integer sqlType, java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new type instance from the given SQL type code.
static Type create(int sqlType, java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new type instance from the given SQL type code.
static Type create(java.lang.Object object)
          Resolves the object type, creating a new one if neccessary.
static Type create(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new type instance from the type family name.
abstract  com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 Type dup(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new type instance from this type.
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
static DataValue floor(DataValue zero, DataValue step, DataValue value)
          Quantizes a value down so that the range from given zero value to the given value will be an even multiply of given steps.
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          Formats an object to produce a string.
 float getCompatibility(java.lang.Class type)
          Gets an estimate of how well this type could represent objects of the given class.
 java.lang.String getDataName()
          Gets type instance data name.
 java.lang.String getFormat()
          Gets the type specification string.
 java.lang.String getId()
          Deprecated. replaced with getID()
 java.lang.String getID()
          Gets type instance identity.
 java.util.Map getMetaData()
          Gets type meta data map.
 java.lang.Object getMetaData(java.lang.Object key)
          Gets type meta data value.
 java.lang.String getSpecs()
          Deprecated. replaced with getFormat()
 int getSQLCode()
          Gets the default java.sqlTypes SQL type code.
 java.lang.String getSQLName()
          Get the SQL type name for default database settings.
 java.lang.String getSQLName(java.lang.String dbtype)
          Get the SQL type name for specific database.
 java.lang.String getTypeName()
          Gets the type name.
abstract  java.lang.Class getValueClass()
          Gets value container class.
 int hashCode()
          Returns a hash code value for the object.
static boolean isNull(SerializableData data)
          Tests if a given data is null, or has a null value.
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition status)
          Parses a string to produce an object.
 void register(java.sql.CallableStatement call, int column)
          Register a callable statement output parameter type.
static void register(Type type)
          Registers a type among known types.
 void setDataName(java.lang.String dataName)
          Sets the type instance data name.
 void setFormat(java.lang.String format)
          Sets the type specification string.
 void setId(java.lang.String id)
          Deprecated. replaced with setID(String)
 void setID(java.lang.String id)
          Sets type identity.
 void setMetaData(java.util.Map metaData)
          Sets type meta data map.
 void setMetaData(java.lang.Object key, java.lang.Object value)
          Sets type meta data map value.
 void setSpecs(java.lang.String specs)
          Deprecated. replaced with setFormat(String)
 DataValue toData(java.sql.CallableStatement statement, int column)
          Converts a callable statement variable to a data value.
 DataValue toData(java.lang.Object objectValue)
          Converts an object to a data value.
 DataValue toData(java.sql.ResultSet resultSet, int column)
          Converts a result set column value to a data value.
abstract  DataValue toData(java.lang.String stringValue, java.text.ParsePosition status)
          Converts a string to a data value.
 java.lang.String toString()
          Gets type string representation.
static java.lang.String toXML(DataValue dataValue)
          Converts a data value to a XML string.
 java.lang.String xmlEnd()
          Creates a XML end element for data elements of this type.
 java.lang.String xmlStart()
          Creates a XML start element for data elements of this type.
abstract  DataValue zero()
          Gets zero data value for this type.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

METADATA_NAME

public static final java.lang.String METADATA_NAME
Meta data key for type name.

See Also:
Constant Field Values

METADATA_GROUP

public static final java.lang.String METADATA_GROUP
Meta data key for type group.

See Also:
Constant Field Values

METADATA_PARENT

public static final java.lang.String METADATA_PARENT
Meta data key for type parent.

See Also:
Constant Field Values

METADATA_SUBCHANNELS

public static final java.lang.String METADATA_SUBCHANNELS
Meta data key for type subchannels.

See Also:
Constant Field Values

TYPENAME

public static final java.lang.String TYPENAME
Default type name ("TEXT").

See Also:
Constant Field Values
Constructor Detail

Type

protected Type(Type type)
Deep copy constructor. In particular, type meta data map, if any, is deep copied as well as possible: a new hash map is created, and all meta data map Dupable keys and values are deep copied into it with Dupable.dup() method. However, all keys and values that are not Dupable are only shallow copied.

Parameters:
type - source type

Type

protected Type(java.lang.String typeName,
               java.lang.String dataName,
               java.lang.String id,
               java.util.Map metaData)
Creates a new type.

Parameters:
typeName - type name
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
Method Detail

getValueClass

public abstract java.lang.Class getValueClass()
Gets value container class.


toData

public abstract DataValue toData(java.lang.String stringValue,
                                 java.text.ParsePosition status)
                          throws InvalidDataException
Converts a string to a data value.

Subclasses are expected to implement this method with string parsers that interprets the given string in the most lenient way possible, and create corresponding new object of this type.

Parameters:
stringValue - data string
status - parse status (may be null)
Returns:
a data value object corresponding given string value
Throws:
InvalidDataException - if given string value could not be parsed
See Also:
toData(CallableStatement,int), toData(Object), toData(ResultSet,int), DataValue.toString()

zero

public abstract DataValue zero()
Gets zero data value for this type. This value is useful as a reference point when polymorphic data is placed on a scalar axis.

Returns:
a new zero value data object sharing this type
See Also:
DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue), DataValue.interpolate(double, com.davisor.data.DataValue)

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two arguments. The objects are not instances of DataValue, they are first converted to this type with the toData(Object) method. If then either of the resulting objects is Comparable, comparation is delegated to it. Otherwise the compration fails. Comparation fails also if the object the comparation was delegated to fails to compare itself to the other object.

Specified by:
compare in interface java.util.Comparator
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
Throws:
java.lang.ClassCastException - if the arguments' types prevent them from being compared by this Comparator

dup

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

Specified by:
dup in interface com.davisor.core.Dupable

format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
Formats an object to produce a string. The given object is first converted to a DataValue with the help of the toData(Object) method. The data value value is then converted to a string with DataValue.toString() method. The resulting string is then appended to given string buffer.

Depending on underlying implementations, the resulting chain of conversion and formatting steps may be very complex and elaborate. For more efficient processing, consider using the DataValue.toString() directly when possible.

null objects or string buffers will generate no output. null field position objects are ignored and not written to.

Parameters:
obj - the object to format with this formatter (may be null)
toAppendTo - the string buffer to append the result to (may be null)
pos - the field position record to update (may be null)
Returns:
a reference to the string buffer given as argument (may be null)
Throws:
java.lang.IllegalArgumentException - if formatting fails
See Also:
toData(Object), DataValue, DataValue.toString()

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition status)
Parses a string to produce an object.


equals

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

Types are by default equal if their type identities and data names are equal.

Subclasses are expected to extend this equality test. In particular, subclass implementations are encouraged to first test object instance equality with the == operator, then their super-class unequality with super.equals(Object) method, and finally perform their own class -specific equality tests if necessary. A typical test sequence should therefore look something like this:

 public boolean equals(Object o)
 {
   if(this == o) return true;
   if(!super.equals(o) || !(o instanceof TypeSubClass)) return false;

   :
 }
 

Specified by:
equals in interface java.util.Comparator
See Also:
Compare.equals(Object,Object), VoidData.equals(Object)

hashCode

public int hashCode()
Returns a hash code value for the object. Subclasses are encouraged to define their own hash code functions that are better in line with their equality test methods.


toString

public java.lang.String toString()
Gets type string representation. The string representation is a set of XML tag attributes, giving values to type attributes.

Subclasses are expected to concatenate their own attributes to this string.

See Also:
xmlEnd(), xmlStart(), Strings.toXML(String,Object)

check

public java.lang.String check(java.lang.String value)
                       throws InvalidDataException
Checks and reformats a data string.

The default checking procedure is to first parse the data string as a data object, and then turn the resulting object back to a data string. Parsing checks the validity of the data string, while formatting reformats it. Therefore, in addition to validating the input value, the resulting string may also have been changed in some way.

The returned string should be such that if checked with this method again, the operation should be completed without exceptions or new changes to the string.

Parameters:
value - data string value
Returns:
checked and reformatted data string
Throws:
InvalidDataException - if the value is invalid
See Also:
check(String[]), toData(java.lang.String, java.text.ParsePosition), DataValue.toString()

check

public java.lang.String[] check(java.lang.String[] values)
                         throws InvalidDataException
Checks and reformats data strings. The checking is done by first parsing all data strings as data objects, and then formatting the resulting objects back to data strings. The new strings replace the old ones in 'values'.

Parsing checks the validity of the data strings, formatting reformats them. The resulting strings may be identical to the original ones, or they may have been changed in some way.

Parameters:
values - data strings
Returns:
a reference to values array, which now contains checked and reformatted data strings.
Throws:
InvalidDataException - if some value is invalid
See Also:
check(String)

ceil

public static DataValue ceil(DataValue zero,
                             DataValue step,
                             DataValue value)
                      throws InvalidDataException
Quantizes a value up so that the range from given zero value to the given value will be an even multiply of given steps.

Parameters:
zero - range limit value
step - quantization factor
value - value to be rounded up
Returns:
a new data object, sharing the type of the zero object
Throws:
InvalidDataException
See Also:
floor(com.davisor.data.DataValue, com.davisor.data.DataValue, com.davisor.data.DataValue)

create

public static Type create(java.lang.Object object)
                   throws InvalidDataException
Resolves the object type, creating a new one if neccessary. If the given object is a Data object, it's type is returned as it is. If the given object is not a Data object, a new type is created based on the object class.

Parameters:
object - the object of which the type is to be resolved (may be null)
Returns:
a data value representation of the given object
Throws:
InvalidDataException - if object can not be converted
NullDataException - if object was null
See Also:
create(Class,String,String,String), create(Integer,String,String,String), create(String,String,String,String), create(int,String,String,String), toData(Object)

create

public static Type create(int sqlType,
                          java.lang.String dataName,
                          java.lang.String id,
                          java.lang.String format)
                   throws NoSuchTypeException
Creates a new type instance from the given SQL type code. The given SQL type is searched from the index of known type families. If a matching type is found, then a new type instance from that family is created with the given type data name and specification.

Parameters:
sqlType - SQL type code
dataName - data name for the new type instance
id - type identity
format - specifications for the new type
Returns:
New type instance.
Throws:
NoSuchTypeException - 'sqlType' was not supported
See Also:
create(Class,String,String,String), create(Integer,String,String,String), create(Object), create(String,String,String,String)

create

public static Type create(java.lang.Integer sqlType,
                          java.lang.String dataName,
                          java.lang.String id,
                          java.lang.String format)
                   throws NoSuchTypeException
Creates a new type instance from the given SQL type code. The given SQL type is searched from the index of known type families. If a matching type is found, a new type instance from that family is created with the given data name, identity, and specification.

Type instances are created by calling their constructor with the following signature:

SomeType(String dataName,String id,String format)

The arguments are expected to have the same significance as corresponding arguments to this method. See IntegerType.IntegerType(String,String,String) for an example.

Parameters:
sqlType - sql type code
dataName - data name for the new type instance
id - type identity
format - specifications for the new type
Returns:
a new type instance
Throws:
NoSuchTypeException - if no type was mapped to sqlType
See Also:
create(Class,String,String,String), create(Object), create(String,String,String,String), create(int,String,String,String)

create

public static Type create(java.lang.Class typeClass,
                          java.lang.String dataName,
                          java.lang.String id,
                          java.lang.String format)
                   throws NoSuchTypeException
Creates a new type instance best suited for data elements represented as instances of of given Java class.

Parameters:
typeClass - desired element type class
dataName - data name for the new type instance
id - type identity
format - specifications for the new type
Returns:
a new type instance
Throws:
NoSuchTypeException - 'type' was not compatible with any known types.
See Also:
create(Integer,String,String,String), create(Object), create(String,String,String,String), create(int,String,String,String)

create

public static Type create(java.lang.String typeName,
                          java.lang.String dataName,
                          java.lang.String id,
                          java.lang.String format)
                   throws NoSuchTypeException
Creates a new type instance from the type family name. The given type family name is first searched from the index of known type families. If a matching family is found, a new type instance from that family is created with the given data name and specification.

Parameters:
typeName - case insensitive type name
dataName - data name for the new type instance
id - type identity
format - specifications for the new type
Returns:
a new type instance
Throws:
NoSuchTypeException - if type name did not refer to any known type
See Also:
create(Class,String,String,String), create(Integer,String,String,String), create(Object), create(int,String,String,String)

dup

public Type dup(java.lang.String dataName,
                java.lang.String id,
                java.lang.String format)
Creates a new type instance from this type. The current type is first duplicated and then reconfigured by the given data name and specification.

Parameters:
dataName - data name of the new type instance
id - type identity
format - specification string for the new type
Returns:
a new duplicated and reconfigured type instance
See Also:
dup(), setDataName(java.lang.String), setID(java.lang.String), setFormat(java.lang.String)

floor

public static DataValue floor(DataValue zero,
                              DataValue step,
                              DataValue value)
                       throws InvalidDataException
Quantizes a value down so that the range from given zero value to the given value will be an even multiply of given steps.

Parameters:
zero - range limit value
step - quantization factor
value - value to be rounded down
Returns:
a new data object, sharing the type of the zero object
Throws:
InvalidDataException
See Also:
ceil(com.davisor.data.DataValue, com.davisor.data.DataValue, com.davisor.data.DataValue)

getCompatibility

public float getCompatibility(java.lang.Class type)
Gets an estimate of how well this type could represent objects of the given class.

Parameters:
type - type to estimate
Returns:
0.0, if the types are not compatible and 1.0 if there is perfect match. Superclasses may override this method with implementations that may return something in between.
See Also:
getValueClass()

getDataName

public java.lang.String getDataName()
Gets type instance data name.

See Also:
setDataName(java.lang.String)

getId

public java.lang.String getId()
Deprecated. replaced with getID()

Gets type instance identity.


getID

public java.lang.String getID()
Gets type instance identity.

See Also:
setID(java.lang.String)

getFormat

public java.lang.String getFormat()
Gets the type specification string.

This particular default method implementation always returns a null specification string. Subclasses are, however, expected to override this.

Returns:
default, null specification string
See Also:
setFormat(java.lang.String), DataValue.getFormat()

getMetaData

public java.util.Map getMetaData()
Gets type meta data map.

Returns:
an application spesific meta data object map (may be null)
See Also:
getMetaData(Object)

getMetaData

public java.lang.Object getMetaData(java.lang.Object key)
Gets type meta data value. The returned value may be null if current meta data map does not recognize given key, or if there is currently no meta data map.

Parameters:
key - meta data key
Returns:
meta data value (may be null)
See Also:
getMetaData(), setMetaData(Object,Object)

getSpecs

public java.lang.String getSpecs()
Deprecated. replaced with getFormat()

Gets the type specification string.


getSQLName

public java.lang.String getSQLName()
Get the SQL type name for default database settings.

Returns:
SQL type name.

getSQLName

public java.lang.String getSQLName(java.lang.String dbtype)
Get the SQL type name for specific database.

Parameters:
dbtype - database type name.
Returns:
SQL type name.

getSQLCode

public int getSQLCode()
Gets the default java.sqlTypes SQL type code.

Returns:
Types.VARCHAR.

getTypeName

public java.lang.String getTypeName()
Gets the type name. Please note, that unlike with type identity and data name, there is no setName method, as a type name is an immutable type property.

Returns:
type name

isNull

public static boolean isNull(SerializableData data)
Tests if a given data is null, or has a null value.

Parameters:
data - data value to be tested
Returns:
true if data is null, or has a null value
See Also:
SerializableData.isNull()

register

public static void register(Type type)
Registers a type among known types. The new type is registered under it's type name, retrieved with getTypeName() method. After registration, the new type will be available for the various create methods.

Parameters:
type - type to be registered
See Also:
create(Class,String,String,String), create(Integer,String,String,String), create(Object), create(String,String,String,String), create(int,String,String,String)

register

public void register(java.sql.CallableStatement call,
                     int column)
              throws java.sql.SQLException
Register a callable statement output parameter type. This default implementation takes the appropriate JDBC type from the getSQLCode method.

Parameters:
call - statement to register out parameter to
column - column to register out parameter to
Throws:
java.sql.SQLException - if a SQL error occurs

setDataName

public void setDataName(java.lang.String dataName)
Sets the type instance data name.

Parameters:
dataName - new type instance data name (may be null)
See Also:
getDataName()

setId

public void setId(java.lang.String id)
Deprecated. replaced with setID(String)

Sets type identity.

Parameters:
id - new type instance identity

setID

public void setID(java.lang.String id)
Sets type identity.

Parameters:
id - new type instance identity
See Also:
getID()

setFormat

public void setFormat(java.lang.String format)
Sets the type specification string. Type specification string describes, in some type specific way, some type details that customize the way in which this particular type instance behaves. The type specification typically affects, for example, the details of how data values of this type are formatted and parsed.

The type specification string can also be set to null, which selects type default behaviour. In this case, the corresponding getFormat is also required to return null.

This particular default method implementation ignores any specification string given to it. Subclasses are, however, expected to override this.

Parameters:
format - type specification string (may be null)
See Also:
getFormat(), DataValue.getFormat()

setMetaData

public void setMetaData(java.util.Map metaData)
Sets type meta data map.

Parameters:
metaData - an application spesific meta data object map

setMetaData

public void setMetaData(java.lang.Object key,
                        java.lang.Object value)
Sets type meta data map value. If no meta data map is currently defined, a standard HashMap is created.

Parameters:
key - meta data key
value - meta data value
See Also:
getMetaData(Object), setMetaData(Map)

setSpecs

public void setSpecs(java.lang.String specs)
Deprecated. replaced with setFormat(String)

Sets the type specification string.

Parameters:
specs - type specification string (may be null)

toData

public DataValue toData(java.lang.Object objectValue)
                 throws InvalidDataException
Converts an object to a data value.

Subclasses are encouraged to implement this method with custom object parsers that interprete given object in the most lenient way possible, and create corresponding new object of this type. It is also acceptable to return the given object as it was, if the object meet subclass criteria for this type.

This default implementation first tests if the given object is a data value of this type. If it is, it is returned as it was. If it is not, the object string representation is delegated to the toData(String,ParsePosition) method for interpretation. If the object value is null, a VoidValue object is created and returned.

Parameters:
objectValue - data object
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
See Also:
toData(CallableStatement,int), toData(ResultSet,int), toData(String,ParsePosition), DataValue.toString()

toData

public DataValue toData(java.sql.CallableStatement statement,
                        int column)
                 throws InvalidDataException,
                        java.sql.SQLException
Converts a callable statement variable to a data value.

This detault implementation gets statement variable string value, and delegates it to toData(String,ParsePosition) method for intepretations.

Parameters:
statement - statement holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurs
See Also:
toData(Object), toData(ResultSet,int), toData(String,ParsePosition), DataValue.toString()

toData

public DataValue toData(java.sql.ResultSet resultSet,
                        int column)
                 throws InvalidDataException,
                        java.sql.SQLException
Converts a result set column value to a data value.

This detault implementation gets result set column string value, and delegates it to toData(String,ParsePosition) method for intepretations.

Parameters:
resultSet - resultSet holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurs
See Also:
toData(CallableStatement,int), toData(Object), toData(String,ParsePosition), DataValue.toString()

toXML

public static java.lang.String toXML(DataValue dataValue)
Converts a data value to a XML string. This small utility method first checks if given data value is not null, and if so, it invokes the DataValue.toXML() method of given value object. If the data value is null, null is also returned.

Parameters:
dataValue - data value to convert to a XML string
Returns:
data value XML string representation (may be null)

xmlEnd

public java.lang.String xmlEnd()
Creates a XML end element for data elements of this type.

See Also:
xmlStart()

xmlStart

public java.lang.String xmlStart()
Creates a XML start element for data elements of this type.

See Also:
toString(), xmlEnd(), Strings.toXML(String,Object)


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