Top Description Fields Constructors Methods
org.eclipse.persistence.tools.schemaframework

public Class FieldDefinition

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Imports
java.io.IOException, .Serializable, .Writer, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.internal.databaseaccess.DatabasePlatform, .FieldTypeDefinition, org.eclipse.persistence.internal.helper.DatabaseField, .Helper, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.logging.SessionLog

Purpose: Define a database field definition for creation within a table. This differs from DatabaseField in that it is used only table creation not a runtime.

Responsibilities:

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected DatabaseField
field

DatabaseField stores the field name with case and delimiting information.

protected String
protected boolean
protected boolean
protected boolean
protected String
protected boolean
protected int
protected int
protected Class<?>
type

Java type class for the field.

protected String
typeDefinition

Database-specific complete type definition like "VARCHAR2(50) UNIQUE NOT NULL".

protected String
typeName

Generic database type name for the field, which can be used instead of the Java class 'type'.

Constructor Summary

AccessConstructor and Description
public
public
FieldDefinition(String name, Class<?> type)

public
FieldDefinition(String name, Class<?> type, int size)

public
FieldDefinition(String name, Class<?> type, int size, int subSize)

public
FieldDefinition(String name, String typeName)

Method Summary

Modifier and TypeMethod and Description
public void
appendDBString(final Writer
Target writer where to write field definition string.
writer
,
final AbstractSession
Current session context.
session
,
final TableDefinition
Database table being processed.
table
)

INTERNAL: Append the database field definition string to the table creation statement.

public void
appendTypeString(final Writer
Target writer where to write field definition string.
writer
,
final AbstractSession
Current session context.
session
)

INTERNAL: Append the database field definition string to the type creation statement.

public Object
clone()

Overrides java.lang.Object.clone.

PUBLIC:
public String
getAdditional()

PUBLIC: Return any additional information about this field to be given when the table is created.

public String
getConstraint()

PUBLIC: Return any constraint of this field.

public DatabaseField
getDatabaseField()

INTERNAL: Return the databasefield.

public String
public String
getName()

PUBLIC: Return the name of the field.

public int
getSize()

PUBLIC: Return the size of the field, this is only required for some field types.

public int
getSubSize()

PUBLIC: Return the sub-size of the field.

public Class<?>
getType()

PUBLIC: Return the type of the field.

public String
getTypeDefinition()

PUBLIC: Return the type definition of the field.

public String
getTypeName()

PUBLIC: Return the type name of the field.

public boolean
isIdentity()

PUBLIC: Answer whether the receiver is an identity field.

public boolean
isPrimaryKey()

PUBLIC: Answer whether the receiver is a primary key.

public boolean
isUnique()

PUBLIC: Answer whether the receiver is a unique constraint field.

public void
setAdditional(String string)

PUBLIC: Set any additional information about this field to be given when the table is created.

public void
setConstraint(String string)

PUBLIC: Set any constraint of this field.

public void
setDatabaseField(DatabaseField field)

INTERNAL: Set the DatabaseField that is associated to this FieldDefinition object.

public void
setForeignKeyFieldName(String foreignKeyFieldName)

public void
setIsIdentity(boolean value)

PUBLIC: Set whether the receiver is an identity field.

public void
setIsPrimaryKey(boolean value)

PUBLIC: Set whether the receiver is a primary key.

public void
setName(String name)

PUBLIC: Set the name of the field.

public void
setShouldAllowNull(boolean value)

PUBLIC: Set whether the receiver should allow null values.

public void
setSize(int size)

PUBLIC: Set the size of the field, this is only required for some field types.

public void
setSubSize(int subSize)

PUBLIC: Set the sub-size of the field.

public void
setType(Class<?> type)

PUBLIC: Set the type of the field.

public void
setTypeDefinition(String typeDefinition)

PUBLIC: Set the type definition of the field.

public void
setTypeName(String typeName)

PUBLIC: Set the type name of the field.

public void
setUnique(boolean value)

PUBLIC: Set whether the receiver is a unique constraint field.

public boolean
shouldAllowNull()

PUBLIC: Return whether the receiver should allow null values.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

additionalback to summary
protected String additional
constraintback to summary
protected String constraint
fieldback to summary
protected DatabaseField field

DatabaseField stores the field name with case and delimiting information. Used if the field needs to be found in the table metadata, for extending tables. if null, name is used for comparison to determine if this field already exists.

foreignKeyFieldNameback to summary
protected String foreignKeyFieldName
isIdentityback to summary
protected boolean isIdentity
isPrimaryKeyback to summary
protected boolean isPrimaryKey
isUniqueback to summary
protected boolean isUnique
nameback to summary
protected String name
shouldAllowNullback to summary
protected boolean shouldAllowNull
sizeback to summary
protected int size
subSizeback to summary
protected int subSize
typeback to summary
protected Class<?> type

Java type class for the field. Particular database type is generated based on platform from this.

typeDefinitionback to summary
protected String typeDefinition

Database-specific complete type definition like "VARCHAR2(50) UNIQUE NOT NULL". If this is given, other additional type constraint fields(size, unique, null) are meaningless.

typeNameback to summary
protected String typeName

Generic database type name for the field, which can be used instead of the Java class 'type'. This is translated to a particular database type based on platform.

Constructor Detail

