|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.text.Format
com.davisor.data.Type
com.davisor.data.AutoType
AutoType implements an polymorphic type that delays actual type selection until data is first applied to it. At that time a type is selected automatically, based on data compatibility against all data types known to the type framework. After the best suited type is selected, an auto type instance will inhert all operational charastersitics of that type until the end of the auto type instance life cycle.
Auto type may also be assigned a polymorphic type spesification string even before an actual type is selected. If so provided, the spesification string will be passed to the actual type when it is created. There is of course no automatic quarantee that the final type can utilize the predetermined spesification string. A predetermined polymorphic type spesification makes however sence for example when working with locale sensitive types.
toData(Object),
toData(CallableStatement,int),
toData(ResultSet,int),
Type.create(Class,String,String,String),
Serialized Form| Nested Class Summary |
| Nested classes inherited from class java.text.Format |
java.text.Format.Field |
| Field Summary | |
protected java.lang.String |
M_format
Polymorphic type spesification string. |
protected Type |
M_type
Actual type. |
static java.lang.String |
TYPENAME
Type name ("AUTO"). |
| Fields inherited from class com.davisor.data.Type |
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS |
| Constructor Summary | |
|
AutoType()
Default constructor. |
|
AutoType(AutoType at)
Deep copy constructor. |
|
AutoType(java.lang.String dataName,
java.lang.String id,
java.lang.String format)
Creates a new type. |
protected |
AutoType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.lang.String format)
Creates a new type. |
| Method Summary | |
java.lang.String |
check(java.lang.String value)
Checks and reformats a data string value. |
java.lang.String[] |
check(java.lang.String[] values)
Checks and reformats a data strings. |
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. |
float |
getCompatibility(java.lang.Class type)
Gets an estimate of how well this type could represent objects of the given class. |
java.lang.String |
getFormat()
Gets the type specification string. |
int |
getSQLCode()
Get the default SQL type code. |
java.lang.String |
getSQLName()
Get the default SQL type name. |
Type |
getType()
Gets current actual type. |
java.lang.Class |
getValueClass()
Gets value container class. |
int |
hashCode()
Returns a hash code value for the object. |
void |
register(java.sql.CallableStatement call,
int column)
Register a callable statement output parameter type. |
void |
setFormat(java.lang.String format)
Sets the type specification string. |
void |
setType(Type type)
Sets actual type. |
DataValue |
toData(java.sql.CallableStatement statement,
int column)
Converts a result set column value 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. |
DataValue |
toData(java.lang.String stringValue,
java.text.ParsePosition status)
Converts a string to a data value. |
DataValue |
zero()
Gets zero data value for this type. |
| Methods inherited from class com.davisor.data.Type |
ceil, compare, create, create, create, create, create, dup, floor, format, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getTypeName, isNull, parseObject, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toString, toXML, xmlEnd, xmlStart |
| 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 |
public static final java.lang.String TYPENAME
protected java.lang.String M_format
protected Type M_type
| Constructor Detail |
public AutoType()
public AutoType(AutoType at)
public AutoType(java.lang.String dataName,
java.lang.String id,
java.lang.String format)
This is the constructor the SQL type mapper Type.create(Integer,String,String,String) method will call to
create a type that matches given SQL type.
dataName - data name (may be null)id - type identity (may be null)format - polymorphic type spesification (may be null)
protected AutoType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.lang.String format)
typeName - type namedataName - data name (may be null)id - type identity (may be null)metaData - type meta data map (may be null)format - polymorphic type spesification (may be null)| Method Detail |
public com.davisor.core.Dupable dup()
dup in interface com.davisor.core.Dupabledup in class Typepublic boolean equals(java.lang.Object o)
Text types are equal if their super-classes, maximum length constraints, and prefixes are.
equals in interface java.util.Comparatorequals in class TypeCompare.equals(Object,Object)public int hashCode()
hashCode in class Type
public Type getType()
throws InvalidDataException
InvalidDataExceptionsetType(com.davisor.data.Type)public void setType(Type type)
null, the type will be resolved
automatically when data is next time applied to this type.
type - new actual type (may be null)getType(),
toData(Object),
toData(CallableStatement,int),
toData(ResultSet,int)
public java.lang.String check(java.lang.String value)
throws InvalidDataException
If an actual type has already been selected, the operation is delegated to that type. Otherwise the given string is returned unmodified.
check in class Typevalue - data string value to check
InvalidDataException - if the value is invalid as a data stringcheck(String[]),
toData(java.lang.Object),
DataValue.toString()
public java.lang.String[] check(java.lang.String[] values)
throws InvalidDataException
If an actual type has already been selected, the operation is delegated to that type. Otherwise the given strings are returned unmodified.
check in class Typevalues - data strings
InvalidDataException - if some value is invalid as a data stringcheck(String)public float getCompatibility(java.lang.Class type)
If an actual type has already been selected, the operation is delegated to that type. Otherwise full compatibiliy (1.0) is returned.
getCompatibility in class Typetype - type to estimate
getValueClass()public java.lang.String getFormat()
If the actual type has not yet been spesified, the current polymorphic spesification string on hold is returned. If an actual type has been specified, the current spesification string from that type will be returned.
getFormat in class Typenull specification stringsetFormat(java.lang.String)public java.lang.String getSQLName()
If an actual type has already been selected, the operation is delegated to that type. Otherwise the superclass default SQL type name is returned.
getSQLName in class Typepublic int getSQLCode()
If an actual type has already been selected, the operation is delegated to that type. Otherwise the superclass default SQL type code is returned.
getSQLCode in class Typepublic java.lang.Class getValueClass()
getValueClass in class Type
public void register(java.sql.CallableStatement call,
int column)
throws java.sql.SQLException
If an actual type has already been selected, the operation is delegated to that type. Otherwise nothing is done.
register in class Typecall - statement to register out parameter tocolumn - column to register out parameter to
java.sql.SQLException - if a SQL error occurspublic void setFormat(java.lang.String format)
If the actual type has not yet been spesified, the given spesification string is stored until that time. If an actual type has been specified, the given spesification string will be passed to it immediately.
setFormat in class Typeformat - polymorphic type spesification (may be null)getFormat()
public DataValue toData(java.lang.Object objectValue)
throws InvalidDataException
If actual type has not yet been resolved, an attempt to resolve
it now is made. First, if the given objectValue is
null or an explicit void value of VoidType,
actual type is left undetermined for now. Next, if the object is
any instance of DataValue, the type of that value is
copied and taken as the new actual type. In any other case, the
actual type is determined with the Type.create(Class,String,String,String) method.
The new type, if found, is configured with current predetermined spesification string, if any.
toData in class TypeobjectValue - data object
InvalidDataException - if given object value could not be parsedtoData(CallableStatement,int),
toData(ResultSet,int),
toData(String,ParsePosition),
DataValue.toString()
public DataValue toData(java.sql.CallableStatement statement,
int column)
throws InvalidDataException,
java.sql.SQLException
If actual type has not yet been resolved, it is resolved now.
The actual type is determined with the Type.create(int,String,String,String) method.
toData in class Typestatement - statement holding the data value to be convertedcolumn - SQL column index for the data value to be converted
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurstoData(Object),
toData(ResultSet,int),
toData(String,ParsePosition),
DataValue.toString()
public DataValue toData(java.sql.ResultSet resultSet,
int column)
throws InvalidDataException,
java.sql.SQLException
If actual type has not yet been resolved, it is resolved now.
The actual type is determined with the Type.create(int,String,String,String) method.
toData in class TyperesultSet - resultSet holding the data value to be convertedcolumn - SQL column index for the data value to be converted
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurstoData(CallableStatement,int),
toData(Object),
toData(String,ParsePosition),
DataValue.toString()
public DataValue toData(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
If actual type has not yet been resolved, type resolvation is
attempted now if given string value is not null or
empty. If it is, null is returned, and actual type
remains unresolved. Otherwise, if the string contains a number, a
DoubleType is created. If it contains a timestamp, time,
or date value, a TimestampType is created. Otherwise a
TextType. In each of these cases, the current type
spesification string if any, is passed to type created. The type
will also be immediately used to convert the given string to a
data value.
If actual type has already been resolved, the string interpretation is delegated to that type.
toData in class TypestringValue - string value to be parsed (may be null)status - parse status (may be null)
InvalidDataException - if given string value could not be parsedType.toData(CallableStatement,int),
Type.toData(Object),
Type.toData(ResultSet,int),
DataValue.toString()public DataValue zero()
If an actual type has already been selected, the operation is
delegated to that type. Otherwise null is returned.
zero in class TypenullDataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue),
DataValue.interpolate(double, com.davisor.data.DataValue)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||