org.ujorm.orm.metaModel
Class MetaColumn

java.lang.Object
  extended by org.ujorm.extensions.SuperAbstractUjo
      extended by org.ujorm.extensions.AbstractUjo
          extended by org.ujorm.orm.AbstractMetaModel
              extended by org.ujorm.orm.metaModel.MetaRelation2Many
                  extended by org.ujorm.orm.metaModel.MetaColumn
All Implemented Interfaces:
Serializable, UjoCloneable, UjoLockable, UjoTextable, ColumnWrapper, Ujo

public final class MetaColumn
extends MetaRelation2Many
implements ColumnWrapper

Database column meta-data

See Also:
Serialized Form

Field Summary
static String AUTO_INDEX_NAME
          A constant for an auto index name from the SqlNameProvider generator
static Key<MetaColumn,String> COMMENT
          Comment of the database column
static Key<MetaColumn,String> CONSTRAINT_NAME
          A name of the constraint for the case a foreign key
static Key<MetaColumn,Class<? extends ITypeService>> CONVERTER
          Convert, save and read application data from/to the database
static Key<MetaColumn,DbType> DB_TYPE
          Database Type
static Key<MetaColumn,String> DEFAULT_VALUE
          DB Default value
static ListKey<MetaColumn,String> INDEX
          A name of the non-unique database index for the column, where the same index can contain more columns.
static Key<MetaColumn,Boolean> MANDATORY
          Column NOT-NULL
static Key<MetaColumn,Integer> MAX_LENGTH
          Column value length
static Key<MetaColumn,Integer> PRECISION
          Column value precision
static Key<MetaColumn,Boolean> PRIMARY_KEY
          DB primary key
static ListKey<MetaColumn,String> UNIQUE_INDEX
          A name of the unique database index for the column, where the same index can contain more columns.
 
Fields inherited from class org.ujorm.orm.metaModel.MetaRelation2Many
ID, NAME, TABLE, TABLE_KEY
 
Constructor Summary
MetaColumn()
           
MetaColumn(ITypeService converter)
           
MetaColumn(MetaTable table, Key tableProperty, MetaColumn param)
           
 
Method Summary
 ColumnWrapper addTableAlias(String alias)
          Create new object column for the new alias
 String getColumnAlias()
          Returns a full SQL column alias name by sample: "TABLE_ALIAS"."ORIG_COLUMN"
 String getComment()
          Get a Comment from meta-model annotation.
 String getConstraintName()
          Returns a constraint name for case a foreigh key
 ITypeService getConverter()
          Returns not null converter
 Class getDbTypeClass()
          Returns a native database code for a DDL statements
 Class getDialectClass()
          Returns a SQL dialect class from a related Database
 String getDialectName()
          Returns a SQL dialect class from a related Database
 String getForeignColumnName(int index)
          Returns a name of foreign column by index
 List<MetaColumn> getForeignColumns()
          Returns an original foreign columns in case a foreign column.
 MetaTable getForeignTable()
          Returns an original foreign columns in case a foreign column.
 String getFullName()
          Returns a DB, TABLE and COLUMN name
 Object getJdbcFriendlyDefaultValue()
          Returns a default value in a JDBC friendly type.
 int getMaxLength()
          Returns a maximal db column length in the database.
 MetaColumn getModel()
          Get link to a column meta-model
 String getName()
          Returns a column name
 int getPrecision()
          Returns the db column precision.
 Class getType()
          Returns a Java Class of value
 char getTypeCode()
          A TypeCode
 Object getValue(OrmUjo bo)
          Returns a key value from a table
 boolean hasDefaultValue()
          Has the key a default value (not null) ? If the default value is an empty String than method returns false.
 void initTypeCode()
          Initialize a type code - for an internal use only.
 boolean isColumn()
          It is a DB column (either a value of a foreign key), not a relation to many.
 boolean isCommented()
          Has the instance assigned a non empty comment?
 boolean isForeignKey()
          Is it a Foreign Key ?
 boolean isMandatory()
          Returns true if the related db column is NOT NULL.
 boolean isPrimaryKey()
          Is it a Primary Key?
 boolean isVoid()
          Is the related key type void?
 void printForeignColumnFullName(int index, Appendable out)
          Print a full 'alias' name of foreign column by index
 void setValue(Ujo bo, Object value)
          Returns a key value from a table
 
Methods inherited from class org.ujorm.orm.metaModel.MetaRelation2Many
equals, getHandler, getId, getKey, getTable, getTableAlias, getTableClass, getValue, hashCode, isCompositeKey, isTypeOf, toString
 
Methods inherited from class org.ujorm.orm.AbstractMetaModel
changeDefault, checkReadOnly, clearReadOnly, get, lock, readAuthorization, readOnly, setReadOnly, writeValue
 
Methods inherited from class org.ujorm.extensions.AbstractUjo
newCamelFactory, newFactory, readValue
 
Methods inherited from class org.ujorm.extensions.SuperAbstractUjo
clone, init, init, readKeys, readUjoManager, readValueString, writeValueString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujorm.orm.ColumnWrapper
equals, getKey, getTableAlias, isCompositeKey
 
Methods inherited from interface org.ujorm.Ujo
readKeys, readValue
 

Field Detail

AUTO_INDEX_NAME

