Package com.mckoi.database
Class DataTableColumnDef
- java.lang.Object
-
- com.mckoi.database.DataTableColumnDef
-
public class DataTableColumnDef extends java.lang.ObjectAll the information regarding a column in a table.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringclass_constraintIf this is a Java Object column, this is a constraint that the object must be derived from to be added to this column.private java.lang.Classconstraining_classThe constraining Class object itself.private byte[]constraints_formatA string that contains some constraints.private intdb_typeThe actual column type in the database (as defined in com.mckoi.database.global.Types).private java.lang.Stringdefault_expression_stringThe default expression string.private java.lang.Stringforeign_keyDeprecated.private java.lang.Stringindex_descThe type of index to use on this column.private java.lang.Stringlocale_strThe locale string if this column represents a string.private java.lang.StringnameThe name of the column.private intscaleThe scale of the data.private intsizeThe size of the data.private intsql_typeThe sql column type (as defined in java.sql.Types).private intstr_decompositionThe locale Collator decomposition if this column represents a string.private intstr_strengthThe locale Collator strength if this column represents a string.TTypetypeThe TType object for this column.
-
Constructor Summary
Constructors Constructor Description DataTableColumnDef()Constructs the column definition.DataTableColumnDef(DataTableColumnDef column_def)Creates a copy of the given column definition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.ClassclassType()Returns the Class of Java object that represents this column.ColumnDescriptioncolumnDescriptionValue(java.lang.String column_name)Returns this column as a ColumnDescription object and gives the column description the given name.(package private) booleancompatIsPrimaryKey()(package private) booleancompatIsUnique()static DataTableColumnDefcreateBinaryColumn(java.lang.String name)Convenience helper - creates a DataTableColumnDef that holds a binary value.static DataTableColumnDefcreateBooleanColumn(java.lang.String name)Convenience helper - creates a DataTableColumnDef that holds a boolean value.static DataTableColumnDefcreateNumericColumn(java.lang.String name)Convenience helper - creates a DataTableColumnDef that holds a numeric value.static DataTableColumnDefcreateStringColumn(java.lang.String name)Convenience helper - creates a DataTableColumnDef that holds a string value.(package private) static TTypecreateTTypeFor(int sql_type, int size, int scale, java.lang.String locale, int str_strength, int str_decomposition, java.lang.String java_class)Returns a TType object for a column with the given type information.voiddump(java.io.PrintStream out)Dumps information about this object to the PrintStream.java.lang.StringgetClassConstraint()If this column represents a Java Object, this returns the name of the class the objects stored in the column must be derived from.java.lang.ClassgetClassConstraintAsClass()If this column represents a Java Object, this returns the class object that is the constraining class for the column.intgetDBType()java.lang.StringgetDBTypeString()Returns the type as a String.intgetDecomposition()ExpressiongetDefaultExpression(TransactionSystem system)java.lang.StringgetDefaultExpressionString()java.lang.StringgetForeignKey()Deprecated.java.lang.StringgetIndexScheme()Returns the name of the scheme we use to index this column.java.lang.StringgetLocaleString()java.lang.StringgetName()intgetScale()intgetSize()intgetSQLType()java.lang.StringgetSQLTypeString()Returns the type as a String.intgetStrength()TTypegetTType()Returns the TType for this column.voidinitTTypeInfo()Initializes the TType information for a column.booleanisIndexableType()Returns true if this type of column is able to be indexed.booleanisNotNull()(package private) static DataTableColumnDefread(java.io.DataInput in)Reads this column from a DataInputStream.voidsetClassConstraint(java.lang.String class_constraint)If this column represents a Java object, this must be a class the object is derived from to be added to this column.voidsetDBType(int db_type)voidsetDefaultExpression(Expression expression)voidsetForeignKey(java.lang.String foreign_key)Deprecated.voidsetFromTType(TType type)Sets this DataTableColumnDef object up from information in the TType object.voidsetIndexScheme(java.lang.String index_scheme)Sets the indexing scheme for this column.voidsetName(java.lang.String name)voidsetNotNull(boolean status)voidsetScale(int scale)voidsetSize(int size)voidsetSQLType(int sql_type)voidsetStringLocale(java.lang.String locale_str, int strength, int decomposition)static java.lang.StringsqlTypeToString(int sql_type)Returns a string that represents the given SQLType enumeration passed to it.(package private) voidwrite(java.io.DataOutput out)Writes this column information out to a DataOutputStream.
-
-
-
Field Detail
-
constraints_format
private byte[] constraints_format
A string that contains some constraints. This string contains information about whether the column is not null, unique, primary key, etc.
-
name
private java.lang.String name
The name of the column.
-
sql_type
private int sql_type
The sql column type (as defined in java.sql.Types).
-
db_type
private int db_type
The actual column type in the database (as defined in com.mckoi.database.global.Types).
-
size
private int size
The size of the data.
-
scale
private int scale
The scale of the data.
-
locale_str
private java.lang.String locale_str
The locale string if this column represents a string. If this is an empty string, the column has no locale (the string is collated lexicographically).
-
str_strength
private int str_strength
The locale Collator strength if this column represents a string. The value here is taken from java.text.Collator.
-
str_decomposition
private int str_decomposition
The locale Collator decomposition if this column represents a string. The value here is taken from java.text.Collator.
-
default_expression_string
private java.lang.String default_expression_string
The default expression string.
-
foreign_key
private java.lang.String foreign_key
Deprecated.If this is a foreign key, the table.column that this foreign key refers to.
-
index_desc
private java.lang.String index_desc
The type of index to use on this column.
-
class_constraint
private java.lang.String class_constraint
If this is a Java Object column, this is a constraint that the object must be derived from to be added to this column. If not specified, it defaults to 'java.lang.Object'.
-
constraining_class
private java.lang.Class constraining_class
The constraining Class object itself.
-
type
public TType type
The TType object for this column.
-
-
Constructor Detail
-
DataTableColumnDef
public DataTableColumnDef()
Constructs the column definition.
-
DataTableColumnDef
public DataTableColumnDef(DataTableColumnDef column_def)
Creates a copy of the given column definition.
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
-
setNotNull
public void setNotNull(boolean status)
-
setSQLType
public void setSQLType(int sql_type)
-
setDBType
public void setDBType(int db_type)
-
setSize
public void setSize(int size)
-
setScale
public void setScale(int scale)
-
setStringLocale
public void setStringLocale(java.lang.String locale_str, int strength, int decomposition)
-
setDefaultExpression
public void setDefaultExpression(Expression expression)
-
setForeignKey
public void setForeignKey(java.lang.String foreign_key)
Deprecated.
-
setIndexScheme
public void setIndexScheme(java.lang.String index_scheme)
Sets the indexing scheme for this column. Either 'InsertSearch' or 'BlindSearch'. If not set, then default to insert search.
-
setClassConstraint
public void setClassConstraint(java.lang.String class_constraint)
If this column represents a Java object, this must be a class the object is derived from to be added to this column.
-
setFromTType
public void setFromTType(TType type)
Sets this DataTableColumnDef object up from information in the TType object. This is useful when we need to create a DataTableColumnDef object to store information based on nothing more than a TType object. This comes in useful for purely functional tables.
-
initTTypeInfo
public void initTTypeInfo()
Initializes the TType information for a column. This should be called at the last part of a DataTableColumnDef setup.
-
getName
public java.lang.String getName()
-
isNotNull
public boolean isNotNull()
-
getSQLType
public int getSQLType()
-
getSQLTypeString
public java.lang.String getSQLTypeString()
Returns the type as a String.
-
getDBTypeString
public java.lang.String getDBTypeString()
Returns the type as a String.
-
classType
public java.lang.Class classType()
Returns the Class of Java object that represents this column.
-
getDBType
public int getDBType()
-
getSize
public int getSize()
-
getScale
public int getScale()
-
getLocaleString
public java.lang.String getLocaleString()
-
getStrength
public int getStrength()
-
getDecomposition
public int getDecomposition()
-
getDefaultExpression
public Expression getDefaultExpression(TransactionSystem system)
-
getDefaultExpressionString
public java.lang.String getDefaultExpressionString()
-
getForeignKey
public java.lang.String getForeignKey()
Deprecated.
-
getIndexScheme
public java.lang.String getIndexScheme()
Returns the name of the scheme we use to index this column. It will be either 'InsertSearch' or 'BlindSearch'.
-
isIndexableType
public boolean isIndexableType()
Returns true if this type of column is able to be indexed.
-
getClassConstraint
public java.lang.String getClassConstraint()
If this column represents a Java Object, this returns the name of the class the objects stored in the column must be derived from.
-
getClassConstraintAsClass
public java.lang.Class getClassConstraintAsClass()
If this column represents a Java Object, this returns the class object that is the constraining class for the column.
-
getTType
public TType getTType()
Returns the TType for this column.
-
columnDescriptionValue
public ColumnDescription columnDescriptionValue(java.lang.String column_name)
Returns this column as a ColumnDescription object and gives the column description the given name.
-
dump
public void dump(java.io.PrintStream out)
Dumps information about this object to the PrintStream.
-
compatIsUnique
boolean compatIsUnique()
-
compatIsPrimaryKey
boolean compatIsPrimaryKey()
-
sqlTypeToString
public static java.lang.String sqlTypeToString(int sql_type)
Returns a string that represents the given SQLType enumeration passed to it. For example, pass SQLTypes.BIT and it returns the string "BIT"
-
createTTypeFor
static TType createTTypeFor(int sql_type, int size, int scale, java.lang.String locale, int str_strength, int str_decomposition, java.lang.String java_class)
Returns a TType object for a column with the given type information. The type information is the sql_type, the size and the scale of the type.
-
createNumericColumn
public static DataTableColumnDef createNumericColumn(java.lang.String name)
Convenience helper - creates a DataTableColumnDef that holds a numeric value.
-
createBooleanColumn
public static DataTableColumnDef createBooleanColumn(java.lang.String name)
Convenience helper - creates a DataTableColumnDef that holds a boolean value.
-
createStringColumn
public static DataTableColumnDef createStringColumn(java.lang.String name)
Convenience helper - creates a DataTableColumnDef that holds a string value.
-
createBinaryColumn
public static DataTableColumnDef createBinaryColumn(java.lang.String name)
Convenience helper - creates a DataTableColumnDef that holds a binary value.
-
write
void write(java.io.DataOutput out) throws java.io.IOExceptionWrites this column information out to a DataOutputStream.- Throws:
java.io.IOException
-
read
static DataTableColumnDef read(java.io.DataInput in) throws java.io.IOException
Reads this column from a DataInputStream.- Throws:
java.io.IOException
-
-