org.melati.poem
Class Column

Package class diagram package Column
java.lang.Object
  extended by org.melati.poem.Column
All Implemented Interfaces:
FieldAttributes
Direct Known Subclasses:
ExtraColumn

public abstract class Column
extends Object
implements FieldAttributes

Abstract Table column which is extended by the generated classes.

Author:
WilliamC At paneris.org

Nested Class Summary
static class Column.LoadException
          Thrown when any unforeseen problem arises loading a Column.
static class Column.SettingException
          Thrown when any unforseen problem arises setting the value of a Column.
 
Constructor Summary
Column(Table table, String name, SQLPoemType type, DefinitionSource definitionSource)
          Constructor.
 
Method Summary
 Field asEmptyField()
          Return a Field of the same type as this Column with default attributes.
abstract  Field asField(Persistent g)
          Return a Field of the same type as this Column from the Persistent.
 CachedSelection cachedSelectionWhereEq(Object raw)
          Create a new CachedSelection of objects equal to this raw parameter.
protected  String defaultDescription()
           
protected  DisplayLevel defaultDisplayLevel()
           
protected  String defaultDisplayName()
           
protected  int defaultDisplayOrder()
           
protected  Integer defaultDisplayOrderPriority()
           
protected  int defaultHeight()
           
protected  boolean defaultIndexed()
           
protected  StandardIntegrityFix defaultIntegrityFix()
           
protected  int defaultPrecision()
           
protected  String defaultRenderinfo()
           
protected  int defaultScale()
           
protected  Searchability defaultSearchability()
           
protected  boolean defaultSortDescending()
           
protected  boolean defaultUnique()
           
protected  boolean defaultUserCreateable()
           
protected  boolean defaultUserEditable()
           
protected  int defaultWidth()
           
 void dump()
          Print information about the structure of the Column to stdout.
 void dump(PrintStream ps)
          Print information to PrintStream.
 Persistent ensure(Persistent orCreate)
          Ensures a row exists for which this column matches when compared with the given Persistent.
 String eqClause(Object raw)
           
 int firstFree(String whereClause)
          Find the next free value in an Integer column.
 Persistent firstWhereEq(Object raw)
          Return the first one found or null if not found.
 String fullQuotedName()
           
 ColumnInfo getColumnInfo()
           
abstract  Object getCooked(Persistent g)
          Retrieves the field value, with locking and access control for this Column.
 Database getDatabase()
           
 String getDescription()
          
 DisplayLevel getDisplayLevel()
           
 String getDisplayName()
          Return a human readable name from the metadata.
 Integer getDisplayOrderPriority()
           
 int getHeight()
          
 boolean getIndexed()
          
 IntegrityFix getIntegrityFix()
          Get the IntegrityFix, if any.
 String getName()
          
abstract  Object getRaw_unsafe(Persistent g)
          Retrieves the field value, without locking, for this Column.
abstract  Object getRaw(Persistent g)
          Retrieves the field value, with locking, for this Column.
 String getRenderInfo()
          
 Searchability getSearchability()
           
 boolean getSortDescending()
          Defaults to false.
 SQLPoemType getSQLType()
           
 Table getTable()
           
 PoemType<?> getType()
          
 boolean getUnique()
           
 boolean getUserCreateable()
          
 boolean getUserEditable()
          
 int getWidth()
          
 boolean isDeletedColumn()
          A Deleted Column is a Column which signal whether the record has been soft-deleted.
 boolean isTroidColumn()
           
 String quotedName()
           
 Enumeration<Persistent> referencesTo(Persistent object)
          Return an Enumeration of Persistents from the Table this column refers to, if this is a reference column, otherwise the Empty Enumeration.
 Enumeration<Persistent> selectionWhereEq(Object raw)
          Get rows where column equal to value.
abstract  void setCooked(Persistent g, Object cooked)
          Sets the field value, with locking, access control and validation for this Column.
 void setDisplayLevel(DisplayLevel level)
           
 void setIntegrityFix(StandardIntegrityFix fix)
           
abstract  void setRaw_unsafe(Persistent g, Object raw)
          Sets the field value, without locking, for this Column.
abstract  void setRaw(Persistent g, Object raw)
          Sets the field value, with locking, for this Column.
 void setRawString(Persistent g, String rawString)
          Set the value from its String representation, if possible.
 void setSearchability(Searchability searchability)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Column

public Column(Table table,
              String name,
              SQLPoemType type,
              DefinitionSource definitionSource)
Constructor.

Parameters:
table - this column belongs to
name - of this Column
type - datatype
definitionSource - where it is being defined from
Method Detail

