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, UjoTextable, ColumnWrapper, Ujo

public final class MetaColumn
extends MetaRelation2Many
implements ColumnWrapper

Database column metadata

Author:
Pavel Ponec
See Also:
Serialized Form

Field Summary
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 Key<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 Key<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_PROPERTY
 
Constructor Summary
MetaColumn()
           
MetaColumn(ITypeService converter)
           
MetaColumn(MetaTable table, Key tableProperty, MetaColumn param)
           
 
Method Summary
 String getAliasName()
          Returns an ALIAS of table and COLUMN name.
 String getComment()
          Get a Comment from meta-model annotation.
 String getConstraintName()
          Returns a constraint name for case a foreigh key
 ITypeService getConverter()
          Returna 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 ling to a column neta-model
 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 property value from a table
 boolean hasDefaultValue()
          Has the property a default value (not null) ?
 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 property 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 property value from a table
 String toString()
          Returns a TABLE and COLUMN names.
 
Methods inherited from class org.ujorm.orm.metaModel.MetaRelation2Many
getHandler, getProperty, getTable, getTableClass, getValue, isTypeOf
 
Methods inherited from class org.ujorm.orm.AbstractMetaModel
get, changeDefault, checkReadOnly, isFilled, isFilled, readAuthorization, readOnly, setReadOnly, writeValue
 
Methods inherited from class org.ujorm.extensions.AbstractUjo
newCamelFactory, newFactory, readValue
 
Methods inherited from class org.ujorm.extensions.SuperAbstractUjo
clone, equals, init, init, readKeys, readProperties, readUjoManager, readValueString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujorm.orm.ColumnWrapper
getTable
 

Field Detail

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 Key<MetaColumn,String> INDEX
A name of the non-unique database index for the column, where the same index can contain more columns. If a single column of the index is marked as unique, so the entire index will be unique.


UNIQUE_INDEX

public static final Key<MetaColumn,String> UNIQUE_INDEX
A name of the unique database index for the column, where the same index can contain more columns. 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 property is undefined then the method returns value -1.

getPrecision

public int getPrecision()
Returns the db column precision.

Returns:
If property 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 property value from a table


setValue

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


getType

public Class getType()
Returns a Java Class of value


toString

public String toString()
Returns a TABLE and COLUMN names.

Overrides:
toString in class MetaRelation2Many

getFullName

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


getAliasName

public String getAliasName()
Returns an ALIAS of table and COLUMN name.


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 property 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 property type void?


getConstraintName

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


getConverter

public ITypeService getConverter()
Returna not null converter


getDbTypeClass

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


getModel

public MetaColumn getModel()
Get ling to a column neta-model

Specified by:
getModel in interface ColumnWrapper


Copyright © 2012. All Rights Reserved.