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 int
AUTOINCREMENT_CONSTRAINT_ORDER
Autoincrement Constraint Orderstatic int
DEFAULT_VALUE_CONSTRAINT_ORDER
Default Value Constraint Orderstatic int
NO_INDEX
User Column index valuestatic int
NOT_NULL_CONSTRAINT_ORDER
Not Null Constraint Orderstatic int
PRIMARY_KEY_CONSTRAINT_ORDER
Primary Key Constraint Orderstatic int
UNIQUE_CONSTRAINT_ORDER
Unique Constraint Order
-
Constructor Summary
Constructors Modifier Constructor Description protected
UserColumn(int index, String name, String type, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)
Constructorprotected
UserColumn(int index, String name, GeoPackageDataType dataType, Long max, boolean notNull, Object defaultValue, boolean primaryKey, boolean autoincrement)
Constructorprotected
UserColumn(TableColumn tableColumn)
Constructorprotected
UserColumn(UserColumn userColumn)
Copy Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAutoincrementConstraint()
Add an autoincrement constraintvoid
addConstraint(String constraint)
Add a constraintvoid
addConstraint(Constraint constraint)
Add a constraintvoid
addConstraint(ConstraintType type, Integer order, String constraint)
Add a constraintvoid
addConstraint(ConstraintType type, String constraint)
Add a constraintvoid
addConstraints(Collection<Constraint> constraints)
Add constraintsvoid
addConstraints(ColumnConstraints constraints)
Add constraintsvoid
addConstraints(Constraints constraints)
Add constraintsvoid
addDefaultConstraints()
Add the default constraints that are enabled (not null, default value, primary key) from the column propertiesvoid
addDefaultValueConstraint(Object defaultValue)
Add a default value constraintvoid
addNotNullConstraint()
Add a not null constraintvoid
addPrimaryKeyConstraint()
Add a primary key constraintvoid
addUniqueConstraint()
Add a unique constraintString
buildConstraintSql(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 typeint
compareTo(UserColumn another)
abstract UserColumn
copy()
Copy the columnConstraints
getConstraints()
Get the constraintsList<Constraint>
getConstraints(ConstraintType type)
Get the constraints of the provided typeGeoPackageDataType
getDataType()
Get the data typeObject
getDefaultValue()
Get the default valueint
getIndex()
Get the indexLong
getMax()
Get the maxString
getName()
Get the nameDataColumns
getSchema()
Get the in-memory data columns schema.String
getType()
Get the database typeprotected static String
getTypeName(String name, GeoPackageDataType dataType)
Get the type name from the data typeboolean
hasConstraints()
Check if has constraintsboolean
hasConstraints(ConstraintType type)
Check if has constraints of the provided typeboolean
hasDefaultValue()
Determine if the column has a default valueboolean
hasIndex()
Check if the column has a valid indexboolean
hasMax()
Determine if the column has a max valueboolean
hasSchema()
Check if the column has an in-memory data columns schemaboolean
isAutoincrement()
Get the autoincrement flagboolean
isNamed(String name)
Determine if this column is named the provided nameboolean
isNotNull()
Get the is not null flagboolean
isPrimaryKey()
Get the primary key flagboolean
isUnique()
Get the unique flagvoid
removeAutoincrementConstraint()
Remove an autoincrement constraintvoid
removeDefaultValueConstraint()
Remove a default value constraintvoid
removeNotNullConstraint()
Remove a not null constraintvoid
removePrimaryKeyConstraint()
Remove a primary key constraintvoid
removeUniqueConstraint()
Remove a unique constraintvoid
resetIndex()
Reset the column indexvoid
setAutoincrement(boolean autoincrement)
Set the autoincrement flagvoid
setConstraintOrder(Constraint constraint)
Set the constraint order by constraint typevoid
setDataType(GeoPackageDataType dataType)
Set the data typevoid
setDefaultValue(Object defaultValue)
Set the default valuevoid
setIndex(int index)
Set the column index.void
setMax(Long max)
Set the maxvoid
setName(String name)
Set the namevoid
setNotNull(boolean notNull)
Set the not null flagvoid
setPrimaryKey(boolean primaryKey)
Set the primary key flagvoid
setSchema(DataColumns schema)
Set the data columns schema.void
setType(String type)
Set the database typevoid
setUnique(boolean unique)
Set the unique flagprotected static void
validateDataType(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:
compareTo
in interfaceComparable<UserColumn>
-
-