Package org.apache.calcite.avatica.util

## Class AbstractCursor

- java.lang.Object
- - org.apache.calcite.avatica.util.AbstractCursor

All Implemented Interfaces:
  `java.lang.AutoCloseable`, `Cursor`

Direct Known Subclasses:
  `PositionedCursor`

    public abstract class AbstractCursor
    extends java.lang.Object
    implements Cursor

Base class for implementing a cursor.

Derived class needs to provide `AbstractCursor.Getter` and can override `Cursor.Accessor` implementations if it wishes.

### Nested Class Summary

Nested Classes
`protected class` `AbstractCursor.AbstractGetter` Abstract implementation of `AbstractCursor.Getter`.
`(package private) static class` `AbstractCursor.AccessorImpl` Implementation of `Cursor.Accessor`.
`private static class` `AbstractCursor.ApproximateNumericAccessor` Accessor of values that are `Double` or null.
`static class` `AbstractCursor.ArrayAccessor` Accessor that assumes that the underlying value is an ARRAY; corresponds to `Types.ARRAY`.
`private static class` `AbstractCursor.BigDecimalAccessor` Accessor that assumes that the underlying value is a `BigDecimal`; corresponds to `Types.DECIMAL`.
`private static class` `AbstractCursor.BigNumberAccessor` Accessor of exact numeric values.
`private static class` `AbstractCursor.BinaryAccessor` Accessor that assumes that the underlying value is an array of `ByteString` values; corresponds to `Types.BINARY` and `Types.VARBINARY`.
`private static class` `AbstractCursor.BinaryFromStringAccessor` Accessor that assumes that the underlying value is a `String`, encoding `Types.BINARY` and `Types.VARBINARY` values in Base64 format.
`private static class` `AbstractCursor.BooleanAccessor` Accessor that assumes that the underlying value is a `Boolean`; corresponds to `Types.BOOLEAN`.
`private static class` `AbstractCursor.ByteAccessor` Accessor that assumes that the underlying value is a `Byte`; corresponds to `Types.TINYINT`.
`private static class` `AbstractCursor.DateAccessor` Accessor that assumes that the underlying value is a DATE, represented as a java.sql.Date; corresponds to `Types.DATE`.
`private static class` `AbstractCursor.DateFromNumberAccessor` Accessor that assumes that the underlying value is a DATE, in its default representation `int`; corresponds to `Types.DATE`.
`private static class` `AbstractCursor.DoubleAccessor` Accessor that assumes that the underlying value is a `Double`; corresponds to `Types.DOUBLE`.
`private static class` `AbstractCursor.ExactNumericAccessor` Accessor of exact numeric values.
`private static class` `AbstractCursor.FixedStringAccessor` Accessor that assumes that the underlying value is a `String`; corresponds to `Types.CHAR`.
`private static class` `AbstractCursor.FloatAccessor` Accessor that assumes that the underlying value is a `Float`; corresponds to `Types.FLOAT`.
`protected static interface` `AbstractCursor.Getter` Gets a value from a particular field of the current record of this cursor.
`private static class` `AbstractCursor.IntAccessor` Accessor that assumes that the underlying value is an `Integer`; corresponds to `Types.INTEGER`.
`private static class` `AbstractCursor.IntervalDayTimeAccessor` Accessor that assumes that the underlying value is a `long`; corresponds to `Types.OTHER`.
`private static class` `AbstractCursor.IntervalYearMonthAccessor` Accessor that assumes that the underlying value is a `int`; corresponds to `Types.OTHER`.
`private static class` `AbstractCursor.LongAccessor` Accessor that assumes that the underlying value is a `Long`; corresponds to `Types.BIGINT`.
`(package private) static class` `AbstractCursor.NumberAccessor` Accessor that assumes that the underlying value is a `Number`; corresponds to `Types.NUMERIC`.
`private static class` `AbstractCursor.ObjectAccessor` Accessor that assumes that the underlying value is an OBJECT; corresponds to `Types.JAVA_OBJECT`.
`private static class` `AbstractCursor.ShortAccessor` Accessor that assumes that the underlying value is a `Short`; corresponds to `Types.SMALLINT`.
`class` `AbstractCursor.SlotGetter` Implementation of `AbstractCursor.Getter` that returns the current contents of a mutable slot.
`private static class` `AbstractCursor.StringAccessor` Accessor that assumes that the underlying value is a `String`; corresponds to `Types.CHAR` and `Types.VARCHAR`.
`private static class` `AbstractCursor.StringFromCharAccessor` Accessor that assumes that the underlying value is a `String`; corresponds to `Types.CHAR`.
`private static class` `AbstractCursor.StructAccessor` Accessor that assumes that the underlying value is a STRUCT; corresponds to `Types.STRUCT`.
`class` `AbstractCursor.StructGetter` Implementation of `AbstractCursor.Getter` that returns the value of a given field of the current contents of another getter.
`private static class` `AbstractCursor.TimeAccessor` Accessor that assumes that the underlying value is a TIME, represented as a java.sql.Time; corresponds to `Types.TIME`.
`private static class` `AbstractCursor.TimeFromNumberAccessor` Accessor that assumes that the underlying value is a Time, in its default representation `int`; corresponds to `Types.TIME`.
`private static class` `AbstractCursor.TimestampAccessor` Accessor that assumes that the underlying value is a TIMESTAMP, represented as a java.sql.Timestamp; corresponds to `Types.TIMESTAMP`.
`private static class` `AbstractCursor.TimestampFromNumberAccessor` Accessor that assumes that the underlying value is a TIMESTAMP, in its default representation `long`; corresponds to `Types.TIMESTAMP`.
`private static class` `AbstractCursor.TimestampFromUtilDateAccessor` Accessor that assumes that the underlying value is a TIMESTAMP, represented as a java.util.Date; corresponds to `Types.TIMESTAMP`.

