Methods Summary |
---|
public void | appendDBString(java.io.Writer writer, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.tools.schemaframework.TableDefinition table)INTERNAL:
Append the database field definition string to the table creation statement.
try {
writer.write(getName());
writer.write(" ");
if (getTypeDefinition() != null) { //apply user-defined complete type definition
writer.write(getTypeDefinition());
} else {
// compose type definition - type name, size, unique, identity, constraints...
FieldTypeDefinition fieldType;
if (getType() != null) { //translate Java 'type'
fieldType = session.getPlatform().getFieldTypeDefinition(getType());
if (fieldType == null) {
throw ValidationException.javaTypeIsNotAValidDatabaseType(getType());
}
} else if (getTypeName() != null) { //translate generic type name
Hashtable fieldTypes = session.getPlatform().getClassTypes();
Class type = (Class)fieldTypes.get(getTypeName());
if (type == null) { // if unknown type name, use as it is
fieldType = new FieldTypeDefinition(getTypeName());
} else {
fieldType = session.getPlatform().getFieldTypeDefinition(type);
if (fieldType == null) {
throw ValidationException.javaTypeIsNotAValidDatabaseType(type);
}
}
} else {
// both type and typeName is null
throw ValidationException.javaTypeIsNotAValidDatabaseType(null);
}
String qualifiedName = table.getFullName() + '." + getName();
session.getPlatform().printFieldTypeSize(writer, this, fieldType, session, qualifiedName);
session.getPlatform().printFieldUnique(writer, isUnique(), session, qualifiedName);
if (isIdentity()) {
String name = table.getFullName() + '." + getName();
session.getPlatform().printFieldIdentityClause(writer, session, name);
}
if (shouldAllowNull() && fieldType.shouldAllowNull()) {
session.getPlatform().printFieldNullClause(writer);
} else {
session.getPlatform().printFieldNotNullClause(writer);
}
if (getConstraint() != null) {
writer.write(" " + getConstraint());
}
if (getAdditional() != null) {
writer.write(" " + getAdditional());
}
}
} catch (IOException ioException) {
throw ValidationException.fileError(ioException);
}
|
public java.lang.Object | clone()PUBLIC:
try {
return super.clone();
} catch (CloneNotSupportedException impossible) {
return null;
}
|
public java.lang.String | getAdditional()PUBLIC:
Return any additional information about this field to be given when the table is created.
return additional;
|
public java.lang.String | getConstraint()PUBLIC:
Return any constraint of this field.
i.e. "BETWEEN 0 AND 1000000".
return constraint;
|
public java.lang.String | getForeignKeyFieldName()PUBLIC:
Return fully-qualified foreign key field name.
return foreignKeyFieldName;
|
public java.lang.String | getName()PUBLIC:
Return the name of the field.
return name;
|
public int | getSize()PUBLIC:
Return the size of the field, this is only required for some field types.
return size;
|
public int | getSubSize()PUBLIC:
Return the sub-size of the field.
This is used as the decimal precision for numeric values only.
return subSize;
|
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.
return type;
|
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.
return typeDefinition;
|
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.
return typeName;
|
public boolean | isIdentity()PUBLIC:
Answer whether the receiver is an identity field.
Identity fields are Sybase specific,
they insure that on insert a unique sequencial value is store in the row.
return isIdentity;
|
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.
return isPrimaryKey;
|
public boolean | isUnique()PUBLIC:
Answer whether the receiver is a unique constraint field.
return isUnique;
|
public void | setAdditional(java.lang.String string)PUBLIC:
Set any additional information about this field to be given when the table is created.
additional = string;
|
public void | setConstraint(java.lang.String string)PUBLIC:
Set any constraint of this field.
i.e. "BETWEEN 0 AND 1000000".
constraint = string;
|
public void | setForeignKeyFieldName(java.lang.String foreignKeyFieldName)PUBLIC:
Set the foreign key field name. This value is used for a foreign key constraint.
this.foreignKeyFieldName = foreignKeyFieldName;
|
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 sequencial value is store in the row.
isIdentity = value;
if (value) {
setShouldAllowNull(false);
}
|
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.
isPrimaryKey = value;
if (value) {
setShouldAllowNull(false);
}
|
public void | setName(java.lang.String name)PUBLIC:
Set the name of the field.
this.name = name;
|
public void | setShouldAllowNull(boolean value)PUBLIC:
Set whether the receiver should allow null values.
shouldAllowNull = value;
|
public void | setSize(int size)PUBLIC:
Set the size of the field, this is only required for some field types.
this.size = size;
|
public void | setSubSize(int subSize)PUBLIC:
Set the sub-size of the field.
This is used as the decimal precision for numeric values only.
this.subSize = subSize;
|
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.
this.type = type;
|
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.
this.typeDefinition = typeDefinition;
|
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.
this.typeName = typeName;
|
public void | setUnique(boolean value)PUBLIC:
Set whether the receiver is a unique constraint field.
isUnique = value;
|
public boolean | shouldAllowNull()PUBLIC:
Return whether the receiver should allow null values.
return shouldAllowNull;
|
public java.lang.String | toString()
return Helper.getShortClassName(getClass()) + "(" + getName() + "(" + getType() + "))";
|