Package mil.nga.geopackage.user
Class UserColumn
- java.lang.Object
-
- mil.nga.geopackage.user.UserColumn
-
- All Implemented Interfaces:
Comparable<UserColumn>
- Direct Known Subclasses:
AttributesColumn,FeatureColumn,TileColumn,UserCustomColumn
public abstract class UserColumn extends Object implements Comparable<UserColumn>
Metadata about a single column from a user table- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static intAUTOINCREMENT_CONSTRAINT_ORDERAutoincrement Constraint Orderstatic intDEFAULT_VALUE_CONSTRAINT_ORDERDefault Value Constraint Orderstatic intNO_INDEXUser Column index valuestatic intNOT_NULL_CONSTRAINT_ORDERNot Null Constraint Orderstatic intPRIMARY_KEY_CONSTRAINT_ORDERPrimary Key Constraint Orderstatic intUNIQUE_CONSTRAINT_ORDERUnique Constraint Order
-
Constructor Summary
Constructors Modifier Constructor Description protectedUserColumn(int index, String name, String type, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)ConstructorprotectedUserColumn(int index, String name, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)ConstructorprotectedUserColumn(TableColumn tableColumn)ConstructorprotectedUserColumn(UserColumn userColumn)Copy Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAutoincrementConstraint()Add an autoincrement constraintvoidaddConstraint(String constraint)Add a constraintvoidaddConstraint(Constraint constraint)Add a constraintvoidaddConstraint(ConstraintType type, Integer order, String constraint)Add a constraintvoidaddConstraint(ConstraintType type, String constraint)Add a constraintvoidaddConstraints(Collection<Constraint> constraints)Add constraintsvoidaddConstraints(ColumnConstraints constraints)Add constraintsvoidaddConstraints(Constraints constraints)Add constraintsvoidaddDefaultConstraints()Add the default constraints that are enabled (not null, default value, primary key) from the column propertiesvoidaddDefaultValueConstraint(Object defaultValue)Add a default value constraintvoidaddNotNullConstraint()Add a not null constraintvoidaddPrimaryKeyConstraint()Add a primary key constraintvoidaddUniqueConstraint()Add a unique constraintStringbuildConstraintSql(Constraint constraint)Build the SQL for the constraintList<Constraint>clearConstraints()Clear the constraintsList<Constraint>clearConstraints(boolean reset)Clear the constraintsList<Constraint>clearConstraints(ConstraintType type)Clear the constraints of the provided typeintcompareTo(UserColumn another)abstract UserColumncopy()Copy the columnConstraintsgetConstraints()Get the constraintsList<Constraint>getConstraints(ConstraintType type)Get the constraints of the provided typeGeoPackageDataTypegetDataType()Get the data typeObjectgetDefaultValue()Get the default valueintgetIndex()Get the indexLonggetMax()Get the maxStringgetName()Get the nameDataColumnsgetSchema()Get the in-memory data columns schema.StringgetType()Get the database typeprotected static StringgetTypeName(String name, GeoPackageDataType dataType)Get the type name from the data typebooleanhasConstraints()Check if has constraintsbooleanhasConstraints(ConstraintType type)Check if has constraints of the provided typebooleanhasDefaultValue()Determine if the column has a default valuebooleanhasIndex()Check if the column has a valid indexbooleanhasMax()Determine if the column has a max valuebooleanhasSchema()Check if the column has an in-memory data columns schemabooleanisAutoincrement()Get the autoincrement flagbooleanisNamed(String name)Determine if this column is named the provided namebooleanisNotNull()Get the is not null flagbooleanisPrimaryKey()Get the primary key flagbooleanisUnique()Get the unique flagvoidremoveAutoincrementConstraint()Remove an autoincrement constraintvoidremoveDefaultValueConstraint()Remove a default value constraintvoidremoveNotNullConstraint()Remove a not null constraintvoidremovePrimaryKeyConstraint()Remove a primary key constraintvoidremoveUniqueConstraint()Remove a unique constraintvoidresetIndex()Reset the column indexvoidsetAutoincrement(boolean autoincrement)Set the autoincrement flagvoidsetConstraintOrder(Constraint constraint)Set the constraint order by constraint typevoidsetDataType(GeoPackageDataType dataType)Set the data typevoidsetDefaultValue(Object defaultValue)Set the default valuevoidsetIndex(int index)Set the column index.voidsetMax(Long max)Set the maxvoidsetName(String name)Set the namevoidsetNotNull(boolean notNull)Set the not null flagvoidsetPrimaryKey(boolean primaryKey)Set the primary key flagvoidsetSchema(DataColumns schema)Set the data columns schema.voidsetType(String type)Set the database typevoidsetUnique(boolean unique)Set the unique flagprotected static voidvalidateDataType(String name, GeoPackageDataType dataType)Validate the data type
-
-
-
Field Detail
-
NO_INDEX
public static final int NO_INDEX
User Column index value- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
NOT_NULL_CONSTRAINT_ORDER
public static final int NOT_NULL_CONSTRAINT_ORDER
Not Null Constraint Order- See Also:
- Constant Field Values
-
DEFAULT_VALUE_CONSTRAINT_ORDER
public static final int DEFAULT_VALUE_CONSTRAINT_ORDER
Default Value Constraint Order- See Also:
- Constant Field Values
-
PRIMARY_KEY_CONSTRAINT_ORDER
public static final int PRIMARY_KEY_CONSTRAINT_ORDER
Primary Key Constraint Order- See Also:
- Constant Field Values
-
AUTOINCREMENT_CONSTRAINT_ORDER
public static final int AUTOINCREMENT_CONSTRAINT_ORDER
Autoincrement Constraint Order- See Also:
- Constant Field Values
-
UNIQUE_CONSTRAINT_ORDER
public static final int UNIQUE_CONSTRAINT_ORDER
Unique Constraint Order- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UserColumn
protected UserColumn(int index, String name, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)Constructor- Parameters:
index- column indexname- column namedataType- data typemax- max valuenotNull- not null flagdefaultValue- default valueprimaryKey- primary key flagautoincrement- autoincrement flag- Since:
- 4.0.0
-
UserColumn
protected UserColumn(int index, String name, String type, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)Constructor- Parameters:
index- column indexname- column nametype- string typedataType- data typemax- max valuenotNull- not null flagdefaultValue- default valueprimaryKey- primary key flagautoincrement- autoincrement flag- Since:
- 4.0.0
-
UserColumn
protected UserColumn(TableColumn tableColumn)
Constructor- Parameters:
tableColumn- table column- Since:
- 3.3.0
-
UserColumn
protected UserColumn(UserColumn userColumn)
Copy Constructor- Parameters:
userColumn- user column- Since:
- 3.3.0
-
-
Method Detail
-
getTypeName
protected static String getTypeName(String name, GeoPackageDataType dataType)
Get the type name from the data type- Parameters:
name- column namedataType- data type- Returns:
- type name
- Since:
- 3.3.0
-
validateDataType
protected static void validateDataType(String name, GeoPackageDataType dataType)
Validate the data type- Parameters:
name- column namedataType- data type- Since:
- 3.3.0
-
copy
public abstract UserColumn copy()
Copy the column- Returns:
- copied column
- Since:
- 3.3.0
-
hasIndex
public boolean hasIndex()
Check if the column has a valid index- Returns:
- true if has a valid index
- Since:
- 3.3.0
-
setIndex
public void setIndex(int index)
Set the column index. Only allowed whenhasIndex()is false (getIndex()isNO_INDEX). Setting a valid index to an existing valid index does nothing.- Parameters:
index- column index- Since:
- 3.3.0
-
resetIndex
public void resetIndex()
Reset the column index- Since:
- 3.3.0
-
getIndex
public int getIndex()
Get the index- Returns:
- index
-
setName
public void setName(String name)
Set the name- Parameters:
name- column name- Since:
- 3.3.0
-
getName
public String getName()
Get the name- Returns:
- name
-
isNamed
public boolean isNamed(String name)
Determine if this column is named the provided name- Parameters:
name- column name- Returns:
- true if named the provided name
- Since:
- 3.0.1
-
hasMax
public boolean hasMax()
Determine if the column has a max value- Returns:
- true if has max value
- Since:
- 3.3.0
-
setMax
public void setMax(Long max)
Set the max- Parameters:
max- max- Since:
- 3.3.0
-
getMax
public Long getMax()
Get the max- Returns:
- max
-
setNotNull
public void setNotNull(boolean notNull)
Set the not null flag- Parameters:
notNull- not null flag- Since:
- 3.3.0
-
isNotNull
public boolean isNotNull()
Get the is not null flag- Returns:
- not null flag
-
hasDefaultValue
public boolean hasDefaultValue()
Determine if the column has a default value- Returns:
- true if has default value
- Since:
- 3.3.0
-
setDefaultValue
public void setDefaultValue(Object defaultValue)
Set the default value- Parameters:
defaultValue- default value- Since:
- 3.3.0
-
getDefaultValue
public Object getDefaultValue()
Get the default value- Returns:
- default value
-
setPrimaryKey
public void setPrimaryKey(boolean primaryKey)
Set the primary key flag- Parameters:
primaryKey- primary key flag- Since:
- 3.3.0
-
isPrimaryKey
public boolean isPrimaryKey()
Get the primary key flag- Returns:
- primary key flag
-
setAutoincrement
public void setAutoincrement(boolean autoincrement)
Set the autoincrement flag- Parameters:
autoincrement- autoincrement flag- Since:
- 4.0.0
-
isAutoincrement
public boolean isAutoincrement()
Get the autoincrement flag- Returns:
- autoincrement flag
- Since:
- 4.0.0
-
setUnique
public void setUnique(boolean unique)
Set the unique flag- Parameters:
unique- unique flag- Since:
- 5.0.0
-
isUnique
public boolean isUnique()
Get the unique flag- Returns:
- unique flag
- Since:
- 5.0.0
-
setDataType
public void setDataType(GeoPackageDataType dataType)
Set the data type- Parameters:
dataType- data type- Since:
- 3.3.0
-
getDataType
public GeoPackageDataType getDataType()
Get the data type- Returns:
- data type
-
setType
public void setType(String type)
Set the database type- Parameters:
type- database type- Since:
- 3.3.0
-
getType
public String getType()
Get the database type- Returns:
- type
-
hasConstraints
public boolean hasConstraints()
Check if has constraints- Returns:
- true if has constraints
- Since:
- 3.3.0
-
hasConstraints
public boolean hasConstraints(ConstraintType type)
Check if has constraints of the provided type- Parameters:
type- constraint type- Returns:
- true if has constraints
- Since:
- 5.0.0
-
getConstraints
public Constraints getConstraints()
Get the constraints- Returns:
- constraints
- Since:
- 5.0.0
-
getConstraints
public List<Constraint> getConstraints(ConstraintType type)
Get the constraints of the provided type- Parameters:
type- constraint type- Returns:
- constraints
- Since:
- 5.0.0
-
clearConstraints
public List<Constraint> clearConstraints()
Clear the constraints- Returns:
- cleared constraints
- Since:
- 3.3.0
-
clearConstraints
public List<Constraint> clearConstraints(boolean reset)
Clear the constraints- Parameters:
reset- true to reset constraint settings- Returns:
- cleared constraints
- Since:
- 3.3.0
-
clearConstraints
public List<Constraint> clearConstraints(ConstraintType type)
Clear the constraints of the provided type- Parameters:
type- constraint type- Returns:
- cleared constraints
- Since:
- 5.0.0
-
addDefaultConstraints
public void addDefaultConstraints()
Add the default constraints that are enabled (not null, default value, primary key) from the column properties- Since:
- 3.3.0
-
addConstraint
public void addConstraint(Constraint constraint)
Add a constraint- Parameters:
constraint- constraint- Since:
- 3.3.0
-
setConstraintOrder
public void setConstraintOrder(Constraint constraint)
Set the constraint order by constraint type- Parameters:
constraint- constraint
-
addConstraint
public void addConstraint(String constraint)
Add a constraint- Parameters:
constraint- constraint- Since:
- 3.3.0
-
addConstraint
public void addConstraint(ConstraintType type, String constraint)
Add a constraint- Parameters:
type- constraint typeconstraint- constraint- Since:
- 5.0.0
-
addConstraint
public void addConstraint(ConstraintType type, Integer order, String constraint)
Add a constraint- Parameters:
type- constraint typeorder- constraint orderconstraint- constraint- Since:
- 5.0.0
-
addConstraints
public void addConstraints(Collection<Constraint> constraints)
Add constraints- Parameters:
constraints- constraints- Since:
- 3.3.0
-
addConstraints
public void addConstraints(ColumnConstraints constraints)
Add constraints- Parameters:
constraints- constraints- Since:
- 3.3.0
-
addConstraints
public void addConstraints(Constraints constraints)
Add constraints- Parameters:
constraints- constraints- Since:
- 5.0.0
-
addNotNullConstraint
public void addNotNullConstraint()
Add a not null constraint- Since:
- 3.3.0
-
removeNotNullConstraint
public void removeNotNullConstraint()
Remove a not null constraint- Since:
- 5.0.0
-
addDefaultValueConstraint
public void addDefaultValueConstraint(Object defaultValue)
Add a default value constraint- Parameters:
defaultValue- default value- Since:
- 3.3.0
-
removeDefaultValueConstraint
public void removeDefaultValueConstraint()
Remove a default value constraint- Since:
- 5.0.0
-
addPrimaryKeyConstraint
public void addPrimaryKeyConstraint()
Add a primary key constraint- Since:
- 3.3.0
-
removePrimaryKeyConstraint
public void removePrimaryKeyConstraint()
Remove a primary key constraint- Since:
- 5.0.0
-
addAutoincrementConstraint
public void addAutoincrementConstraint()
Add an autoincrement constraint- Since:
- 4.0.0
-
removeAutoincrementConstraint
public void removeAutoincrementConstraint()
Remove an autoincrement constraint- Since:
- 5.0.0
-
addUniqueConstraint
public void addUniqueConstraint()
Add a unique constraint- Since:
- 3.3.0
-
removeUniqueConstraint
public void removeUniqueConstraint()
Remove a unique constraint- Since:
- 5.0.0
-
buildConstraintSql
public String buildConstraintSql(Constraint constraint)
Build the SQL for the constraint- Parameters:
constraint- constraint- Returns:
- SQL or null
- Since:
- 4.0.0
-
getSchema
public DataColumns getSchema()
Get the in-memory data columns schema. Not saved as part of the column, loaded usingDataColumnsDao.- Returns:
- column schema or null
- Since:
- 6.6.7
-
hasSchema
public boolean hasSchema()
Check if the column has an in-memory data columns schema- Returns:
- true if has column schema
- Since:
- 6.6.7
-
setSchema
public void setSchema(DataColumns schema)
Set the data columns schema. Not saved as part of the column, saved usingDataColumnsDao.- Parameters:
schema- data columns schema- Since:
- 6.6.7
-
compareTo
public int compareTo(UserColumn another)
Sort by index
- Specified by:
compareToin interfaceComparable<UserColumn>
-
-