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

public abstract class ValueGetter<T> extends Object
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
  • Field Details

    • valueType

      protected final Class<? extends T> 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

      protected ValueGetter(Class<? extends T> valueType)
      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: The stmts is the same reference for all features created by a new FeatureIterator instance, including its dependencies. But the source will 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, or null if 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, or null if none.
      cmget - the getter for components in the array, or null for automatic.
      array - the SQL array, or null if none.
      Returns:
      the Java array, or null if the given SQL array is null.
      Throws:
      Exception - if an error occurred. May be an SQL error, a WKB parsing error, etc.