defaultDisplayLevel

protected DisplayLevel defaultDisplayLevel()

defaultSearchability

protected Searchability defaultSearchability()

defaultDisplayOrderPriority

protected Integer defaultDisplayOrderPriority()

defaultSortDescending

protected boolean defaultSortDescending()

defaultDisplayName

protected String defaultDisplayName()

defaultDisplayOrder

protected int defaultDisplayOrder()

defaultDescription

protected String defaultDescription()

defaultUserEditable

protected boolean defaultUserEditable()

defaultUserCreateable

protected boolean defaultUserCreateable()

defaultIndexed

protected boolean defaultIndexed()

defaultUnique

protected boolean defaultUnique()

defaultIntegrityFix

protected StandardIntegrityFix defaultIntegrityFix()
Returns:
the StandardIntegrityFix prevent

defaultWidth

protected int defaultWidth()

defaultHeight

protected int defaultHeight()

defaultPrecision

protected int defaultPrecision()

defaultScale

protected int defaultScale()

defaultRenderinfo

protected String defaultRenderinfo()

getDatabase

public final Database getDatabase()
Returns:
the Databse our table is in

getTable

public final Table getTable()
Returns:
our Table

getName

public final String getName()

Specified by:
getName in interface FieldAttributes
Returns:
the machine name of the field
See Also:
FieldAttributes.getName()

quotedName

public final String quotedName()
Returns:
the name quoted appropriately for the DBMS

fullQuotedName

public final String fullQuotedName()
Returns:
the name in table.column notation

getDisplayName

public final String getDisplayName()
Return a human readable name from the metadata.

Specified by:
getDisplayName in interface FieldAttributes
Returns:
the human readable name of the field
See Also:
FieldAttributes.getDisplayName()

getDescription

public final String getDescription()

Specified by:
getDescription in interface FieldAttributes
Returns:
the longer description of the field
See Also:
FieldAttributes.getDescription()

getColumnInfo

public final ColumnInfo getColumnInfo()
Returns:
the metadata record for this Column

getDisplayLevel

public DisplayLevel getDisplayLevel()
Returns:
the defined or default DsiplayLevel

setDisplayLevel

public void setDisplayLevel(DisplayLevel level)
Parameters:
level - the DisplayLevel to set

getSearchability

public Searchability getSearchability()
Returns:
our defined or default Searchabillity

setSearchability

public void setSearchability(Searchability searchability)
Parameters:
searchability - the Searchability to set

getUserEditable

public final boolean getUserEditable()

Specified by:
getUserEditable in interface FieldAttributes
Returns:
whether a user may change the field value
See Also:
FieldAttributes.getUserEditable()

getUserCreateable

public final boolean getUserCreateable()

Specified by:
getUserCreateable in interface FieldAttributes
Returns:
whether a user may create a field
See Also:
FieldAttributes.getUserCreateable()

getSQLType

public final SQLPoemType getSQLType()
Returns:
the SQLPoemType of this Column

getType

public final PoemType<?> getType()

Specified by:
getType in interface FieldAttributes
Returns:
the PoemType of the field
See Also:
FieldAttributes.getType()

isTroidColumn

public final boolean isTroidColumn()
Returns:
whether this is a Troid Column

isDeletedColumn

public final boolean isDeletedColumn()
A Deleted Column is a Column which signal whether the record has been soft-deleted.

Returns:
whether this is a Deleted Column

getIndexed

public final boolean getIndexed()

Specified by:
getIndexed in interface FieldAttributes
Returns:
whether the field is indexed
See Also:
FieldAttributes.getIndexed()

getUnique

public final boolean getUnique()
Returns:
whether this Column's values are unique in this table

getIntegrityFix

public IntegrityFix getIntegrityFix()
Get the IntegrityFix, if any.

Returns:
the IntegrityFix or default

setIntegrityFix

public void setIntegrityFix(StandardIntegrityFix fix)
Parameters:
fix - the IntegrityFix to set

getRenderInfo

public final String getRenderInfo()

Specified by:
getRenderInfo in interface FieldAttributes
Returns:
the name of a special widget templet to display this field
See Also:
FieldAttributes.getRenderInfo()

getWidth

public final int getWidth()

Specified by:
getWidth in interface FieldAttributes
Returns:
the width of widget required to display this field
See Also:
FieldAttributes.getWidth()

getHeight

public final int getHeight()

Specified by:
getHeight in interface FieldAttributes
Returns:
the height of widget to display this field
See Also:
FieldAttributes.getHeight()

