org.apache.torque.map
Class ColumnMap

java.lang.Object
  extended by org.apache.torque.map.ColumnMap
All Implemented Interfaces:
java.io.Serializable

public class ColumnMap
extends java.lang.Object
implements java.io.Serializable

ColumnMap is used to model a column of a table in a database.

Note that this information should be set via the

MapBuilder class and not changed by applications. The set methods are only public because this class needs them.

Version:
$Id: ColumnMap.java 473821 2006-11-11 22:37:25Z tv $
Author:
John D. McNally, Greg Monroe
See Also:
Serialized Form

Constructor Summary
ColumnMap(java.lang.String name, TableMap containingTable)
          Constructor.
 
Method Summary
 void addInheritanceMap(InheritanceMap map)
          Add an associated inheritance mapping.
 java.lang.String getColumnName()
          Get the name of a column.
 java.lang.String getDefault()
          A string representing the default value defined for this column.
 java.lang.String getDescription()
          Returns the column description info.
 java.lang.String getFullyQualifiedName()
          Get the table name + column name.
 java.lang.String getInheritance()
          Gets the inheritance type used.
 InheritanceMap getInheritanceMap(java.lang.String key)
          Get the inheritance map with the specified key.
 InheritanceMap[] getInheritanceMaps()
          Get the inheritance information associated with this column,
 java.lang.String getInputValidator()
          Returns the input validator class name.
 java.lang.String getJavaName()
          Gets the Java Name for this column as defined in XML or created by generator code.
 java.lang.String getJavaNamingMethod()
          Returns the Java naming method for this column.
 java.lang.String getJavaType()
          Returns the java type of this column.
 int getPosition()
          Returns the position (one based) of this column in the table.
 java.lang.String getRelatedColumnName()
          Get the column name that this column is related to.
 java.lang.String getRelatedName()
          Get the table.column that this column is related to.
 java.lang.String getRelatedTableName()
          Get the table name that this column is related to.
 int getScale()
          Gets the scale set for this column (if any) as set in the XML database definition.
 int getSize()
          The "precision" value from the XML size="<precision>[,<scale>]" attribute.
 TableMap getTable()
          Returns the map for the table this column belongs to.
 java.lang.String getTableName()
          Get the name of the table this column is in.
 java.lang.String getTorqueType()
          Get the name of the Torque type of this column.
 java.lang.Object getType()
          Get the type of this column.
 boolean isAutoIncrement()
          Returns whether this column is an autoincrement column.
 boolean isForeignKey()
          Is this column a foreign key?
 boolean isNotNull()
          Is null value allowed ?
 boolean isPk()
          Returns whether this column is a primary key.
 boolean isPrimaryKey()
          Is this column a primary key?
 boolean isProtected()
          Returns whether getters and setters are generated with the access modifier "protected" rather than "public".
 boolean isUseInheritance()
          Returns whether this column uses inheritance subclasses.
 boolean isUsePrimitive()
          Returns whether this colum uses primitive values rather than objects.
protected  java.lang.String normalizeName(java.lang.String name)
          Makes sure that the column names don't include table prefixes.
 void setAutoIncrement(boolean autoIncrement)
          Sets whether this column is an autoincrement column.
 void setDefault(java.lang.String defaultValue)
          Sets the default value for this column.
 void setDescription(java.lang.String description)
          Sets the description for this column.
 void setForeignKey(java.lang.String fullyQualifiedName)
          Set the foreign key for this column.
 void setForeignKey(java.lang.String tableName, java.lang.String columnName)
          Set the foreign key for this column.
 void setInheritance(java.lang.String inheritanceType)
          Sets the inheritance type.
 void setInputValidator(java.lang.String inputValidator)
          Sets the input validator class name.
 void setJavaName(java.lang.String name)
          Sets the Java Name for this column.
 void setJavaNamingMethod(java.lang.String javaNamingMethod)
          Sets the java naming method for this column.
 void setJavaType(java.lang.String javaType)
          Sets the java type of this column.
 void setNotNull(boolean nn)
          Set if this column may be null.
 void setPk(boolean pk)
          Sets whether this column is a primary key.
 void setPosition(int position)
          Sets the position (one based) of this column in the table.
 void setPrimaryKey(boolean pk)
          Set if this column is a primary key or not.
 void setProtected(boolean isProtected)
          Sets whether getters and setters should be generated with the access modifier "protected" rather than "public".
 void setScale(int scale)
           
 void setSize(int size)
          Set the size of this column.
 void setTorqueType(java.lang.String torqueType)
          Set the Torque type of this column.
 void setType(java.lang.Object type)
          Set the type of this column.
 void setUseInheritance(boolean useInheritance)
          Sets whether this column uses inheritance subclasses.
 void setUsePrimitive(boolean usePrimitive)
          Sets whether this colum uses primitive values rather than objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnMap

