Package mil.nga.geopackage.user
Class UserColumns<TColumn extends UserColumn>
- java.lang.Object
-
- mil.nga.geopackage.user.UserColumns<TColumn>
-
- Type Parameters:
TColumn- column type
- Direct Known Subclasses:
AttributesColumns,FeatureColumns,TileColumns,UserCustomColumns
public abstract class UserColumns<TColumn extends UserColumn> extends Object
Abstract collection of columns from a user table, representing a full set of table columns or a subset from a query- Since:
- 3.5.0
- Author:
- osbornb
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUserColumns(String tableName, List<TColumn> columns, boolean custom)ConstructorprotectedUserColumns(UserColumns<TColumn> userColumns)Copy Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddColumn(TColumn column)Add a new columnvoidalterColumn(TColumn column)Alter a columnintcolumnCount()Get the column countList<TColumn>columnsOfType(GeoPackageDataType type)Get the columns with the provided data typeabstract UserColumns<TColumn>copy()Copy the user columnsvoiddropColumn(int index)Drop a columnvoiddropColumn(String columnName)Drop a columnvoiddropColumn(TColumn column)Drop a columnprotected voidduplicateCheck(int index, Integer previousIndex, String column)Check for duplicate column namesTColumngetColumn(int index)Get the column at the indexTColumngetColumn(String columnName)Get the column of the column nameintgetColumnIndex(String columnName)Get the column index of the column nameIntegergetColumnIndex(String columnName, boolean required)Get the column index of the column nameStringgetColumnName(int index)Get the column name at the indexString[]getColumnNames()Get the array of column namesList<TColumn>getColumns()Get the list of columnsTColumngetPkColumn()Get the primary key columnintgetPkColumnIndex()Get the primary key column indexStringgetPkColumnName()Get the primary key column nameStringgetTableName()Get the table namebooleanhasColumn(String columnName)Check if the table has the columnbooleanhasPkColumn()Check if the table has a primary key columnbooleanhasSchema()Check if any columns have an in-memory data columns schemabooleanisCustom()Is custom column specification (partial and/or ordering)booleanisPkModifiable()Is the primary key modifiablebooleanisValueValidation()Is value validation against column types enabledprotected voidmissingCheck(Integer index, String column)Check for missing columnsvoidrenameColumn(int index, String newColumnName)Rename a columnvoidrenameColumn(String columnName, String newColumnName)Rename a columnvoidrenameColumn(TColumn column, String newColumnName)Rename a columnvoidsetCustom(boolean custom)Set the custom column specification flagvoidsetPkModifiable(boolean pkModifiable)Set if the primary key can be modifiedvoidsetTableName(String tableName)Set the table namevoidsetValueValidation(boolean valueValidation)Set if values should validated against column typesprotected voidtypeCheck(GeoPackageDataType expected, TColumn column)Check for the expected data typeprotected voidupdateColumns()Update the table columns
-
-
-
Constructor Detail
-
UserColumns
protected UserColumns(String tableName, List<TColumn> columns, boolean custom)
Constructor- Parameters:
tableName- table namecolumns- columnscustom- custom column specification
-
UserColumns
protected UserColumns(UserColumns<TColumn> userColumns)
Copy Constructor- Parameters:
userColumns- user columns
-
-
Method Detail
-
copy
public abstract UserColumns<TColumn> copy()
Copy the user columns- Returns:
- copied user columns
-
updateColumns
protected void updateColumns()
Update the table columns
-
duplicateCheck
protected void duplicateCheck(int index, Integer previousIndex, String column)Check for duplicate column names- Parameters:
index- indexpreviousIndex- previous indexcolumn- column
-
typeCheck
protected void typeCheck(GeoPackageDataType expected, TColumn column)
Check for the expected data type- Parameters:
expected- expected data typecolumn- user column
-
missingCheck
protected void missingCheck(Integer index, String column)
Check for missing columns- Parameters:
index- column indexcolumn- user column
-
getColumnIndex
public int getColumnIndex(String columnName)
Get the column index of the column name- Parameters:
columnName- column name- Returns:
- column index
-
getColumnIndex
public Integer getColumnIndex(String columnName, boolean required)
Get the column index of the column name- Parameters:
columnName- column namerequired- column existence is required- Returns:
- column index
-
getColumnNames
public String[] getColumnNames()
Get the array of column names- Returns:
- column names
-
getColumnName
public String getColumnName(int index)
Get the column name at the index- Parameters:
index- column index- Returns:
- column name
-
getColumn
public TColumn getColumn(int index)
Get the column at the index- Parameters:
index- column index- Returns:
- column
-
getColumn
public TColumn getColumn(String columnName)
Get the column of the column name- Parameters:
columnName- column name- Returns:
- column
-
hasColumn
public boolean hasColumn(String columnName)
Check if the table has the column- Parameters:
columnName- column name- Returns:
- true if has the column
-
columnCount
public int columnCount()
Get the column count- Returns:
- column count
-
getTableName
public String getTableName()
Get the table name- Returns:
- table name
-
setTableName
public void setTableName(String tableName)
Set the table name- Parameters:
tableName- table name
-
isCustom
public boolean isCustom()
Is custom column specification (partial and/or ordering)- Returns:
- custom flag
-
setCustom
public void setCustom(boolean custom)
Set the custom column specification flag- Parameters:
custom- custom flag
-
hasPkColumn
public boolean hasPkColumn()
Check if the table has a primary key column- Returns:
- true if has a primary key
-
getPkColumnIndex
public int getPkColumnIndex()
Get the primary key column index- Returns:
- primary key column index
-
getPkColumn
public TColumn getPkColumn()
Get the primary key column- Returns:
- primary key column
-
getPkColumnName
public String getPkColumnName()
Get the primary key column name- Returns:
- primary key column name
-
columnsOfType
public List<TColumn> columnsOfType(GeoPackageDataType type)
Get the columns with the provided data type- Parameters:
type- data type- Returns:
- columns
-
isPkModifiable
public boolean isPkModifiable()
Is the primary key modifiable- Returns:
- true if the primary key is modifiable
- Since:
- 4.0.0
-
setPkModifiable
public void setPkModifiable(boolean pkModifiable)
Set if the primary key can be modified- Parameters:
pkModifiable- primary key modifiable flag- Since:
- 4.0.0
-
isValueValidation
public boolean isValueValidation()
Is value validation against column types enabled- Returns:
- true if values are validated against column types
- Since:
- 4.0.0
-
setValueValidation
public void setValueValidation(boolean valueValidation)
Set if values should validated against column types- Parameters:
valueValidation- value validation flag- Since:
- 4.0.0
-
addColumn
public void addColumn(TColumn column)
Add a new column- Parameters:
column- new column
-
renameColumn
public void renameColumn(TColumn column, String newColumnName)
Rename a column- Parameters:
column- columnnewColumnName- new column name
-
renameColumn
public void renameColumn(String columnName, String newColumnName)
Rename a column- Parameters:
columnName- column namenewColumnName- new column name
-
renameColumn
public void renameColumn(int index, String newColumnName)Rename a column- Parameters:
index- column indexnewColumnName- new column name
-
dropColumn
public void dropColumn(TColumn column)
Drop a column- Parameters:
column- column to drop
-
dropColumn
public void dropColumn(String columnName)
Drop a column- Parameters:
columnName- column name
-
dropColumn
public void dropColumn(int index)
Drop a column- Parameters:
index- column index
-
alterColumn
public void alterColumn(TColumn column)
Alter a column- Parameters:
column- altered column
-
hasSchema
public boolean hasSchema()
Check if any columns have an in-memory data columns schema- Returns:
- true if has a column schema
- Since:
- 6.6.7
-
-