getDisplayOrderPriority

public final Integer getDisplayOrderPriority()
Returns:
the set or default DisplayOrderPriority

getSortDescending

public final boolean getSortDescending()
Defaults to false.

Returns:
whether this Column should be sorted in descending order

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

dump

public void dump()
Print information about the structure of the Column to stdout.


dump

public void dump(PrintStream ps)
Print information to PrintStream.

Parameters:
ps - PrintStream to dump to

eqClause

public String eqClause(Object raw)
Parameters:
raw - An object with an equivalent SQL type
Returns:
the SQL euals clause that would capture equality with the raw

selectionWhereEq

public Enumeration<Persistent> selectionWhereEq(Object raw)
Get rows where column equal to value.

Parameters:
raw - a raw value such as a String
Returns:
an enumeration of Persistents

firstWhereEq

public Persistent firstWhereEq(Object raw)
Return the first one found or null if not found.

Parameters:
raw - Object of correct type for this Column
Returns:
the first one found based upon default ordering

cachedSelectionWhereEq

public CachedSelection cachedSelectionWhereEq(Object raw)
Create a new CachedSelection of objects equal to this raw parameter.

Parameters:
raw - Object of correct type for this Column
Returns:
a new CachedSelection of objects equal to raw.

getRaw

public abstract Object getRaw(Persistent g)
                       throws AccessPoemException
Retrieves the field value, with locking, for this Column.

Parameters:
g - the Persistent to read
Returns:
the Object itself
Throws:
AccessPoemException - if the current AccessToken does not confer read access rights

getRaw_unsafe

public abstract Object getRaw_unsafe(Persistent g)
Retrieves the field value, without locking, for this Column.

Parameters:
g - the Persistent to read
Returns:
the Object without checks

setRaw

public abstract void setRaw(Persistent g,
                            Object raw)
                     throws AccessPoemException,
                            ValidationPoemException
Sets the field value, with locking, for this Column.

Parameters:
g - the Persistent to modify
raw - the value to set the field to
Throws:
AccessPoemException - if the current AccessToken does not confer write access rights
ValidationPoemException - if the raw value is not valid

setRaw_unsafe

public abstract void setRaw_unsafe(Persistent g,
                                   Object raw)
Sets the field value, without locking, for this Column.

Parameters:
g - the Persistent to modify
raw - the value to set the field to

getCooked

public abstract Object getCooked(Persistent g)
                          throws AccessPoemException,
                                 PoemException
Retrieves the field value, with locking and access control for this Column.

Parameters:
g - the Persistent to modify
Returns:
either the value or what is represented by the value
Throws:
AccessPoemException - if the current AccessToken does not confer read access rights
PoemException - if any problem occurs

setCooked

public abstract void setCooked(Persistent g,
                               Object cooked)
                        throws AccessPoemException,
                               ValidationPoemException
Sets the field value, with locking, access control and validation for this Column.

Parameters:
g - the Persistent to modify
cooked - the value to set
Throws:
AccessPoemException - if the current AccessToken does not confer read access rights
ValidationPoemException - if the value is not valid

asField

public abstract Field asField(Persistent g)
Return a Field of the same type as this Column from the Persistent.

Parameters:
g - the Persistent
Returns:
a Field

asEmptyField

public Field asEmptyField()
Return a Field of the same type as this Column with default attributes.

Returns:
the empty Field

setRawString

public void setRawString(Persistent g,
                         String rawString)
Set the value from its String representation, if possible. Throws SettingException if the String value cannot be converted to the appropriate type

Parameters:
g - the Persistent to alter
rawString - the String representation of the value to set

referencesTo

public Enumeration<Persistent> referencesTo(Persistent object)
Return an Enumeration of Persistents from the Table this column refers to, if this is a reference column, otherwise the Empty Enumeration.

Parameters:
object - A persistent of the type referred to by this column
Returns:
an Enumeration Persistents referencing this Column of the Persistent

ensure

public Persistent ensure(Persistent orCreate)
Ensures a row exists for which this column matches when compared with the given Persistent.

The given object is used to create a new row if necessary, in which case it will be assigned the next troid and cached.

Parameters:
orCreate - the Persistent to use as criteria and ensure
Returns:
the existing or newly created Persistent

firstFree

public int firstFree(String whereClause)
Find the next free value in an Integer column. This is not used in Melati, but is used in Bibliomania. Throws AppBugPoemException if this Column is not an Integer column.

Parameters:
whereClause -
Returns:
the incremented value
Since:
04/05/2000


Copyright © 2000-2010 PanEris. All Rights Reserved.