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.Getterand can overrideCursor.Accessorimplementations if it wishes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractCursor.AbstractGetterAbstract implementation ofAbstractCursor.Getter.(package private) static classAbstractCursor.AccessorImplImplementation ofCursor.Accessor.private static classAbstractCursor.ApproximateNumericAccessorAccessor of values that areDoubleor null.static classAbstractCursor.ArrayAccessorAccessor that assumes that the underlying value is an ARRAY; corresponds toTypes.ARRAY.private static classAbstractCursor.BigDecimalAccessorAccessor that assumes that the underlying value is aBigDecimal; corresponds toTypes.DECIMAL.private static classAbstractCursor.BigNumberAccessorAccessor of exact numeric values.private static classAbstractCursor.BinaryAccessorAccessor that assumes that the underlying value is an array ofByteStringvalues; corresponds toTypes.BINARYandTypes.VARBINARY.private static classAbstractCursor.BinaryFromStringAccessorAccessor that assumes that the underlying value is aString, encodingTypes.BINARYandTypes.VARBINARYvalues in Base64 format.private static classAbstractCursor.BooleanAccessorAccessor that assumes that the underlying value is aBoolean; corresponds toTypes.BOOLEAN.private static classAbstractCursor.ByteAccessorAccessor that assumes that the underlying value is aByte; corresponds toTypes.TINYINT.private static classAbstractCursor.DateAccessorAccessor that assumes that the underlying value is a DATE, represented as a java.sql.Date; corresponds toTypes.DATE.private static classAbstractCursor.DateFromNumberAccessorAccessor that assumes that the underlying value is a DATE, in its default representationint; corresponds toTypes.DATE.private static classAbstractCursor.DoubleAccessorAccessor that assumes that the underlying value is aDouble; corresponds toTypes.DOUBLE.private static classAbstractCursor.ExactNumericAccessorAccessor of exact numeric values.private static classAbstractCursor.FixedStringAccessorAccessor that assumes that the underlying value is aString; corresponds toTypes.CHAR.private static classAbstractCursor.FloatAccessorAccessor that assumes that the underlying value is aFloat; corresponds toTypes.FLOAT.protected static interfaceAbstractCursor.GetterGets a value from a particular field of the current record of this cursor.private static classAbstractCursor.IntAccessorAccessor that assumes that the underlying value is anInteger; corresponds toTypes.INTEGER.private static classAbstractCursor.IntervalDayTimeAccessorAccessor that assumes that the underlying value is along; corresponds toTypes.OTHER.private static classAbstractCursor.IntervalYearMonthAccessorAccessor that assumes that the underlying value is aint; corresponds toTypes.OTHER.private static classAbstractCursor.LongAccessorAccessor that assumes that the underlying value is aLong; corresponds toTypes.BIGINT.(package private) static classAbstractCursor.NumberAccessorAccessor that assumes that the underlying value is aNumber; corresponds toTypes.NUMERIC.private static classAbstractCursor.ObjectAccessorAccessor that assumes that the underlying value is an OBJECT; corresponds toTypes.JAVA_OBJECT.private static classAbstractCursor.ShortAccessorAccessor that assumes that the underlying value is aShort; corresponds toTypes.SMALLINT.classAbstractCursor.SlotGetterImplementation ofAbstractCursor.Getterthat returns the current contents of a mutable slot.private static classAbstractCursor.StringAccessorAccessor that assumes that the underlying value is aString; corresponds toTypes.CHARandTypes.VARCHAR.private static classAbstractCursor.StringFromCharAccessorAccessor that assumes that the underlying value is aString; corresponds toTypes.CHAR.private static classAbstractCursor.StructAccessorAccessor that assumes that the underlying value is a STRUCT; corresponds toTypes.STRUCT.classAbstractCursor.StructGetterImplementation ofAbstractCursor.Getterthat returns the value of a given field of the current contents of another getter.private static classAbstractCursor.TimeAccessorAccessor that assumes that the underlying value is a TIME, represented as a java.sql.Time; corresponds toTypes.TIME.private static classAbstractCursor.TimeFromNumberAccessorAccessor that assumes that the underlying value is a Time, in its default representationint; corresponds toTypes.TIME.private static classAbstractCursor.TimestampAccessorAccessor that assumes that the underlying value is a TIMESTAMP, represented as a java.sql.Timestamp; corresponds toTypes.TIMESTAMP.private static classAbstractCursor.TimestampFromNumberAccessorAccessor that assumes that the underlying value is a TIMESTAMP, in its default representationlong; corresponds toTypes.TIMESTAMP.private static classAbstractCursor.TimestampFromUtilDateAccessorAccessor that assumes that the underlying value is a TIMESTAMP, represented as a java.util.Date; corresponds toTypes.TIMESTAMP.-
Nested classes/interfaces inherited from interface org.apache.calcite.avatica.util.Cursor
Cursor.Accessor
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean[]wasNullSlot into which each accessor should write whether the value returned was null.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCursor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Cursor.AccessorcreateAccessor(ColumnMetaData columnMetaData, int ordinal, java.util.Calendar localCalendar, ArrayImpl.Factory factory)protected Cursor.AccessorcreateAccessor(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.GettercreateGetter(int ordinal)private static java.lang.StringdateAsString(int v, java.util.Calendar calendar)Accesses a date value as a string, e.g.(package private) static java.sql.TimeintToTime(int v, java.util.Calendar calendar)private static java.sql.DatelongToDate(long v, java.util.Calendar calendar)(package private) static java.sql.TimestamplongToTimestamp(long v, java.util.Calendar calendar)abstract booleannext()Moves to the next row.private static java.lang.StringtimeAsString(int v, java.util.Calendar calendar)Accesses a time value as a string, e.g.private static java.lang.StringtimestampAsString(long v, java.util.Calendar calendar)Accesses a timestamp value as a string.booleanwasNull()Returns whether the last value returned was null.
-
-
-
Method Detail
-
wasNull
public boolean wasNull()
Description copied from interface:CursorReturns whether the last value returned was null.
-
createAccessors
public java.util.List<Cursor.Accessor> createAccessors(java.util.List<ColumnMetaData> types, java.util.Calendar localCalendar, ArrayImpl.Factory factory)
Description copied from interface:CursorCreates a list of accessors, one per column.- Specified by:
createAccessorsin interfaceCursor- Parameters:
types- List of column types, perTypes.localCalendar- Calendar in local time zonefactory- 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:CursorMoves to the next row.
-
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)
-
-