Package org.apache.empire.db
Class DBTableColumn
java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBColumnExpr
org.apache.empire.db.DBColumn
org.apache.empire.db.DBTableColumn
- All Implemented Interfaces:
Column,ColumnExpr
This class represent one column of a table.
It contains all properties of this columns (e.g. the column width).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final Stringprotected intprotected Objectprotected booleanprotected booleanprotected doubleprotected DataTypeFields inherited from class org.apache.empire.db.DBColumnExpr
attributes, beanPropertyName, optionsFields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUEFields inherited from interface org.apache.empire.data.Column
COLATTR_CASESENSITIVE, COLATTR_CURRENCY_CODE, COLATTR_ENUMTYPE, COLATTR_FRACTION_DIGITS, COLATTR_INTEGER_DIGITS, COLATTR_MAXVALUE, COLATTR_MINLENGTH, COLATTR_MINVALUE, COLATTR_NORMCOLUMN, COLATTR_NULLTEXT, COLATTR_NUMBER_GROUPSEP, COLATTR_NUMBER_TYPE, COLATTR_REFCOLUMNS, COLATTR_REGEXP, COLATTR_SORTDESCENDING, COLATTR_SORTEXPRESSION, COLATTR_TITLE, COLATTR_TOOLTIP, COLATTR_TYPE, NUMTYPE_CURRENCY, NUMTYPE_DECIMAL, NUMTYPE_INTEGER, NUMTYPE_PERCENT -
Constructor Summary
ConstructorsModifierConstructorDescriptionDBTableColumn(DBTable table, DataType type, String name, double size, boolean required, boolean autoGenerated, Object defValue) Constructs a DBTableColumn object set the specified parameters to this object.protectedDBTableColumn(DBTable newTable, DBTableColumn other) Clone Constructor -
Method Summary
Modifier and TypeMethodDescriptionSets field elements, default attributes and all options to the specified Element object (XML tag).Returns the data type.intReturns the scale of the Decimal or 0 if the DataType is not DataType.DECIMAL.Returns the default column value.getRecordDefaultValue(Record record, Connection conn) Returns the default column value.doublegetSize()Gets the the column width.booleanReturns true if column is a numeric sequence or otherwise generated valuebooleanChecks whether the column is read only.booleanReturns true if column is mandatory.booleanReturns true if column the column is a single byte text or character column or false otherwisereferenceOn(DBTableColumn target) Creates a foreign key relation for this column.voidsetDecimalScale(int scale) Sets the scale of a decimal.voidsetDefaultValue(Object defValue) Sets the default column value.voidsetEnumOptions(Class<? extends Enum<?>> enumType) sets the options from an enum classvoidsetReadOnly(boolean readOnly) Sets the read only attribute of the column.voidsetRequired(boolean required) Changes the required property of the table column
Use for dynamic data model changes only.voidsetSingleByteChars(boolean singleByteChars) sets whether this column is a single byte character or text columnvoidsetSize(double size) Changes the size of the table column
Use for dynamic data model changes only.validateValue(Object value) Checks whether the supplied value is valid for this column.Methods inherited from class org.apache.empire.db.DBColumn
addReferencedColumns, addSQL, coalesceColumn, decodeEnum, decodeSort, equals, getAlias, getAttribute, getAttributes, getComment, getDatabase, getEntity, getEnumType, getFullName, getIdentifier, getJavaType, getName, getNormalizedColumn, getOptions, getRegExPattern, getRowSet, getSortExpr, getUpdateColumn, hashCode, isAggregate, isEnum, qualified, reference, setCaseInsensitive, setCaseSensitive, setComment, setNormalizedColumn, setNumberType, setRegExPattern, setSortExpr, setSortExpr, to, toStringMethods inherited from class org.apache.empire.db.DBColumnExpr
abs, aggregate, append, as, as, asc, avg, ceiling, cmp, coalesce, concat, concat, contains, convertTo, convertTo, count, countDistinct, day, decode, decode, decode, decode, decode, decode, decodeEnum, decodeSort, desc, divideBy, floor, format, function, getAttribute, getBeanPropertyName, getControlType, getDefaultSortOrder, getExprFromPhrase, getExprFromPhrase, getIgnoreCaseExpr, getNumberType, getSourceColumn, getTitle, in, in, in, indexOf, indexOf, indexOf, is, isBetween, isCaseSensitive, isGreaterThan, isLessOrEqual, isLiteralValue, isMoreOrEqual, isNot, isNotBetween, isSmallerThan, length, like, like, likeLower, likeUpper, lower, max, min, minus, minus, modulo, month, multiplyWith, notContains, notIn, notIn, notIn, notLike, nvl, on, parenthesis, plus, plus, prepend, replace, reverse, round, setAttribute, setBeanPropertyName, setControlType, setDefaultSortOrder, setOptions, setTitle, stringAgg, stringAgg, substring, substring, substring, substring, substring, substring, sum, toChar, toChar, trim, trimLeft, trimRight, trunc, upper, when, yearMethods inherited from class org.apache.empire.db.DBObject
checkParamNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.empire.data.ColumnExpr
getBeanPropertyName, getControlType, getSourceColumn, getTitle, setAttribute
-
Field Details
-
DBCOLATTR_SINGLEBYTECHARS
- See Also:
-
type
-
size
protected double size -
required
protected boolean required -
autoGenerated
protected boolean autoGenerated -
readOnly
protected boolean readOnly -
defaultValue
-
decimalScale
protected int decimalScale
-
-
Constructor Details
-
DBTableColumn
public DBTableColumn(DBTable table, DataType type, String name, double size, boolean required, boolean autoGenerated, Object defValue) Constructs a DBTableColumn object set the specified parameters to this object.- Parameters:
table- the table object to add the column to, set to null if you don't want it added to a tabletype- the type of the column e.g. integer, text, datename- the column namesize- the column widthrequired- flag whether the column is requiredautoGenerated- flag whether the column is auto generateddefValue- the object value
-
DBTableColumn
Clone Constructor- Parameters:
newTable- the cloned tableother- the column to clone
-
-
Method Details
-
getDefaultValue
Returns the default column value. For columns of type DBDataType.AUTOINC this is assumed to be the name of a sequence- Returns:
- the default column value
-
setDefaultValue
Sets the default column value.- Parameters:
defValue- the default column value
-
getRecordDefaultValue
Returns the default column value. Unlike getDefaultValue this function is used when creating or adding records. If the column value is DBDataType AUTOIN this function will return a new sequence value for this record- Parameters:
record- the recordconn- a valid database connection- Returns:
- the default column value
-
getDataType
Returns the data type.- Specified by:
getDataTypein interfaceColumnExpr- Specified by:
getDataTypein classDBColumnExpr- Returns:
- the data type
- See Also:
-
getSize
public double getSize()Gets the the column width. -
setSize
public void setSize(double size) Changes the size of the table column
Use for dynamic data model changes only.- Parameters:
size- the new column size
-
getDecimalScale
public int getDecimalScale()Returns the scale of the Decimal or 0 if the DataType is not DataType.DECIMAL.- Returns:
- the decimal scale
-
setDecimalScale
public void setDecimalScale(int scale) Sets the scale of a decimal. The DataType must be set to DataType.DECIMAL otherwise an exception is thrown.- Parameters:
scale- the number of fraction digits
-
isRequired
public boolean isRequired()Returns true if column is mandatory. Only for the graphic presentation.- Specified by:
isRequiredin interfaceColumn- Specified by:
isRequiredin classDBColumn- Returns:
- true if column is mandatory
-
isAutoGenerated
public boolean isAutoGenerated()Returns true if column is a numeric sequence or otherwise generated value- Specified by:
isAutoGeneratedin interfaceColumn- Specified by:
isAutoGeneratedin classDBColumn- Returns:
- true if column is auto increment
-
isSingleByteChars
public boolean isSingleByteChars()Returns true if column the column is a single byte text or character column or false otherwise- Returns:
- true if column is a single byte character based column
-
setSingleByteChars
public void setSingleByteChars(boolean singleByteChars) sets whether this column is a single byte character or text column- Parameters:
singleByteChars- flag whether single byte chars should be used
-
setRequired
public void setRequired(boolean required) Changes the required property of the table column
Use for dynamic data model changes only.- Parameters:
required- true if the column is required or false otherwise
-
isReadOnly
public boolean isReadOnly()Checks whether the column is read only.- Specified by:
isReadOnlyin interfaceColumn- Specified by:
isReadOnlyin classDBColumn- Returns:
- true if the column is read only
-
setReadOnly
public void setReadOnly(boolean readOnly) Sets the read only attribute of the column.- Parameters:
readOnly- true if the column should be read only or false otherwise
-
setEnumOptions
sets the options from an enum class- Parameters:
enumType- the enum type
-
validateValue
Checks whether the supplied value is valid for this column. If the type of the value supplied does not match the columns data type the value will be checked for compatibility.- Specified by:
validateValuein interfaceColumn- Specified by:
validateValuein classDBColumn- Parameters:
value- the checked to check for validity- Returns:
- true if the value is valid or false otherwise.
-
referenceOn
Creates a foreign key relation for this column.- Parameters:
target- the referenced primary key column- Returns:
- the reference object
-
addXml
Sets field elements, default attributes and all options to the specified Element object (XML tag).
-