FieldDefinitionback to summary
public FieldDefinition()
FieldDefinitionback to summary
public FieldDefinition(String name, Class<?> type)
FieldDefinitionback to summary
public FieldDefinition(String name, Class<?> type, int size)
FieldDefinitionback to summary
public FieldDefinition(String name, Class<?> type, int size, int subSize)
FieldDefinitionback to summary
public FieldDefinition(String name, String typeName)

Method Detail

appendDBStringback to summary
public void appendDBString(final Writer writer, final AbstractSession session, final TableDefinition table) throws ValidationException

INTERNAL: Append the database field definition string to the table creation statement.

Parameters
writer:Writer

Target writer where to write field definition string.

session:AbstractSession

Current session context.

table:TableDefinition

Database table being processed.

Exceptions
ValidationException:
When invalid or inconsistent data were found.
appendTypeStringback to summary
public void appendTypeString(final Writer writer, final AbstractSession session) throws ValidationException

INTERNAL: Append the database field definition string to the type creation statement. Types do not support constraints.

Parameters
writer:Writer

Target writer where to write field definition string.

session:AbstractSession

Current session context.

Exceptions
ValidationException:
When invalid or inconsistent data were found.
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

PUBLIC:

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
getAdditionalback to summary
public String getAdditional()

PUBLIC: Return any additional information about this field to be given when the table is created.

getConstraintback to summary
public String getConstraint()

PUBLIC: Return any constraint of this field. i.e. "BETWEEN 0 AND 1000000".

getDatabaseFieldback to summary
public DatabaseField getDatabaseField()

INTERNAL: Return the databasefield.

getForeignKeyFieldNameback to summary
public String getForeignKeyFieldName()
getNameback to summary
public String getName()

PUBLIC: Return the name of the field.

getSizeback to summary
public int getSize()

PUBLIC: Return the size of the field, this is only required for some field types.

getSubSizeback to summary
public int getSubSize()

PUBLIC: Return the sub-size of the field. This is used as the decimal precision for numeric values only.

getTypeback to summary
public Class<?> getType()

PUBLIC: Return the type of the field. This should be set to a java class, such as String.class, Integer.class or Date.class.

getTypeDefinitionback to summary
public String getTypeDefinition()

PUBLIC: Return the type definition of the field. This is database-specific complete type definition like "VARCHAR2(50) UNIQUE NOT NULL". If this is given, other additional type constraint fields(size, unique, null) are meaningless.

getTypeNameback to summary
public String getTypeName()

PUBLIC: Return the type name of the field. This is the generic database type name, which can be used instead of the Java class 'type'. This is translated to a particular database type based on platform.

isIdentityback to summary
public boolean isIdentity()

PUBLIC: Answer whether the receiver is an identity field. Identity fields are Sybase specific, they insure that on insert a unique sequential value is stored in the row.

isPrimaryKeyback to summary
public boolean isPrimaryKey()

PUBLIC: Answer whether the receiver is a primary key. If the table has a multipart primary key this should be set in each field.

isUniqueback to summary
public boolean isUnique()

PUBLIC: Answer whether the receiver is a unique constraint field.

setAdditionalback to summary
public void setAdditional(String string)

PUBLIC: Set any additional information about this field to be given when the table is created.

setConstraintback to summary
public void setConstraint(String string)

PUBLIC: Set any constraint of this field. i.e. "BETWEEN 0 AND 1000000".

setDatabaseFieldback to summary
public void setDatabaseField(DatabaseField field)

INTERNAL: Set the DatabaseField that is associated to this FieldDefinition object. The databaesField is used when extending tables to see if this field already exists.

setForeignKeyFieldNameback to summary
public void setForeignKeyFieldName(String foreignKeyFieldName)
setIsIdentityback to summary
public void setIsIdentity(boolean value)

PUBLIC: Set whether the receiver is an identity field. Identity fields are Sybase specific, they insure that on insert a unique sequential value is stored in the row.

setIsPrimaryKeyback to summary
public void setIsPrimaryKey(boolean value)

PUBLIC: Set whether the receiver is a primary key. If the table has a multipart primary key this should be set in each field.

setNameback to summary
public void setName(String name)

PUBLIC: Set the name of the field.

setShouldAllowNullback to summary
public void setShouldAllowNull(boolean value)

PUBLIC: Set whether the receiver should allow null values.

setSizeback to summary
public void setSize(int size)

PUBLIC: Set the size of the field, this is only required for some field types.

setSubSizeback to summary
public void setSubSize(int subSize)

PUBLIC: Set the sub-size of the field. This is used as the decimal precision for numeric values only.

setTypeback to summary
public void setType(Class<?> type)

PUBLIC: Set the type of the field. This should be set to a java class, such as String.class, Integer.class or Date.class.

setTypeDefinitionback to summary
public void setTypeDefinition(String typeDefinition)

PUBLIC: Set the type definition of the field. This is database-specific complete type definition like "VARCHAR2(50) UNIQUE NOT NULL". If this is given, other additional type constraint fields(size, unique, null) are meaningless.

setTypeNameback to summary
public void setTypeName(String typeName)

PUBLIC: Set the type name of the field. This is the generic database type name, which can be used instead of the Java class 'type'. This is translated to a particular database type based on platform.

setUniqueback to summary
public void setUnique(boolean value)

PUBLIC: Set whether the receiver is a unique constraint field.

shouldAllowNullback to summary
public boolean shouldAllowNull()

PUBLIC: Return whether the receiver should allow null values.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override