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 protected
UserColumns(String tableName, List<TColumn> columns, boolean custom)
Constructorprotected
UserColumns(UserColumns<TColumn> userColumns)
Copy Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addColumn(TColumn column)
Add a new columnvoid
alterColumn(TColumn column)
Alter a columnint
columnCount()
Get the column countList<TColumn>
columnsOfType(GeoPackageDataType type)
Get the columns with the provided data typeabstract UserColumns<TColumn>
copy()
Copy the user columnsvoid
dropColumn(int index)
Drop a columnvoid
dropColumn(String columnName)
Drop a columnvoid
dropColumn(TColumn column)
Drop a columnprotected void
duplicateCheck(int index, Integer previousIndex, String column)
Check for duplicate column namesTColumn
getColumn(int index)
Get the column at the indexTColumn
getColumn(String columnName)
Get the column of the column nameint
getColumnIndex(String columnName)
Get the column index of the column nameInteger
getColumnIndex(String columnName, boolean required)
Get the column index of the column nameString
getColumnName(int index)
Get the column name at the indexString[]
getColumnNames()
Get the array of column namesList<TColumn>
getColumns()
Get the list of columnsTColumn
getPkColumn()
Get the primary key columnint
getPkColumnIndex()
Get the primary key column indexString
getPkColumnName()
Get the primary key column nameString
getTableName()
Get the table nameboolean
hasColumn(String columnName)
Check if the table has the columnboolean
hasPkColumn()
Check if the table has a primary key columnboolean
hasSchema()
Check if any columns have an in-memory data columns schemaboolean
isCustom()
Is custom column specification (partial and/or ordering)boolean
isPkModifiable()
Is the primary key modifiableboolean
isValueValidation()
Is value validation against column types enabledprotected void
missingCheck(Integer index, String column)
Check for missing columnsvoid
renameColumn(int index, String newColumnName)
Rename a columnvoid
renameColumn(String columnName, String newColumnName)
Rename a columnvoid
renameColumn(TColumn column, String newColumnName)
Rename a columnvoid
setCustom(boolean custom)
Set the custom column specification flagvoid
setPkModifiable(boolean pkModifiable)
Set if the primary key can be modifiedvoid
setTableName(String tableName)
Set the table namevoid
setValueValidation(boolean valueValidation)
Set if values should validated against column typesprotected void
typeCheck(GeoPackageDataType expected, TColumn column)
Check for the expected data typeprotected void
updateColumns()
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
-
-