public static final String AUTO_INDEX_NAME
A constant for an auto index name from the SqlNameProvider generator

See Also:
SqlNameProvider, Constant Field Values

PRIMARY_KEY

public static final Key<MetaColumn,Boolean> PRIMARY_KEY
DB primary key


DB_TYPE

public static final Key<MetaColumn,DbType> DB_TYPE
Database Type


MANDATORY

public static final Key<MetaColumn,Boolean> MANDATORY
Column NOT-NULL


MAX_LENGTH

public static final Key<MetaColumn,Integer> MAX_LENGTH
Column value length


PRECISION

public static final Key<MetaColumn,Integer> PRECISION
Column value precision


DEFAULT_VALUE

public static final Key<MetaColumn,String> DEFAULT_VALUE
DB Default value


INDEX

public static final ListKey<MetaColumn,String> INDEX
A name of the non-unique database index for the column, where the same index can contain more columns. If the name is "AUTO" then automatic name based on column setting is generated. If a single column of the index is marked as unique, so the entire index will be unique.


UNIQUE_INDEX

public static final ListKey<MetaColumn,String> UNIQUE_INDEX
A name of the unique database index for the column, where the same index can contain more columns. If the name is "AUTO" then automatic name based on column setting is generated. If a single column of the index is marked as unique, so the entire index will be unique.


CONSTRAINT_NAME

public static final Key<MetaColumn,String> CONSTRAINT_NAME
A name of the constraint for the case a foreign key


CONVERTER

public static final Key<MetaColumn,Class<? extends ITypeService>> CONVERTER
Convert, save and read application data from/to the database


COMMENT

public static final Key<MetaColumn,String> COMMENT
Comment of the database column

Constructor Detail

MetaColumn

public MetaColumn()

MetaColumn

public MetaColumn(ITypeService converter)

MetaColumn

public MetaColumn(MetaTable table,
                  Key tableProperty,
                  MetaColumn param)
Method Detail

isColumn

public boolean isColumn()
It is a DB column (either a value of a foreign key), not a relation to many.

Overrides:
isColumn in class MetaRelation2Many

isForeignKey

public boolean isForeignKey()
Is it a Foreign Key ?

Overrides:
isForeignKey in class MetaRelation2Many

isPrimaryKey

public boolean isPrimaryKey()
Is it a Primary Key?


isCommented

public boolean isCommented()
Has the instance assigned a non empty comment?


getComment

public String getComment()
Get a Comment from meta-model annotation.

See Also:
Comment

getMaxLength

public int getMaxLength()
Returns a maximal db column length in the database.

Returns:
If key is undefined then the method returns value -1.

getPrecision

public int getPrecision()
Returns the db column precision.

Returns:
If key is undefined then the method returns value -1.

isMandatory

public boolean isMandatory()
Returns true if the related db column is NOT NULL.


getForeignTable

public MetaTable getForeignTable()
Returns an original foreign columns in case a foreign column.


getForeignColumns

public List<MetaColumn> getForeignColumns()
Returns an original foreign columns in case a foreign column.


getForeignColumnName

public String getForeignColumnName(int index)
Returns a name of foreign column by index


getValue

public Object getValue(OrmUjo bo)
Returns a key value from a table


setValue

public void setValue(Ujo bo,
                     Object value)
Returns a key value from a table

Parameters:
ujo - Related Ujo object
value - A value to assign.

getType

public Class getType()
Returns a Java Class of value


getName

public final String getName()
Returns a column name

Specified by:
getName in interface ColumnWrapper

getFullName

public String getFullName()
Returns a DB, TABLE and COLUMN name


getColumnAlias

public String getColumnAlias()
Returns a full SQL column alias name by sample: "TABLE_ALIAS"."ORIG_COLUMN"


printForeignColumnFullName

public void printForeignColumnFullName(int index,
                                       Appendable out)
                                throws IOException
Print a full 'alias' name of foreign column by index

Throws:
IOException

getTypeCode

public char getTypeCode()
A TypeCode

See Also:
TypeService

hasDefaultValue

public boolean hasDefaultValue()
Has the key a default value (not null) ? If the default value is an empty String than method returns false.


getJdbcFriendlyDefaultValue

public Object getJdbcFriendlyDefaultValue()
Returns a default value in a JDBC friendly type. The real result type depends in an implementatin of the ITypeService. For example a Java Enumerator default value can return either the Integer or String type too.

See Also:
ITypeService

getDialectClass

public Class getDialectClass()
Returns a SQL dialect class from a related Database


getDialectName

public String getDialectName()
Returns a SQL dialect class from a related Database


initTypeCode

public void initTypeCode()
Initialize a type code - for an internal use only.


isVoid

public boolean isVoid()
Is the related key type void?


getConstraintName

public String getConstraintName()
Returns a constraint name for case a foreigh key


getConverter

public ITypeService getConverter()
Returns not null converter


getDbTypeClass

public Class getDbTypeClass()
Returns a native database code for a DDL statements


getModel

public MetaColumn getModel()
Get link to a column meta-model

Specified by:
getModel in interface ColumnWrapper

addTableAlias

public final ColumnWrapper addTableAlias(String alias)
Create new object column for the new alias

Parameters:
alias - Nullable alias value
Returns:
New instance of ColumnWrapper for a different alias.


Copyright 2013, Pavel Ponec