public abstract class BasePoemType<T> extends Object implements SQLPoemType<T>, Cloneable
| Modifier and Type | Method and Description |
|---|---|
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.
|
<O> PoemType<O> |
canRepresent(PoemType<O> other)
Return a PoemType which can can represent another,
or null.
|
Object |
cookedOfRaw(Object raw)
Converts a possibly null low-level representation of a database
column value to its canonical form.
|
boolean |
getNullable()
Whether the type is nullable.
|
T |
getRaw(ResultSet rs,
int col)
Return an object as delivered by the database.
|
Enumeration<T> |
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.
|
T |
rawOfCooked(Object cooked)
Return the Object value, a no-op for all but ReferencePoemTypes,
for which it returns the troid as an Integer.
|
T |
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<T> |
withNullable(boolean nullableP)
Get a new type with a nullablity, presumably different.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitsqlDefaultValuepublic void setRawRange(Comparable<T> low, Comparable<T> limit)
low - included lower limitlimit - excluded upper limitpublic final void assertValidRaw(Object raw) throws ValidationPoemException
assertValidRaw in interface PoemType<T>raw - the raw value to checkValidationPoemException - if the raw has an illegal valuePoemType.assertValidRaw(java.lang.Object)public final T getRaw(ResultSet rs, int col) throws ValidationPoemException
getRaw in interface SQLType<T>rs - the Resultset containing the valuecol - the column withing the ResultSet to readValidationPoemExceptionSQLType.getRaw(java.sql.ResultSet, int)public final void setRaw(PreparedStatement ps, int col, Object raw)
setRaw in interface SQLType<T>ps - the Prepared Statement to modifycol - the column within the PreparedStatementraw - the value to setSQLType.setRaw(java.sql.PreparedStatement, int, java.lang.Object)public Enumeration<T> possibleRaws()
possibleRaws in interface PoemType<T>PoemType.possibleRaws()public final String stringOfRaw(Object raw) throws ValidationPoemException
stringOfRaw in interface PoemType<T>raw - the valueValidationPoemException - if the raw has an illegal valuePoemType.stringOfRaw(java.lang.Object)public final T 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<T>string - the String representation to convertParsingPoemException - if the String representation is not well formedValidationPoemException - if the raw has an illegal valuePoemType.rawOfString(java.lang.String)public final void assertValidCooked(Object cooked) throws ValidationPoemException
assertValidCooked in interface PoemType<T>cooked - the Object to checkValidationPoemException - if the raw has an illegal valuePoemType.assertValidCooked(java.lang.Object)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<T>raw - the object, typically a troidTypeMismatchPoemException - if the raw is of the wrong typePoemException - if there is another problem, such as no object with that troidPoemType.cookedOfRaw(java.lang.Object)public final T rawOfCooked(Object cooked)
rawOfCooked in interface PoemType<T>cooked - the Persistent or ObjectPoemType.rawOfCooked(java.lang.Object)public final String stringOfCooked(Object cooked, PoemLocale locale, int style) throws PoemException
stringOfCooked in interface PoemType<T>cooked - the PoemType to be stringifiedlocale - to be used for datesstyle - as in java.text.DateFormat.SHORT, ...TypeMismatchPoemException - if the raw is of the wrong typePoemException - if there is an access violationPoemType.stringOfCooked(java.lang.Object,
org.melati.poem.PoemLocale, int)public final boolean getNullable()
getNullable in interface PoemType<T>PoemType.getNullable()public final int sqlTypeCode()
sqlTypeCode in interface SQLType<T>SQLType.sqlTypeCode()public String sqlDefinition(Dbms dbms)
STRING NOT NULL
sqlDefinition in interface SQLType<T>dbms - the DBMSSQLType.sqlDefinition(org.melati.poem.dbms.Dbms)public String sqlTypeDefinition(Dbms dbms)
STRING
sqlTypeDefinition in interface SQLType<T>dbms - the DBMSSQLType.sqlTypeDefinition(org.melati.poem.dbms.Dbms)public <O> PoemType<O> canRepresent(PoemType<O> other)
canRepresent in interface PoemType<T>O - the type of the PoemTypeother - the other type to checkPoemType.canRepresent(org.melati.poem.PoemType)public final PoemType<T> withNullable(boolean nullableP)
withNullable in interface PoemType<T>nullableP - the nullability we wantPoemType.withNullable(boolean)public void saveColumnInfo(ColumnInfo info) throws AccessPoemException
saveColumnInfo in interface PoemType<T>info - the ColumnInfo to set the type ofAccessPoemException - if our AccessToken does not permit modificationPoemType.saveColumnInfo(org.melati.poem.ColumnInfo)public String quotedRaw(Object raw) throws ValidationPoemException
numbers and booleans are not quoted for most dbms'.
quotedRaw in interface SQLType<T>raw - sql valueValidationPoemExceptionSQLType.quotedRaw(java.lang.Object)public String toString()
toString in class ObjectObject.toString()Copyright © 2000–2021 PanEris. All rights reserved.