org.melati.poem
Interface PoemType<T>

Package class diagram package PoemType
All Known Subinterfaces:
SQLPoemType
All Known Implementing Classes:
AtomPoemType, BasePoemType, BigDecimalPoemType, BinaryPoemType, BooleanPoemType, ColumnTypePoemType, DatePoemType, DeletedPoemType, DisplayLevelPoemType, DoublePoemType, FixedPointAtomPoemType, IndexPoemType, IntegerPoemType, IntegrityFixPoemType, LongPoemType, MSAccess.MSAccessStringPoemType, MySQL.BlobPoemType, MySQL.MySQLBooleanPoemType, MySQL.MySQLStringPoemType, Oracle.OracleBooleanPoemType, Oracle.OracleStringPoemType, PasswordPoemType, ReferencePoemType, RestrictedReferencePoemType, SearchabilityPoemType, SizedAtomPoemType, SQLServer.SQLServerBooleanPoemType, StringPoemType, TimestampPoemType, TroidPoemType

public interface PoemType<T>

A data type.

PoemTypes come in two flavours: the predefined ones and those that can be defined by the application programmer; the former have a negative type code, the latter a positive one.


Method Summary
 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.
 Object cookedOfRaw(Object raw)
          Create an Object from a raw Object, a no-op for all but ReferencePoemTypes.
 boolean getNullable()
          Whether the type is nullable.
 Enumeration<T> possibleRaws()
          Get the possible values for this field, null for rangeable types with no range set.
 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 rawString)
          Get an Object from its String representation.
 void saveColumnInfo(ColumnInfo columnInfo)
          Set the type of the ColumnInfo.
 String stringOfCooked(Object cooked, PoemLocale locale, int style)
          A localised String representation of the oject.
 String stringOfRaw(Object object)
          The String representation of the Field.
 String toDsdType()
          The field type used in the Data Structure Definition language.
 PoemType<T> withNullable(boolean nullable)
          Get a new type with a nullablity, presumably different.
 

Method Detail

assertValidRaw

void assertValidRaw(Object raw)
                    throws TypeMismatchPoemException,
                           ValidationPoemException
Check if value is of the right type and an allowed value, throw appropriate Exception if not.

Parameters:
raw - the raw value to check
Throws:
TypeMismatchPoemException - if the raw is of the wrong type
ValidationPoemException - if the raw has an illegal value

possibleRaws

Enumeration<T> possibleRaws()
Get the possible values for this field, null for rangeable types with no range set. NOTE Null is a possible value for nullable types

Returns:
an Enumeration of possibilities or null

stringOfRaw

String stringOfRaw(Object object)
                   throws TypeMismatchPoemException,
                          ValidationPoemException
The String representation of the Field.

Parameters:
object - the value
Returns:
a String representation
Throws:
TypeMismatchPoemException - if the raw is of the wrong type
ValidationPoemException - if the raw has an illegal value

rawOfString

T rawOfString(String rawString)
              throws ParsingPoemException,
                     ValidationPoemException
Get an Object from its String representation.

Parameters:
rawString - the String representation to convert
Returns:
an Object of the correct type
Throws:
ParsingPoemException - if the String representation is not well formed
ValidationPoemException - if the raw has an illegal value

assertValidCooked

void assertValidCooked(Object cooked)
                       throws TypeMismatchPoemException,
                              ValidationPoemException
Check if an Object is valid, throw appropriate Exception if not.

Parameters:
cooked - the Object to check
Throws:
TypeMismatchPoemException - if the raw is of the wrong type
ValidationPoemException - if the raw has an illegal value

cookedOfRaw

Object cookedOfRaw(Object raw)
                   throws TypeMismatchPoemException,
                          PoemException
Create an Object from a raw Object, a no-op for all but ReferencePoemTypes.

Parameters:
raw - the object, typically a troid
Returns:
the Persistent or the raw unchanged
Throws:
TypeMismatchPoemException - if the raw is of the wrong type
PoemException - if there is another problem, such as no object with that troid

rawOfCooked

T rawOfCooked(Object cooked)
              throws TypeMismatchPoemException
Return the Object value, a no-op for all but ReferencePoemTypes, for which it returns the troid as an Integer.

Parameters:
cooked - the Persistent or Object
Returns:
a Persistent's troid or the raw unchanged
Throws:
TypeMismatchPoemException - if the raw is of the wrong type

stringOfCooked

String stringOfCooked(Object cooked,
                      PoemLocale locale,
                      int style)
                      throws TypeMismatchPoemException,
                             PoemException
A localised String representation of the oject.

Parameters:
style - as in java.text.DateFormat.SHORT, ...
Returns:
a String representation of an Object
Throws:
TypeMismatchPoemException - if the raw is of the wrong type
PoemException - if there is an access violation

getNullable

boolean getNullable()
Whether the type is nullable.

Returns:
the type's nullability

canRepresent

PoemType<?> canRepresent(PoemType<?> other)
Return a PoemType which can can represent another, or null.

Parameters:
other - the other type to check
Returns:
the other or null

withNullable

PoemType<T> withNullable(boolean nullable)
Get a new type with a nullablity, presumably different.

Parameters:
nullable - the nullability we want
Returns:
this or a clone with the desired nullability

saveColumnInfo

void saveColumnInfo(ColumnInfo columnInfo)
                    throws AccessPoemException
Set the type of the ColumnInfo.

Parameters:
columnInfo - the ColumnInfo to set the type of
Throws:
AccessPoemException - if our AccessToken does not permit modification

toDsdType

String toDsdType()
The field type used in the Data Structure Definition language.

Returns:
the Type name


Copyright © 2000-2010 PanEris. All Rights Reserved.