### Nested classes/interfaces inherited from interface org.apache.calcite.avatica.util.Cursor

`Cursor.Accessor`

### Field Summary

Fields
`protected boolean[]` `wasNull` Slot into which each accessor should write whether the value returned was null.

### Constructor Summary

Constructors
`protected` `AbstractCursor()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`protected Cursor.Accessor` `createAccessor​(ColumnMetaData columnMetaData, int ordinal, java.util.Calendar localCalendar, ArrayImpl.Factory factory)`
`protected Cursor.Accessor` `createAccessor​(ColumnMetaData columnMetaData, AbstractCursor.Getter getter, java.util.Calendar localCalendar, ArrayImpl.Factory factory)`
`java.util.List<Cursor.Accessor>` `createAccessors​(java.util.List<ColumnMetaData> types, java.util.Calendar localCalendar, ArrayImpl.Factory factory)` Creates a list of accessors, one per column.
`protected abstract AbstractCursor.Getter` `createGetter​(int ordinal)`
`private static java.lang.String` `dateAsString​(int v, java.util.Calendar calendar)` Accesses a date value as a string, e.g.
`(package private) static java.sql.Time` `intToTime​(int v, java.util.Calendar calendar)`
`private static java.sql.Date` `longToDate​(long v, java.util.Calendar calendar)`
`(package private) static java.sql.Timestamp` `longToTimestamp​(long v, java.util.Calendar calendar)`
`abstract boolean` `next()` Moves to the next row.
`private static java.lang.String` `timeAsString​(int v, java.util.Calendar calendar)` Accesses a time value as a string, e.g.
`private static java.lang.String` `timestampAsString​(long v, java.util.Calendar calendar)` Accesses a timestamp value as a string.
`boolean` `wasNull()` Returns whether the last value returned was null.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.calcite.avatica.util.Cursor

`close`

### Field Detail

#### wasNull

    protected final boolean[] wasNull

Slot into which each accessor should write whether the value returned was null.

### Constructor Detail

#### AbstractCursor

    protected AbstractCursor()

### Method Detail

#### wasNull

    public boolean wasNull()

Description copied from interface: `Cursor`
Returns whether the last value returned was null.

Specified by:
  `wasNull` in interface `Cursor`

#### createAccessors

    public java.util.List<Cursor.Accessor> createAccessors​(java.util.List<ColumnMetaData> types,
                                                           java.util.Calendar localCalendar,
                                                           ArrayImpl.Factory factory)

Description copied from interface: `Cursor`
Creates a list of accessors, one per column.

Specified by:
  `createAccessors` in interface `Cursor`
Parameters:
  `types` - List of column types, per `Types`.
  `localCalendar` - Calendar in local time zone
  `factory` - Factory that creates sub-ResultSets when needed
Returns:
  List of column accessors

#### createAccessor

    protected Cursor.Accessor createAccessor​(ColumnMetaData columnMetaData,
                                             int ordinal,
                                             java.util.Calendar localCalendar,
                                             ArrayImpl.Factory factory)

#### createAccessor

    protected Cursor.Accessor createAccessor​(ColumnMetaData columnMetaData,
                                             AbstractCursor.Getter getter,
                                             java.util.Calendar localCalendar,
                                             ArrayImpl.Factory factory)

#### createGetter

    protected abstract AbstractCursor.Getter createGetter​(int ordinal)

#### next

    public abstract boolean next()

Description copied from interface: `Cursor`
Moves to the next row.

Specified by:
  `next` in interface `Cursor`
Returns:
  Whether moved

#### timestampAsString

    private static java.lang.String timestampAsString​(long v,
                                                      java.util.Calendar calendar)

Accesses a timestamp value as a string. The timestamp is in SQL format (e.g. "2013-09-22 22:30:32"), not Java format ("2013-09-22 22:30:32.123").

#### dateAsString

    private static java.lang.String dateAsString​(int v,
                                                 java.util.Calendar calendar)

Accesses a date value as a string, e.g. "2013-09-22".

#### timeAsString

    private static java.lang.String timeAsString​(int v,
                                                 java.util.Calendar calendar)

Accesses a time value as a string, e.g. "22:30:32".

#### longToDate

    private static java.sql.Date longToDate​(long v,
                                            java.util.Calendar calendar)

#### intToTime

    static java.sql.Time intToTime​(int v,
                                   java.util.Calendar calendar)

#### longToTimestamp

    static java.sql.Timestamp longToTimestamp​(long v,
                                              java.util.Calendar calendar)