|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.melati.poem.BasePoemType<T>
public abstract class BasePoemType<T>
Base class of all fundamental types.
Field Summary | |
---|---|
protected boolean |
nullable
|
Method Summary | |
---|---|
protected abstract void |
_assertValidCooked(Object cooked)
|
protected abstract void |
_assertValidRaw(Object raw)
|
protected abstract boolean |
_canRepresent(SQLPoemType other)
|
protected abstract Object |
_cookedOfRaw(Object raw)
Converts a non-null low-level representation of a database column value to the appropriate object. |
protected abstract Object |
_getRaw(ResultSet rs,
int col)
|
protected Enumeration<Object> |
_possibleRaws()
|
protected abstract String |
_quotedRaw(Object raw)
|
protected abstract Object |
_rawOfCooked(Object raw)
|
protected abstract Object |
_rawOfString(String string)
Converts a non-null string to an appropriate value for insertion into the underlying DBMS. |
protected abstract void |
_saveColumnInfo(ColumnInfo info)
|
protected abstract void |
_setRaw(PreparedStatement ps,
int col,
Object raw)
|
protected abstract String |
_sqlDefinition(Dbms dbms)
|
protected abstract String |
_stringOfCooked(Object cooked,
PoemLocale locale,
int style)
|
protected abstract String |
_stringOfRaw(Object raw)
|
protected abstract String |
_toString()
|
void |
assertValidCooked(Object cooked)
Check if an Object is valid, throw appropriate Exception if not. |
void |
assertValidRaw(Object raw)
Check if value is of the right type and an allowed value, throw appropriate Exception if not. |
PoemType<?> |
canRepresent(PoemType other)
Return a PoemType which can can represent another, or null. |
protected Object |
clone()
|
Object |
cookedOfRaw(Object raw)
Converts a possibly null low-level representation of a database column value to its canonical form. |
protected Comparable<T> |
getLimitRaw()
|
protected Comparable<T> |
getLowRaw()
|
boolean |
getNullable()
Whether the type is nullable. |
Object |
getRaw(ResultSet rs,
int col)
Return an object as delivered by the database. |
Enumeration<Object> |
possibleRaws()
Get the possible values for this field, null for rangeable types with no range set. |
String |
quotedRaw(Object raw)
Quoting a raw value, if appropriate, for the Dbms. |
Object |
rawOfCooked(Object cooked)
Return the Object value, a no-op for all but ReferencePoemTypes, for which it returns the troid as an Integer. |
Object |
rawOfString(String string)
Converts a possibly null String to a low level
representation of a valid database column value. |
void |
saveColumnInfo(ColumnInfo info)
Set the type of the ColumnInfo. |
void |
setRaw(PreparedStatement ps,
int col,
Object raw)
Set a column of a PreparedStatement to the passed in value. |
void |
setRawRange(Comparable<T> low,
Comparable<T> limit)
Set the limits, if applicable. |
String |
sqlDefinition(Dbms dbms)
See http://dev.mysql.com/doc/refman/5.0/en/timestamp.html The MySQL default for nullability of timestamps is not null, so need to make all fields explicitly nullable. |
int |
sqlTypeCode()
|
String |
sqlTypeDefinition(Dbms dbms)
SQL type definition without nullability. |
String |
stringOfCooked(Object cooked,
PoemLocale locale,
int style)
A localised String representation of the oject. |
String |
stringOfRaw(Object raw)
This doesn't do an explicit assertValidRaw. |
String |
toString()
|
PoemType |
withNullable(boolean nullableP)
Get a new type with a nullablity, presumably different. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.melati.poem.SQLType |
---|
sqlDefaultValue |
Methods inherited from interface org.melati.poem.PoemType |
---|
toDsdType |
Field Detail |
---|
protected boolean nullable
Method Detail |
---|
public void setRawRange(Comparable<T> low, Comparable<T> limit)
low
- included lower limitlimit
- excluded upper limitprotected Comparable<T> getLowRaw()
protected Comparable<T> getLimitRaw()
protected abstract void _assertValidRaw(Object raw) throws ValidationPoemException
ValidationPoemException
public final void assertValidRaw(Object raw) throws ValidationPoemException
assertValidRaw
in interface PoemType
raw
- the raw value to check
ValidationPoemException
- if the raw has an illegal valuePoemType.assertValidRaw(java.lang.Object)
protected abstract Object _getRaw(ResultSet rs, int col) throws SQLException
SQLException
public final Object getRaw(ResultSet rs, int col) throws ValidationPoemException
getRaw
in interface SQLType
rs
- the Resultset containing the valuecol
- the column withing the ResultSet to read
ValidationPoemException
SQLType.getRaw(java.sql.ResultSet, int)
protected abstract void _setRaw(PreparedStatement ps, int col, Object raw) throws SQLException
SQLException
public final void setRaw(PreparedStatement ps, int col, Object raw)
setRaw
in interface SQLType
ps
- the Prepared Statement to modifycol
- the column within the PreparedStatementraw
- the value to setSQLType.setRaw(java.sql.PreparedStatement, int, java.lang.Object)
protected Enumeration<Object> _possibleRaws()
public Enumeration<Object> possibleRaws()
possibleRaws
in interface PoemType
PoemType.possibleRaws()
protected abstract String _stringOfRaw(Object raw)
public final String stringOfRaw(Object raw) throws ValidationPoemException
stringOfRaw
in interface PoemType
raw
- the value
ValidationPoemException
- if the raw has an illegal valuePoemType.stringOfRaw(java.lang.Object)
protected abstract Object _rawOfString(String string) throws ParsingPoemException
ParsingPoemException
public final Object rawOfString(String string) throws ParsingPoemException, ValidationPoemException
String
to a low level
representation of a valid database column value.
Null values are not changed.
This result is validated with assertValidRaw(Object)
whereas stringOfRaw(Object)
assumes this is not
required.
Get an Object from its String representation.
rawOfString
in interface PoemType
string
- the String representation to convert
ParsingPoemException
- if the String representation is not well formed
ValidationPoemException
- if the raw has an illegal valuePoemType.rawOfString(java.lang.String)
protected abstract void _assertValidCooked(Object cooked) throws ValidationPoemException
ValidationPoemException
public final void assertValidCooked(Object cooked) throws ValidationPoemException
assertValidCooked
in interface PoemType
cooked
- the Object to check
ValidationPoemException
- if the raw has an illegal valuePoemType.assertValidCooked(java.lang.Object)
protected abstract Object _cookedOfRaw(Object raw) throws PoemException
For the base object types, (String, Integer etc) this involves no change.
For types with an integer id, such as Poem internal types and user defined types, then the appropriate instantiated type is returned from its Integer id.
raw
- the base object or Integer object id
PoemException
public final Object cookedOfRaw(Object raw) throws PoemException
The raw value is checked to ensure it is valid. Create an Object from a raw Object, a no-op for all but ReferencePoemTypes.
cookedOfRaw
in interface PoemType
raw
- the object, typically a troid
TypeMismatchPoemException
- if the raw is of the wrong type
PoemException
- if there is another problem, such as no object with that troidPoemType.cookedOfRaw(java.lang.Object)
protected abstract Object _rawOfCooked(Object raw) throws PoemException
PoemException
public final Object rawOfCooked(Object cooked)
rawOfCooked
in interface PoemType
cooked
- the Persistent or Object
PoemType.rawOfCooked(java.lang.Object)
protected abstract String _stringOfCooked(Object cooked, PoemLocale locale, int style) throws PoemException
PoemException
public final String stringOfCooked(Object cooked, PoemLocale locale, int style) throws PoemException
stringOfCooked
in interface PoemType
style
- as in java.text.DateFormat.SHORT, ...
TypeMismatchPoemException
- if the raw is of the wrong type
PoemException
- if there is an access violationPoemType.stringOfCooked(java.lang.Object,
org.melati.poem.PoemLocale, int)
public final boolean getNullable()
getNullable
in interface PoemType
PoemType.getNullable()
public final int sqlTypeCode()
sqlTypeCode
in interface SQLType
SQLType.sqlTypeCode()
protected abstract String _sqlDefinition(Dbms dbms)
public String sqlDefinition(Dbms dbms)
STRING NOT NULL
sqlDefinition
in interface SQLType
dbms
- the DBMS
SQLType.sqlDefinition(org.melati.poem.dbms.Dbms)
public String sqlTypeDefinition(Dbms dbms)
STRING
sqlTypeDefinition
in interface SQLType
dbms
- the DBMS
SQLType.sqlTypeDefinition(org.melati.poem.dbms.Dbms)
protected abstract boolean _canRepresent(SQLPoemType other)
public PoemType<?> canRepresent(PoemType other)
canRepresent
in interface PoemType
other
- the other type to check
PoemType.canRepresent(org.melati.poem.PoemType)
public final PoemType withNullable(boolean nullableP)
withNullable
in interface PoemType
nullableP
- the nullability we want
PoemType.withNullable(boolean)
protected abstract void _saveColumnInfo(ColumnInfo info) throws AccessPoemException
AccessPoemException
public void saveColumnInfo(ColumnInfo info) throws AccessPoemException
saveColumnInfo
in interface PoemType
info
- the ColumnInfo to set the type of
AccessPoemException
- if our AccessToken does not permit modificationPoemType.saveColumnInfo(org.melati.poem.ColumnInfo)
protected abstract String _quotedRaw(Object raw)
public String quotedRaw(Object raw) throws ValidationPoemException
numbers and booleans are not quoted for most dbms'.
quotedRaw
in interface SQLType
raw
- sql value
ValidationPoemException
SQLType.quotedRaw(java.lang.Object)
protected abstract String _toString()
public String toString()
toString
in class Object
Object.toString()
protected Object clone()
clone
in class Object
Object.clone()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |