Class FieldDefinition
- java.lang.Object
-
- org.eclipse.persistence.tools.schemaframework.FieldDefinition
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class FieldDefinition extends java.lang.Object implements java.io.Serializable, java.lang.CloneablePurpose: 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:
- Store the name, java type, size and sub-size. The sizes are optional and the name of the java class is used for the type.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringadditionalprotected java.lang.Stringconstraintprotected org.eclipse.persistence.internal.helper.DatabaseFieldfieldDatabaseField stores the field name with case and delimiting information.protected java.lang.StringforeignKeyFieldNameprotected booleanisIdentityprotected booleanisPrimaryKeyprotected booleanisUniqueprotected java.lang.Stringnameprotected booleanshouldAllowNullprotected intsizeprotected intsubSizeprotected java.lang.ClasstypeJava type class for the field.protected java.lang.StringtypeDefinitionDatabase-specific complete type definition like "VARCHAR2(50) UNIQUE NOT NULL".protected java.lang.StringtypeNameGeneric database type name for the field, which can be used instead of the Java class 'type'.
-
Constructor Summary
Constructors Constructor Description FieldDefinition()FieldDefinition(java.lang.String name, java.lang.Class type)FieldDefinition(java.lang.String name, java.lang.Class type, int size)FieldDefinition(java.lang.String name, java.lang.Class type, int size, int subSize)FieldDefinition(java.lang.String name, java.lang.String typeName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendDBString(java.io.Writer writer, org.eclipse.persistence.internal.sessions.AbstractSession session, TableDefinition table)INTERNAL: Append the database field definition string to the table creation statement.voidappendTypeString(java.io.Writer writer, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Append the database field definition string to the type creation statement.java.lang.Objectclone()PUBLIC:java.lang.StringgetAdditional()PUBLIC: Return any additional information about this field to be given when the table is created.java.lang.StringgetConstraint()PUBLIC: Return any constraint of this field.org.eclipse.persistence.internal.helper.DatabaseFieldgetDatabaseField()INTERNAL: Return the databasefield.java.lang.StringgetForeignKeyFieldName()java.lang.StringgetName()PUBLIC: Return the name of the field.intgetSize()PUBLIC: Return the size of the field, this is only required for some field types.intgetSubSize()PUBLIC: Return the sub-size of the field.java.lang.ClassgetType()PUBLIC: Return the type of the field.java.lang.StringgetTypeDefinition()PUBLIC: Return the type definition of the field.java.lang.StringgetTypeName()PUBLIC: Return the type name of the field.booleanisIdentity()PUBLIC: Answer whether the receiver is an identity field.booleanisPrimaryKey()PUBLIC: Answer whether the receiver is a primary key.booleanisUnique()PUBLIC: Answer whether the receiver is a unique constraint field.voidsetAdditional(java.lang.String string)PUBLIC: Set any additional information about this field to be given when the table is created.voidsetConstraint(java.lang.String string)PUBLIC: Set any constraint of this field.voidsetDatabaseField(org.eclipse.persistence.internal.helper.DatabaseField field)INTERNAL: Set the DatabaseField that is associated to this FieldDefinition object.voidsetForeignKeyFieldName(java.lang.String foreignKeyFieldName)voidsetIsIdentity(boolean value)PUBLIC: Set whether the receiver is an identity field.voidsetIsPrimaryKey(boolean value)PUBLIC: Set whether the receiver is a primary key.voidsetName(java.lang.String name)PUBLIC: Set the name of the field.voidsetShouldAllowNull(boolean value)PUBLIC: Set whether the receiver should allow null values.voidsetSize(int size)PUBLIC: Set the size of the field, this is only required for some field types.voidsetSubSize(int subSize)PUBLIC: Set the sub-size of the field.voidsetType(java.lang.Class type)PUBLIC: Set the type of the field.voidsetTypeDefinition(java.lang.String typeDefinition)PUBLIC: Set the type definition of the field.voidsetTypeName(java.lang.String typeName)PUBLIC: Set the type name of the field.voidsetUnique(boolean value)PUBLIC: Set whether the receiver is a unique constraint field.booleanshouldAllowNull()PUBLIC: Return whether the receiver should allow null values.java.lang.StringtoString()
-
-
-
Field Detail
-
name
protected java.lang.String name
-
type
protected java.lang.Class type
Java type class for the field. Particular database type is generated based on platform from this.
-
typeName
protected java.lang.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.
-
field
protected org.eclipse.persistence.internal.helper.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.
-
typeDefinition
protected java.lang.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.
-
size
protected int size
-
subSize
protected int subSize
-
shouldAllowNull
protected boolean shouldAllowNull
-
isIdentity
protected boolean isIdentity
-
isPrimaryKey
protected boolean isPrimaryKey
-
isUnique
protected boolean isUnique
-
additional
protected java.lang.String additional
-
constraint
protected java.lang.String constraint
-
foreignKeyFieldName
protected java.lang.String foreignKeyFieldName
-
-
Constructor Detail
-
FieldDefinition
public FieldDefinition()
-
FieldDefinition
public FieldDefinition(java.lang.String name, java.lang.Class type)
-
FieldDefinition
public FieldDefinition(java.lang.String name, java.lang.Class type, int size)
-
FieldDefinition
public FieldDefinition(java.lang.String name, java.lang.Class type, int size, int subSize)
-
FieldDefinition
public FieldDefinition(java.lang.String name, java.lang.String typeName)
-
-
Method Detail
-
appendDBString
public void appendDBString(java.io.Writer writer, org.eclipse.persistence.internal.sessions.AbstractSession session, TableDefinition table) throws ValidationExceptionINTERNAL: Append the database field definition string to the table creation statement.- Parameters:
writer- Target writer where to write field definition string.session- Current session context.table- Database table being processed.- Throws:
ValidationException- When invalid or inconsistent data were found.
-
appendTypeString
public void appendTypeString(java.io.Writer writer, org.eclipse.persistence.internal.sessions.AbstractSession session) throws ValidationExceptionINTERNAL: Append the database field definition string to the type creation statement. Types do not support constraints.- Parameters:
writer- Target writer where to write field definition string.session- Current session context.- Throws:
ValidationException- When invalid or inconsistent data were found.
-
clone
public java.lang.Object clone()
PUBLIC:- Overrides:
clonein classjava.lang.Object
-
getAdditional
public java.lang.String getAdditional()
PUBLIC: Return any additional information about this field to be given when the table is created.
-
getConstraint
public java.lang.String getConstraint()
PUBLIC: Return any constraint of this field. i.e. "BETWEEN 0 AND 1000000".
-
getForeignKeyFieldName
public java.lang.String getForeignKeyFieldName()
-
getName
public java.lang.String getName()
PUBLIC: Return the name of the field.
-
getDatabaseField
public org.eclipse.persistence.internal.helper.DatabaseField getDatabaseField()
INTERNAL: Return the databasefield.
-
getSize
public int getSize()
PUBLIC: Return the size of the field, this is only required for some field types.
-
getSubSize
public int getSubSize()
PUBLIC: Return the sub-size of the field. This is used as the decimal precision for numeric values only.
-
getType
public java.lang.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.
-
getTypeName
public java.lang.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.
-
getTypeDefinition
public java.lang.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.
-
isIdentity
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.
-
isPrimaryKey
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.
-
isUnique
public boolean isUnique()
PUBLIC: Answer whether the receiver is a unique constraint field.
-
setAdditional
public void setAdditional(java.lang.String string)
PUBLIC: Set any additional information about this field to be given when the table is created.
-
setConstraint
public void setConstraint(java.lang.String string)
PUBLIC: Set any constraint of this field. i.e. "BETWEEN 0 AND 1000000".
-
setForeignKeyFieldName
public void setForeignKeyFieldName(java.lang.String foreignKeyFieldName)
-
setIsIdentity
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.
-
setIsPrimaryKey
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.
-
setName
public void setName(java.lang.String name)
PUBLIC: Set the name of the field.
-
setDatabaseField
public void setDatabaseField(org.eclipse.persistence.internal.helper.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.
-
setShouldAllowNull
public void setShouldAllowNull(boolean value)
PUBLIC: Set whether the receiver should allow null values.
-
setSize
public void setSize(int size)
PUBLIC: Set the size of the field, this is only required for some field types.
-
setSubSize
public void setSubSize(int subSize)
PUBLIC: Set the sub-size of the field. This is used as the decimal precision for numeric values only.
-
setType
public void setType(java.lang.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.
-
setTypeName
public void setTypeName(java.lang.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.
-
setTypeDefinition
public void setTypeDefinition(java.lang.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.
-
setUnique
public void setUnique(boolean value)
PUBLIC: Set whether the receiver is a unique constraint field.
-
shouldAllowNull
public boolean shouldAllowNull()
PUBLIC: Return whether the receiver should allow null values.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-