Class Column
java.lang.Object
org.apache.sis.internal.sql.feature.Column
Information (name, data type…) about a table column. It contains information extracted from
database metadata,
possibly completed with information about a geometry column.
The aim is to describe all information about a column that is needed for mapping to feature model.
Multi-threading
Column instances shall be kept unmodified after all fields have been initialized.
The same instances may be read concurrently by many threads.- Since:
- 1.1
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.opengis.referencing.crs.CoordinateReferenceSystemIf this column is a geometry or raster column, the Coordinate Reference System (CRS).private GeometryTypeIf this column is a geometry column, the type of the geometry objects.final booleanWhether the column can have null values.final StringTitle to use for displays.final StringName of the column.private final intThe column size, or 0 if not applicable.(package private) StringName to use for feature property.final intType of values as one of the constants enumerated inTypesclass.final StringA name for the value type, free-text from the database engine.(package private) ValueGetter<?>Converter fromResultSetcolumn value to value stored in the feature instance. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a synthetic column (a column not inferred from database analysis) for describing the type of elements in an array.Column(ResultSetMetaData metadata, int column, String quote) Creates a new column from the result of a query.Creates a new column from database metadata. -
Method Summary
Modifier and TypeMethodDescription(package private) final AttributeTypeBuilder<?>createAttribute(FeatureTypeBuilder feature) Creates a feature attribute for this column.final Optional<org.opengis.referencing.crs.CoordinateReferenceSystem>If this column is a geometry or raster column, returns the default coordinate reference system.final Optional<GeometryType>If this column is a geometry column, returns the type of the geometry objects.private static StringPostgreSQL JDBC drivers sometimes gives the fully qualified type name.(package private) final voidmakeSpatial(Localized caller, GeometryType type, org.opengis.referencing.crs.CoordinateReferenceSystem crs) Modifies this column for declaring it as a geometry or raster column.toString()Returns a string representation for debugging purposes.
-
Field Details
-
name
Name of the column.- See Also:
-
label
Title to use for displays. This is the name specified by theASkeyword in aSELECTclause. This is never null but may be identical tonameif no label was specified. -
propertyName
String propertyNameName to use for feature property. This is the same aslabelunless there is a name collision. In that case the property name is modified for avoiding the collision. -
type
public final int typeType of values as one of the constants enumerated inTypesclass.- See Also:
-
typeName
A name for the value type, free-text from the database engine. For more information about this, seeDatabaseMetaData.getColumns(String, String, String, String)andReflection.TYPE_NAME. This value shall not be null.- See Also:
-
precision
private final int precisionThe column size, or 0 if not applicable. For texts, this is the maximum number of characters allowed. For numbers, this is the maximum number of digits. For blobs, this is a limit in number of bytes. -
isNullable
public final boolean isNullableWhether the column can have null values.- See Also:
-
geometryType
If this column is a geometry column, the type of the geometry objects. Otherwisenull.- See Also:
-
defaultCRS
private org.opengis.referencing.crs.CoordinateReferenceSystem defaultCRSIf this column is a geometry or raster column, the Coordinate Reference System (CRS). Otherwisenull. This is determined from the geometry Spatial Reference Identifier (SRID).- See Also:
-
valueGetter
ValueGetter<?> valueGetter
-
-
Constructor Details
-
Column
Column(int type, String typeName) Creates a synthetic column (a column not inferred from database analysis) for describing the type of elements in an array.- Parameters:
type- SQL type of the column.typeName- SQL name of the type.
-
Column
Column(Analyzer analyzer, ResultSet metadata, String quote) throws SQLException Creates a new column from database metadata. Information are fetched from currentResultSetrow. This method does not change cursor position.- Parameters:
analyzer- the analyzer which is creating this column.metadata- the result ofDatabaseMetaData.getColumns(…).quote- value ofDatabaseMetaData.getIdentifierQuoteString().- Throws:
SQLException- if an error occurred while fetching metadata.- See Also:
-
Column
Column(ResultSetMetaData metadata, int column, String quote) throws SQLException Creates a new column from the result of a query.- Parameters:
metadata- value ofResultSet.getMetaData().column- index of the column for which to get metadata.quote- value ofDatabaseMetaData.getIdentifierQuoteString().- Throws:
SQLException- if an error occurred while fetching metadata.- See Also:
-
-
Method Details
-
localPart
PostgreSQL JDBC drivers sometimes gives the fully qualified type name. For example, we sometimes get"public"."geometry"(including the quotes) instead of a plaingeometry. If this is the case, keep only the local part.- Parameters:
type- value found in the @value Reflection#TYPE_NAME} column.quote- value ofDatabaseMetaData.getIdentifierQuoteString().- Returns:
- local part of the type name.
- Throws:
SQLDataException
-
makeSpatial
final void makeSpatial(Localized caller, GeometryType type, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws DataStoreContentException Modifies this column for declaring it as a geometry or raster column. This method is invoked during inspection of the"GEOMETRY_COLUMNS"table of a spatial database. It can also be invoked during the inspection of"GEOGRAPHY_COLUMNS"or"RASTER_COLUMNS"tables, which are PostGIS extensions. In the raster case, the geometrytypeargument shall be null.- Parameters:
caller- provider of the locale for error message, if any.type- the type of values in the column, ornullif not geometric.crs- the Coordinate Reference System (CRS), ornullif unknown.- Throws:
DataStoreContentException
-
getGeometryType
If this column is a geometry column, returns the type of the geometry objects. Otherwise returns empty (including the case where this is a raster column). Note that if this column is a geometry column but the geometry type was not defined, thenGeometryType.GEOMETRYis returned as a fallback.- Returns:
- type of geometry objects, or empty if this column is not a geometry column.
-
getDefaultCRS
If this column is a geometry or raster column, returns the default coordinate reference system. Otherwise returns empty. The CRS may also be empty even for a geometry column if it is unspecified.- Returns:
- CRS of geometries or rasters in this column, or empty if unknown or not applicable.
-
createAttribute
Creates a feature attribute for this column. The attribute is appended to the given feature builder. The attribute builder is returned for allowing additional configuration.- Parameters:
feature- the feature where to append an attribute for this column.- Returns:
- builder for the added feature attribute.
-
toString
Returns a string representation for debugging purposes.
-