Package com.wisecoders.dbs.schema
Class Column
java.lang.Object
com.wisecoders.dbs.diagram.model.AbstractUnit
com.wisecoders.dbs.schema.Column
- All Implemented Interfaces:
Attribute,TreeUnit,Unit,DbUnit,Comparable<AbstractUnit>
A column into a table.
-
Field Summary
FieldsFields inherited from interface com.wisecoders.dbs.diagram.model.Attribute
MARKER_ARRAY, MARKER_BLOB, MARKER_BOOLEAN, MARKER_CHAR, MARKER_DATE, MARKER_FIRST, MARKER_FK, MARKER_INDEX, MARKER_INDEX1, MARKER_INDEX2, MARKER_INDEX3, MARKER_INDEX4, MARKER_JSON_ARRAY, MARKER_JSON_OBJECT, MARKER_NUMBER, MARKER_OPTION_ASC, MARKER_OPTION_DESC, MARKER_PK, MARKER_REF, MARKER_TEXT, MARKER_UNIQUE, TYPE_STRING_MAX_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionColumn(AbstractTable table, String name) Public constructor.Column(AbstractTable table, String name, DataType dataType) Public constructorColumn(AbstractTable table, String name, DataType dataType, AttributeSpec spec) Column(ChildEntity childEntity, String name, DataType dataType) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendOptions(String options) voidClone the definition from the given columnintcompareTo(AbstractUnit unit) booleandefaultValuesAreSimilar(Column target) Checks if the default values are similargetChildAt(int idx) intstatic ColumngetColumnByPath(Folder<? extends Column> columns, String name) getDbId()intgetDisplayName(Diagram diagram) shortGet the percentage of the null values for the data generator.Get the data generator patternintintReturn the best fitting data generator pattern.getSpec()com.wisecoders.dbs.sys.fx.glyph.GlyphFolder[]shortgetTypeString(DataTypeFormat usage) booleanbooleanbooleanbooleanbooleanbooleanbooleanhasMarker(int marker) booleanbooleanbooleanbooleanisTicked()booleanisUnique()True if the column is unique.booleanbooleanisUsingSameDataType(Column other) ref()voidrefresh()voidvoidsetAssociatedSequence(Sequence sequence) voidsetDataType(DataType dataType) Set the column data type definition.voidsetDecimal(int decimal) Set data type decimal precisionvoidsetDefaultValue(String defaultValue) Set the column default valuevoidsetDefinition(String definition) voidsetEnumeration(String enumeration) Set enumeration valuesvoidsetGeneratorNullsPercentage(short nulls) Set the percentage of the null values for the data generator.booleansetGeneratorPattern(String generatorPattern) Set the data generator patternvoidsetGeneratorPatternClearCache(String generatorPattern) Set the data generator pattern and clear the pattern cache.voidsetGeneratorSeed(int generatorSeed) voidsetIdentity(String identity) Mark column as autoincrementvoidsetLength(int length) Set data type current lengthvoidsetMandatory(boolean mandatory) voidsetMarker(int marker) booleansetOptions(String options) Set the parameters to add after the column definitionvoidsetSpec(AttributeSpec spec) voidsetTicked(boolean ticked) Not used with columnvoidsetToDoFlag(short toDo) voidsetTypeOptions(String typeOptions) Set the string to be added after the data typevoidsetUnsigned(boolean unsigned) Mark the column as unsignedtoString()booleanupdateCascade(boolean dryRun, String oldName, String newName, DataType dataType, int precision, int decimal) protected booleanupdateCascade(boolean dryRun, String oldName, String newName, DataType dataType, int precision, int decimal, List<Column> alreadyDone) Methods inherited from class com.wisecoders.dbs.diagram.model.AbstractUnit
fixNull, getByName, getByName, getComment, getCommentNotNull, getCommentTag, getCommentTags, getDefaultKey, getKey, getName, getPlainName, getPropertyAddOnFolder, getString, getTickId, getTouchId, getUnitProperty, has, is, is, isMarkedForDeletion, isVirtual, markForDeletion, matches, removeUnitProperty, rename, sameAs, sameAs, setComment, setCommentTag, setCommentTags, setTouchId, setUnitProperty, setVirtualMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.wisecoders.dbs.diagram.model.Unit
getComment, getCommentTag, getCommentTags, is, isMarkedForDeletion, markForDeletion, setComment, setCommentTag, setCommentTags
-
Field Details
-
ICON_COLUMN
- See Also:
-
table
-
generatorPatternCache
-
-
Constructor Details
-
Column
Public constructor. By default, set as integer data type.- Parameters:
table- it belongs toname- of the column
-
Column
-
Column
-
Column
Public constructor- Parameters:
table- it belongs toname- of the columndataType- to be used.
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein interfaceUnit- Overrides:
getDisplayNamein classAbstractUnit
-
getSyncFolders
- Overrides:
getSyncFoldersin classAbstractUnit
-
getSymbolicName
- Specified by:
getSymbolicNamein interfaceUnit- Specified by:
getSymbolicNamein classAbstractUnit- Returns:
- "Column"
-
getSymbolicIcon
- Specified by:
getSymbolicIconin classAbstractUnit- Returns:
- an icon for the tree
-
getSymbolicGlyph
public com.wisecoders.dbs.sys.fx.glyph.Glyph getSymbolicGlyph()- Specified by:
getSymbolicGlyphin classAbstractUnit
-
getIndexingIcon
- Specified by:
getIndexingIconin interfaceAttribute- Returns:
- an icon for the index ( if exists )
-
setDataType
Set the column data type definition. The length and decimal are set throgh separate methods- Parameters:
dataType- to use
-
hasLength
public boolean hasLength()- Returns:
- true if the Attribute has set the length
-
hasDecimal
public boolean hasDecimal()- Returns:
- true if the Attribute has a set the decimal
-
getLength
public int getLength()- Returns:
- data type length
-
setLength
public void setLength(int length) Set data type current length- Parameters:
length- of the column
-
getDecimal
public int getDecimal()- Returns:
- data type decimal
-
setDecimal
public void setDecimal(int decimal) Set data type decimal precision- Parameters:
decimal- of the column
-
getDataType
- Specified by:
getDataTypein interfaceAttribute- Returns:
- the column data type definition. The current length, precision, are stored in the Column
-
isUsingSameDataType
-
getEnumeration
- Returns:
- the enumeration values
-
setEnumeration
Set enumeration values- Parameters:
enumeration- as list of comma separated text
-
getTypeOptions
- Returns:
- The string to be added after the data type
-
setTypeOptions
Set the string to be added after the data type- Parameters:
typeOptions- as string
-
getOptions
- Returns:
- string which will be added on the end of the column definition
-
setOptions
Set the parameters to add after the column definition- Parameters:
options- as string
-
appendOptions
-
isUnsigned
public boolean isUnsigned()- Returns:
- true if the column is unsigned
-
setUnsigned
public void setUnsigned(boolean unsigned) Mark the column as unsigned- Parameters:
unsigned- - values can be only above 0
-
isIdentity
public boolean isIdentity()- Returns:
- true if the column is autoincrement
-
getIdentity
-
setIdentity
Mark column as autoincrement- Parameters:
identity- true if autoincrement
-
setDefaultValue
Set the column default value- Parameters:
defaultValue- to use on insert if nothing is specified
-
hasDefaultValue
public boolean hasDefaultValue()- Returns:
- true if the column has set a default value
-
getDefaultValue
- Returns:
- the column default value
-
defaultValuesAreSimilar
Checks if the default values are similar- Parameters:
target- column- Returns:
- true if the default values are pretty the same. Differences can be in values quotation
-
cloneFrom
Clone the definition from the given column- Parameters:
other- to clone
-
setTicked
public void setTicked(boolean ticked) Not used with column -
isTicked
public boolean isTicked() -
getEntity
-
getParentEntity
- Specified by:
getParentEntityin interfaceUnit- Overrides:
getParentEntityin classAbstractUnit
-
getRootParentColumn
-
getParent
- Specified by:
getParentin interfaceTreeUnit- Specified by:
getParentin classAbstractUnit
-
setMarker
public void setMarker(int marker) -
hasMarker
public boolean hasMarker(int marker) -
resetMarkers
public void resetMarkers() -
setMandatory
public void setMandatory(boolean mandatory) -
isMandatory
public boolean isMandatory()- Specified by:
isMandatoryin interfaceAttribute
-
getTypeString
-
getTypeString
- Specified by:
getTypeStringin interfaceAttribute
-
refresh
public void refresh()- Specified by:
refreshin classAbstractUnit
-
isSelectable
public boolean isSelectable()- Specified by:
isSelectablein interfaceAttribute
-
compareTo
- Specified by:
compareToin interfaceComparable<AbstractUnit>- Overrides:
compareToin classAbstractUnit
-
setToDoFlag
public void setToDoFlag(short toDo) -
getToDoFlag
public short getToDoFlag()- Specified by:
getToDoFlagin interfaceAttribute
-
getGeneratorPattern
Get the data generator pattern- Returns:
- the pattern
-
setGeneratorPatternClearCache
Set the data generator pattern and clear the pattern cache.- Parameters:
generatorPattern- to set
-
setGeneratorPattern
Set the data generator pattern- Parameters:
generatorPattern- is the reverse regexp or pattern for random number, values from file, etc.- Returns:
- if true if set
-
getGeneratorNullsPercentage
public short getGeneratorNullsPercentage()Get the percentage of the null values for the data generator. Omitted if the column is mandatory- Returns:
- percentage between 0 and 100
-
hasGeneratorNullsPercentage
public boolean hasGeneratorNullsPercentage() -
setGeneratorNullsPercentage
public void setGeneratorNullsPercentage(short nulls) Set the percentage of the null values for the data generator. Omitted if the column is mandatory- Parameters:
nulls- as percentage between 0 and 100
-
isUnique
public boolean isUnique()True if the column is unique. This is deduced from the indexes information- Returns:
- true if the column is unique
-
getGeneratorSeed
public int getGeneratorSeed() -
setGeneratorSeed
public void setGeneratorSeed(int generatorSeed) -
getOrGuessGeneratorPattern
Return the best fitting data generator pattern.- Returns:
- pattern string, can be reverse reg exp, random number pattern, etc.
-
toString
- Overrides:
toStringin classAbstractUnit
-
hasAssociatedSequence
public boolean hasAssociatedSequence() -
getAssociatedSequence
- Specified by:
getAssociatedSequencein interfaceAttribute
-
setAssociatedSequence
-
getNameWithPath
- Specified by:
getNameWithPathin interfaceAttribute
-
getParentColumn
-
hasChildEntity
public boolean hasChildEntity() -
getChildEntity
-
getCreateChildEntity
-
getChildrenCount
public int getChildrenCount()- Specified by:
getChildrenCountin interfaceTreeUnit- Overrides:
getChildrenCountin classAbstractUnit
-
getChildAt
- Specified by:
getChildAtin interfaceTreeUnit- Overrides:
getChildAtin classAbstractUnit
-
getColumnByPath
-
getSpec
-
setSpec
-
setDefinition
-
getDefinition
-
getDbId
-
getSchema
-
ref
- Specified by:
refin interfaceUnit- Overrides:
refin classAbstractUnit
-
updateCascade
-
updateCascade
-