Class ValueGetter<T>
java.lang.Object
org.apache.sis.internal.sql.feature.ValueGetter<T>
- Type Parameters:
T- type of values in the column.
- Direct Known Subclasses:
GeometryGetter,ObjectGetter,RasterGetter,ValueGetter.AsArray,ValueGetter.AsBigDecimal,ValueGetter.AsBoolean,ValueGetter.AsByte,ValueGetter.AsBytes,ValueGetter.AsDate,ValueGetter.AsDouble,ValueGetter.AsFloat,ValueGetter.AsInstant,ValueGetter.AsInteger,ValueGetter.AsLocalTime,ValueGetter.AsLong,ValueGetter.AsObject,ValueGetter.AsOffsetDateTime,ValueGetter.AsOffsetTime,ValueGetter.AsShort,ValueGetter.AsString
Description of the type of values in a column, together with a method for fetching the values from a result set.
The
ValueGetter getter method will typically delegate to the most appropriate ResultSet getter
method for the column type, but may also perform some conversions such as parsing geometry Well-Known Binary (WKB).
The getValue(InfoStatements, ResultSet, int) method is invoked with the result set cursor placed on the
row of interest. The index of the column to read must be specified. It allows to reuse the same ValueGetter
instance for an arbitrary number of columns.
Multi-threading
ValueGetter instances shall be thread-safe.- Since:
- 1.1
- Version:
- 1.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classA getter of values specified as Java array.(package private) static final classA getter ofBigDecimalvalues from the current row of aResultSet.(package private) static final class(package private) static final class(package private) static final classA getter ofbyte[]values from the current row of aResultSet.(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final classA getter ofOffsetDateTimevalues from the current row of aResultSet.(package private) static final classA getter ofOffsetDateTimevalues from the current row of aResultSet.(package private) static final class(package private) static final class -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedValueGetter(Class<? extends T> valueType) Creates a new column value getter. -
Method Summary
Modifier and TypeMethodDescriptionabstract TgetValue(InfoStatements stmts, ResultSet source, int columnIndex) Gets the value in the column at specified index.protected static Collection<?>toCollection(InfoStatements stmts, ValueGetter<?> cmget, Array array) Converts the given SQL array to a Java array and free the SQL array.
-
Field Details
-
valueType
The type of Java objects fetched from the column. The value shall not be a primitive type; the wrapper class shall be used instead. The value may be an array of a primitive type however.
-
-
Constructor Details
-
ValueGetter
Creates a new column value getter.- Parameters:
valueType- the type of Java objects fetched from the column.
-
-
Method Details
-
getValue
public abstract T getValue(InfoStatements stmts, ResultSet source, int columnIndex) throws Exception Gets the value in the column at specified index. The given result set must have its cursor position on the line to read. This method does not modify the cursor position.Note: Thestmtsis the same reference for all features created by a newFeatureIteratorinstance, including its dependencies. But thesourcewill vary depending on whether we are iterating over the main feature or one of its dependencies.- Parameters:
stmts- prepared statements for fetching CRS from SRID, ornullif none.source- the result set from which to get the value.columnIndex- index of the column in which to get the value.- Returns:
- value in the given column. May be
null. - Throws:
Exception- if an error occurred. May be an SQL error, a WKB parsing error, etc.
-
toCollection
protected static Collection<?> toCollection(InfoStatements stmts, ValueGetter<?> cmget, Array array) throws Exception Converts the given SQL array to a Java array and free the SQL array. The returned array may be a primitive array or an array of objects.- Parameters:
stmts- information about the statement being executed, ornullif none.cmget- the getter for components in the array, ornullfor automatic.array- the SQL array, ornullif none.- Returns:
- the Java array, or
nullif the given SQL array is null. - Throws:
Exception- if an error occurred. May be an SQL error, a WKB parsing error, etc.
-