public ColumnMap(java.lang.String name,
                 TableMap containingTable)
Constructor.

Parameters:
name - The name of the column.
containingTable - TableMap of the table this column is in.
Method Detail

normalizeName

protected java.lang.String normalizeName(java.lang.String name)
Makes sure that the column names don't include table prefixes. E.g., SCARAB_PROJECT.PROJECT_ID should be PROJECT_ID.

Parameters:
name - The name to check
Returns:
The corrected name if needed or the same name if not.

getColumnName

public java.lang.String getColumnName()
Get the name of a column.

Returns:
A String with the column name.

getFullyQualifiedName

public java.lang.String getFullyQualifiedName()
Get the table name + column name.

Returns:
A String with the full column name.

getTableName

public java.lang.String getTableName()
Get the name of the table this column is in.

Returns:
A String with the table name.

setType

public void setType(java.lang.Object type)
Set the type of this column.

Parameters:
type - An Object specifying the type.

setTorqueType

public void setTorqueType(java.lang.String torqueType)
Set the Torque type of this column.

Parameters:
torqueType - the Torque type of the column.

setSize

public void setSize(int size)
Set the size of this column.

Parameters:
size - An int specifying the size.

setPrimaryKey

public void setPrimaryKey(boolean pk)
Set if this column is a primary key or not.

Parameters:
pk - True if column is a primary key.

setNotNull

public void setNotNull(boolean nn)
Set if this column may be null.

Parameters:
nn - True if column may be null.

setForeignKey

public void setForeignKey(java.lang.String fullyQualifiedName)
Set the foreign key for this column.

Parameters:
fullyQualifiedName - The name of the table.column that is foreign.

setForeignKey

public void setForeignKey(java.lang.String tableName,
                          java.lang.String columnName)
Set the foreign key for this column.

Parameters:
tableName - The name of the table that is foreign.
columnName - The name of the column that is foreign.

getType

public java.lang.Object getType()
Get the type of this column. Note that if usePrimitive is true, this may need to be converted.

Returns:
An Object specifying the type.

getTorqueType

public java.lang.String getTorqueType()
Get the name of the Torque type of this column.

Returns:
The name of the Torque type of this column.

getSize

public int getSize()
The "precision" value from the XML size="<precision>[,<scale>]" attribute. Where [,<scale>] is optional. If the size attribute has not been set in the XML, it will return 0.

Note that the size="P,S" format should be replaced with size="P" scale="S".

Returns:
An int specifying the size.

isPrimaryKey

public boolean isPrimaryKey()
Is this column a primary key?

Returns:
True if column is a primary key.

isNotNull

public boolean isNotNull()
Is null value allowed ?

Returns:
True if column may be null.

isForeignKey

public boolean isForeignKey()
Is this column a foreign key?

Returns:
True if column is a foreign key.

getRelatedName

public java.lang.String getRelatedName()
Get the table.column that this column is related to.

Returns:
A String with the full name for the related column.

getRelatedTableName

public java.lang.String getRelatedTableName()
Get the table name that this column is related to.

Returns:
A String with the name for the related table.

getRelatedColumnName

public java.lang.String getRelatedColumnName()
Get the column name that this column is related to.

Returns:
A String with the name for the related column.

getScale

public int getScale()
Gets the scale set for this column (if any) as set in the XML database definition. E.g., the value of the scale attribute or the scale portion of a size="P,S" attribute. (Note: size="P,S" format is being deprecated!).

Returns:
Returns the scale.

setScale

public void setScale(int scale)
Parameters:
scale - The scale to set.

getJavaName

public java.lang.String getJavaName()
Gets the Java Name for this column as defined in XML or created by generator code.

Returns:
the Java Name.

setJavaName

public void setJavaName(java.lang.String name)
Sets the Java Name for this column.

Parameters:
name - the Java Name.

isAutoIncrement

public boolean isAutoIncrement()
Returns whether this column is an autoincrement column.

Returns:
true if this column is an autoIncrement column, false otherwise.

setAutoIncrement

public void setAutoIncrement(boolean autoIncrement)
Sets whether this column is an autoincrement column.

Parameters:
autoIncrement - whether this colimn is an autoincrement column.

getDefault

public java.lang.String getDefault()
A string representing the default value defined for this column.

Returns:
The default value of this column, if any.

setDefault

public void setDefault(java.lang.String defaultValue)
Sets the default value for this column.

Parameters:
defaultValue - The defaultValue to set.

getDescription

public java.lang.String getDescription()
Returns the column description info.

Returns:
the description, if any.

setDescription

public void setDescription(java.lang.String description)
Sets the description for this column.

Parameters:
description - The description to set.

getInheritanceMaps

public InheritanceMap[] getInheritanceMaps()
Get the inheritance information associated with this column,

Returns:
Returns an array of associated inheritanceMap. The array is in XML order.

addInheritanceMap

public void addInheritanceMap(InheritanceMap map)
Add an associated inheritance mapping.

Parameters:
map - The inheritanceMap to associate with this column.

getInheritance

public java.lang.String getInheritance()
Gets the inheritance type used.

Returns:
the inheritance type used.

setInheritance

public void setInheritance(java.lang.String inheritanceType)
Sets the inheritance type.

Parameters:
inheritanceType - The inheritance type to set.

getInputValidator

public java.lang.String getInputValidator()
Returns the input validator class name. (This property is in the DTD, but currently not used by Torque?)

Returns:
Returns the inputValidator.

setInputValidator

public void setInputValidator(java.lang.String inputValidator)
Sets the input validator class name.

Parameters:
inputValidator - The inputValidator to set.

isProtected

public boolean isProtected()
Returns whether getters and setters are generated with the access modifier "protected" rather than "public".

Returns:
whether the accessors should be protected rather than public.

setProtected

public void setProtected(boolean isProtected)
Sets whether getters and setters should be generated with the access modifier "protected" rather than "public".

Parameters:
isProtected - whether getters and setters for this column are protected.

isPk

public boolean isPk()
Returns whether this column is a primary key.

Returns:
whether this column is a primary key.

setPk

public void setPk(boolean pk)
Sets whether this column is a primary key.

Parameters:
pk - whether this column is a primary key.

isUseInheritance

public boolean isUseInheritance()
Returns whether this column uses inheritance subclasses.

Returns:
true if inheritance subclasses are used, false otherwise.

setUseInheritance

public void setUseInheritance(boolean useInheritance)
Sets whether this column uses inheritance subclasses.

Parameters:
useInheritance - whether this column uses Inheritance subclasses.

getInheritanceMap

public InheritanceMap getInheritanceMap(java.lang.String key)
Get the inheritance map with the specified key.

Parameters:
key - the key of the inheritance map.
Returns:
the inheritance map with the specified key, or null if no inheritance map with the specified key exists in this column.

isUsePrimitive

public boolean isUsePrimitive()
Returns whether this colum uses primitive values rather than objects.

Returns:
true if this colum uses primitive values, false if it uses objects.

setUsePrimitive

public void setUsePrimitive(boolean usePrimitive)
Sets whether this colum uses primitive values rather than objects.

Parameters:
usePrimitive - whether primitive objects are used rather than objects.

getJavaNamingMethod

public java.lang.String getJavaNamingMethod()
Returns the Java naming method for this column.

Returns:
the javaNamingMethod for this column.

setJavaNamingMethod

public void setJavaNamingMethod(java.lang.String javaNamingMethod)
Sets the java naming method for this column.

Parameters:
javaNamingMethod - The javaNamingMethod to set.

getTable

public TableMap getTable()
Returns the map for the table this column belongs to.

Returns:
the table map for this column.

getPosition

public int getPosition()
Returns the position (one based) of this column in the table. XML order is preserved.

Returns:
The position of this column, one-based.

setPosition

public void setPosition(int position)
Sets the position (one based) of this column in the table.

Parameters:
position - The position to set.

getJavaType

public java.lang.String getJavaType()
Returns the java type of this column.

Returns:
the javaType.

setJavaType

public void setJavaType(java.lang.String javaType)
Sets the java type of this column.

Parameters:
javaType - The javaType to set.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.