Class SqlRow

java.lang.Object
com.onenetwork.platform.data.sql.SqlRow
All Implemented Interfaces:
com.onenetwork.platform.data.sql.impl.QueryResult

public class SqlRow
extends java.lang.Object
implements com.onenetwork.platform.data.sql.impl.QueryResult
Contains the result of a query executed through SqlService.

When accessing primitive methods like getIntValue(String), one should call isNull(String) first.

Use of String-based getters is strongly recommended. When index-based access is required, Similar to ResultSet, SqlRow's indexed getters start counting from one, not zero.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.onenetwork.platform.data.sql.impl.QueryResult

    com.onenetwork.platform.data.sql.impl.QueryResult.IsNull
  • Constructor Summary

    Constructors 
    Constructor Description
    SqlRow()  
  • Method Summary

    Modifier and Type Method Description
    void addValue​(java.lang.Object value)
    Add value to row (the value is assumed to conform with the metadata for the row)
    boolean getBooleanValue​(int index)
    Returns the boolean value for the given column index.
    boolean getBooleanValue​(int index, boolean defaultVal)
    Like getBooleanValue(int) but returns defaultVal if actual value is null.
    boolean getBooleanValue​(java.lang.String columnName)
    Returns the boolean value for the given column name.
    boolean getBooleanValue​(java.lang.String columnName, boolean defaultVal)
    Like getBooleanValue(String) but returns defaultVal if actual value is null.
    byte[] getBytesValue​(int index)
    Returns the byte array value for the given column index.
    byte[] getBytesValue​(int index, byte[] defaultVal)
    Like getBytesValue(int) but returns defaultVal if actual value is null.
    byte[] getBytesValue​(java.lang.String columnName)
    Returns the byte array value for the given column name.
    byte[] getBytesValue​(java.lang.String columnName, byte[] defaultVal)
    Like getBytesValue(String) but returns defaultVal if actual value is null.
    byte getByteValue​(int index)
    Returns the byte value for the given column index.
    byte getByteValue​(int index, byte defaultVal)
    Like getByteValue(int) but returns defaultVal if actual value is null.
    byte getByteValue​(java.lang.String columnName)
    Returns the byte value for the given column name.
    byte getByteValue​(java.lang.String columnName, byte defaultVal)
    Like getByteValue(String) but returns defaultVal if actual value is null.
    java.io.Reader getCharacterStreamValue​(int index)
    Returns the character Reader value for the given column index.
    java.io.Reader getCharacterStreamValue​(int index, java.io.Reader defaultVal)
    Like getCharacterStreamValue(int) but returns defaultVal if actual value is null.
    java.io.Reader getCharacterStreamValue​(java.lang.String columnName)
    Returns the character Reader value for the given column name.
    java.io.Reader getCharacterStreamValue​(java.lang.String columnName, java.io.Reader defaultVal)
    Like getCharacterStreamValue(String) but returns defaultVal if actual value is null.
    int getColumnCount()
    Returns the total number of columnns in the row
    double getDoubleValue​(int index)
    Returns the double value for the given column index.
    double getDoubleValue​(int index, double defaultVal)
    Like getDoubleValue(int) but returns defaultVal if actual value is null.
    double getDoubleValue​(java.lang.String columnName)
    Returns the double value for the given column name.
    double getDoubleValue​(java.lang.String columnName, double defaultVal)
    Like getDoubleValue(String) but returns defaultVal if actual value is null.
    float getFloatValue​(int index)
    Returns the float value for the given column index.
    float getFloatValue​(int index, float defaultVal)
    Like getFloatValue(int) but returns defaultVal if actual value is null.
    float getFloatValue​(java.lang.String columnName)
    Returns the float value for the given column name.
    float getFloatValue​(java.lang.String columnName, float defaultVal)
    Like getFloatValue(String) but returns defaultVal if actual value is null.
    int getIntValue​(int index)
    Returns the int value for the given column index.
    int getIntValue​(int index, int defaultVal)
    Like getIntValue(int) but returns defaultVal if actual value is null.
    int getIntValue​(java.lang.String columnName)
    Returns the int value for the given column name.
    int getIntValue​(java.lang.String columnName, int defaultVal)
    Like getIntValue(String) but returns defaultVal if actual value is null.
    int getLength()  
    long getLongValue​(int index)
    Returns the long value for the given column index.
    long getLongValue​(int index, long defaultVal)
    Like getLongValue(int) but returns defaultVal if actual value is null.
    long getLongValue​(java.lang.String columnName)
    Returns the long value for the given column name.
    long getLongValue​(java.lang.String columnName, long defaultVal)
    Like getLongValue(String) but returns defaultVal if actual value is null.
    java.lang.Number getNumericValue​(int index, java.lang.Class<? extends java.lang.Number> numericClass)
    Returns the value for the given column index (may be null) as a Number.
    java.lang.Number getNumericValue​(int index, java.lang.Class<? extends java.lang.Number> numericClass, java.lang.Number defaultVal)
    Like getNumericValue(int, Class) but returns defaultVal if actual value is null.
    short getShortValue​(int index)
    Returns the short value for the given column index.
    short getShortValue​(int index, short defaultVal)
    Like getShortValue(int) but returns defaultVal if actual value is null.
    short getShortValue​(java.lang.String columnName)
    Returns the short value for the given column name.
    short getShortValue​(java.lang.String columnName, short defaultVal)
    Like getShortValue(String) but returns defaultVal if actual value is null.
    SqlResultMeta getSqlResultMeta()  
    java.lang.String getStringValue​(int index)
    Returns the String value for the given column index (may be null)
    java.lang.String getStringValue​(int index, java.lang.String defaultVal)
    Like getStringValue(int) but returns defaultVal if actual value is null.
    java.lang.String getStringValue​(java.lang.String columnName)
    Returns the String value for the given column name (may be null)
    java.lang.String getStringValue​(java.lang.String columnName, java.lang.String defaultVal)
    Like getStringValue(String) but returns defaultVal if actual value is null.
    java.sql.Timestamp getTimestampUTCValue​(int index)
    Deprecated.
    This method currently just calls getTimestampValue(int), it is not intended to be used.
    java.sql.Timestamp getTimestampUTCValue​(int index, java.sql.Timestamp defaultVal)
    Deprecated.
    Like getTimestampUTCValue(int) but returns defaultVal if actual value is null.
    java.sql.Timestamp getTimestampUTCValue​(java.lang.String columnName)
    Deprecated.
    This method currently just calls getTimestampValue(String), it is not intended to be used.
    java.sql.Timestamp getTimestampUTCValue​(java.lang.String columnName, java.sql.Timestamp defaultVal)
    Deprecated.
    Like getTimestampUTCValue(String) but returns defaultVal if actual value is null.
    java.sql.Timestamp getTimestampValue​(int index)
    Returns the Timestamp value for the given column index.
    java.sql.Timestamp getTimestampValue​(int index, java.sql.Timestamp defaultVal)
    Like getTimestampValue(int) but returns defaultVal if actual value is null.
    java.sql.Timestamp getTimestampValue​(java.lang.String columnName)
    Returns the Timestamp value for the given column name.
    java.sql.Timestamp getTimestampValue​(java.lang.String columnName, java.sql.Timestamp defaultVal)
    Like getTimestampValue(String) but returns defaultVal if actual value is null.
    java.lang.Object getValue​(int index)
    Returns the value for the given column index (may be null)
    java.lang.Object getValue​(int index, java.lang.Object defaultVal)
    Like getValue(int) but returns defaultVal if actual value is null.
    java.lang.Object getValue​(java.lang.String columnName)
    Returns the value for the given column name (may be null)
    java.lang.Object getValue​(java.lang.String columnName, java.lang.Object defaultVal)
    Like getValue(String) but returns defaultVal if actual value is null.
    boolean isNull​(int index)
    Returns true iff the value at the given index is null.
    boolean isNull​(java.lang.String columnName)
    Returns true iff the value at the given index is null.
    com.onenetwork.platform.data.sql.impl.QueryResult.IsNull isNullValue​(int index)
    Deprecated.
    not meant for use by clients
    com.onenetwork.platform.data.sql.impl.QueryResult.IsNull isNullValue​(java.lang.String column)
    Deprecated.
    not meant for use by clients
    void setSqlResultMeta​(SqlResultMeta meta)
    Sets the row metadata (describes columns/types)
    java.lang.String toString()  
    boolean wasNull()
    Deprecated.
    not meant for use by clients

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • setSqlResultMeta

      public void setSqlResultMeta​(SqlResultMeta meta)
      Sets the row metadata (describes columns/types)
      Parameters:
      meta - row metadata
    • getValue

      public java.lang.Object getValue​(int index, java.lang.Object defaultVal)
      Like getValue(int) but returns defaultVal if actual value is null.
    • getValue

      public java.lang.Object getValue​(int index)
      Returns the value for the given column index (may be null)
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • isNull

      public boolean isNull​(int index)
      Returns true iff the value at the given index is null. Should always be called before calling primitive getters like #getIntValue(index).
      Parameters:
      index - column index - the first column is 1
      Returns:
      true if the value at the given index is null
    • isNull

      public boolean isNull​(java.lang.String columnName)
      Returns true iff the value at the given index is null. Should always be called before calling primitive getters like #getIntValue(index).
      Parameters:
      columnName - column name
      Returns:
      true if the value at the given column is null
    • getValue

      public java.lang.Object getValue​(java.lang.String columnName, java.lang.Object defaultVal)
      Like getValue(String) but returns defaultVal if actual value is null.
    • getValue

      public java.lang.Object getValue​(java.lang.String columnName)
      Returns the value for the given column name (may be null)
      Parameters:
      columnName - column name
      Returns:
      value of column
    • getNumericValue

      public java.lang.Number getNumericValue​(int index, java.lang.Class<? extends java.lang.Number> numericClass, java.lang.Number defaultVal)
      Like getNumericValue(int, Class) but returns defaultVal if actual value is null.
    • getNumericValue

      public java.lang.Number getNumericValue​(int index, java.lang.Class<? extends java.lang.Number> numericClass)
      Returns the value for the given column index (may be null) as a Number. Any underlying numeric type (int, long, short, etc) can use this method.
      Parameters:
      index - column index - the first column is 1
      numericClass - Number subclass to which the value should be converted
      Returns:
      numeric value, converted to the given type
    • getStringValue

      public java.lang.String getStringValue​(int index, java.lang.String defaultVal)
      Like getStringValue(int) but returns defaultVal if actual value is null.
    • getStringValue

      public java.lang.String getStringValue​(int index)
      Returns the String value for the given column index (may be null)
      Specified by:
      getStringValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getStringValue

      public java.lang.String getStringValue​(java.lang.String columnName, java.lang.String defaultVal)
      Like getStringValue(String) but returns defaultVal if actual value is null.
    • getStringValue

      public java.lang.String getStringValue​(java.lang.String columnName)
      Returns the String value for the given column name (may be null)
      Specified by:
      getStringValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getLongValue

      public long getLongValue​(int index, long defaultVal)
      Like getLongValue(int) but returns defaultVal if actual value is null.
    • getLongValue

      public long getLongValue​(int index)
      Returns the long value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getLongValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getLongValue

      public long getLongValue​(java.lang.String columnName, long defaultVal)
      Like getLongValue(String) but returns defaultVal if actual value is null.
    • getLongValue

      public long getLongValue​(java.lang.String columnName)
      Returns the long value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getLongValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getIntValue

      public int getIntValue​(int index, int defaultVal)
      Like getIntValue(int) but returns defaultVal if actual value is null.
    • getIntValue

      public int getIntValue​(int index)
      Returns the int value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getIntValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getIntValue

      public int getIntValue​(java.lang.String columnName, int defaultVal)
      Like getIntValue(String) but returns defaultVal if actual value is null.
    • getIntValue

      public int getIntValue​(java.lang.String columnName)
      Returns the int value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getIntValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getByteValue

      public byte getByteValue​(int index, byte defaultVal)
      Like getByteValue(int) but returns defaultVal if actual value is null.
    • getByteValue

      public byte getByteValue​(int index)
      Returns the byte value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getByteValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getByteValue

      public byte getByteValue​(java.lang.String columnName, byte defaultVal)
      Like getByteValue(String) but returns defaultVal if actual value is null.
    • getByteValue

      public byte getByteValue​(java.lang.String columnName)
      Returns the byte value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getByteValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getShortValue

      public short getShortValue​(int index, short defaultVal)
      Like getShortValue(int) but returns defaultVal if actual value is null.
    • getShortValue

      public short getShortValue​(int index)
      Returns the short value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getShortValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getShortValue

      public short getShortValue​(java.lang.String columnName, short defaultVal)
      Like getShortValue(String) but returns defaultVal if actual value is null.
    • getShortValue

      public short getShortValue​(java.lang.String columnName)
      Returns the short value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getShortValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getFloatValue

      public float getFloatValue​(int index, float defaultVal)
      Like getFloatValue(int) but returns defaultVal if actual value is null.
    • getFloatValue

      public float getFloatValue​(int index)
      Returns the float value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getFloatValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getFloatValue

      public float getFloatValue​(java.lang.String columnName, float defaultVal)
      Like getFloatValue(String) but returns defaultVal if actual value is null.
    • getFloatValue

      public float getFloatValue​(java.lang.String columnName)
      Returns the float value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getFloatValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getDoubleValue

      public double getDoubleValue​(int index, double defaultVal)
      Like getDoubleValue(int) but returns defaultVal if actual value is null.
    • getDoubleValue

      public double getDoubleValue​(int index)
      Returns the double value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getDoubleValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getDoubleValue

      public double getDoubleValue​(java.lang.String columnName, double defaultVal)
      Like getDoubleValue(String) but returns defaultVal if actual value is null.
    • getDoubleValue

      public double getDoubleValue​(java.lang.String columnName)
      Returns the double value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getDoubleValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getTimestampValue

      public java.sql.Timestamp getTimestampValue​(int index, java.sql.Timestamp defaultVal)
      Like getTimestampValue(int) but returns defaultVal if actual value is null.
    • getTimestampValue

      public java.sql.Timestamp getTimestampValue​(int index)
      Returns the Timestamp value for the given column index.
      Specified by:
      getTimestampValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getTimestampUTCValue

      public java.sql.Timestamp getTimestampUTCValue​(int index, java.sql.Timestamp defaultVal)
      Deprecated.
      Like getTimestampUTCValue(int) but returns defaultVal if actual value is null.
    • getTimestampUTCValue

      public java.sql.Timestamp getTimestampUTCValue​(int index)
      Deprecated.
      This method currently just calls getTimestampValue(int), it is not intended to be used.
      Specified by:
      getTimestampUTCValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • getTimestampValue

      public java.sql.Timestamp getTimestampValue​(java.lang.String columnName, java.sql.Timestamp defaultVal)
      Like getTimestampValue(String) but returns defaultVal if actual value is null.
    • getTimestampValue

      public java.sql.Timestamp getTimestampValue​(java.lang.String columnName)
      Returns the Timestamp value for the given column name.
      Specified by:
      getTimestampValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getTimestampUTCValue

      public java.sql.Timestamp getTimestampUTCValue​(java.lang.String columnName, java.sql.Timestamp defaultVal)
      Deprecated.
      Like getTimestampUTCValue(String) but returns defaultVal if actual value is null.
    • getTimestampUTCValue

      public java.sql.Timestamp getTimestampUTCValue​(java.lang.String columnName)
      Deprecated.
      This method currently just calls getTimestampValue(String), it is not intended to be used.
      Specified by:
      getTimestampUTCValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • getBooleanValue

      public boolean getBooleanValue​(int index, boolean defaultVal)
      Like getBooleanValue(int) but returns defaultVal if actual value is null.
    • getBooleanValue

      public boolean getBooleanValue​(int index)
      Returns the boolean value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getBooleanValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getBooleanValue

      public boolean getBooleanValue​(java.lang.String columnName, boolean defaultVal)
      Like getBooleanValue(String) but returns defaultVal if actual value is null.
    • getBooleanValue

      public boolean getBooleanValue​(java.lang.String columnName)
      Returns the boolean value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getBooleanValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • addValue

      public void addValue​(java.lang.Object value)
      Add value to row (the value is assumed to conform with the metadata for the row)
      Parameters:
      value - value to add at end of list
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getBytesValue

      public byte[] getBytesValue​(int index, byte[] defaultVal)
      Like getBytesValue(int) but returns defaultVal if actual value is null.
    • getBytesValue

      public byte[] getBytesValue​(int index)
      Returns the byte array value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getBytesValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getCharacterStreamValue

      public java.io.Reader getCharacterStreamValue​(int index, java.io.Reader defaultVal)
      Like getCharacterStreamValue(int) but returns defaultVal if actual value is null.
    • getCharacterStreamValue

      public java.io.Reader getCharacterStreamValue​(int index)
      Returns the character Reader value for the given column index. Client should first call isNull(int) to see if the value is null.
      Specified by:
      getCharacterStreamValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      index - column index - the first column is 1
      Returns:
      value at index
    • getBytesValue

      public byte[] getBytesValue​(java.lang.String columnName, byte[] defaultVal)
      Like getBytesValue(String) but returns defaultVal if actual value is null.
    • getBytesValue

      public byte[] getBytesValue​(java.lang.String columnName)
      Returns the byte array value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getBytesValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • getCharacterStreamValue

      public java.io.Reader getCharacterStreamValue​(java.lang.String columnName, java.io.Reader defaultVal)
      Like getCharacterStreamValue(String) but returns defaultVal if actual value is null.
    • getCharacterStreamValue

      public java.io.Reader getCharacterStreamValue​(java.lang.String columnName)
      Returns the character Reader value for the given column name. Client should first call isNull(String) to see if the value is null.
      Specified by:
      getCharacterStreamValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
      Parameters:
      columnName - column name
      Returns:
      value for column
    • wasNull

      public boolean wasNull()
      Deprecated.
      not meant for use by clients
      Specified by:
      wasNull in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • isNullValue

      public com.onenetwork.platform.data.sql.impl.QueryResult.IsNull isNullValue​(int index)
      Deprecated.
      not meant for use by clients
      Specified by:
      isNullValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • isNullValue

      public com.onenetwork.platform.data.sql.impl.QueryResult.IsNull isNullValue​(java.lang.String column)
      Deprecated.
      not meant for use by clients
      Specified by:
      isNullValue in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • getColumnCount

      public int getColumnCount()
      Returns the total number of columnns in the row
      Specified by:
      getColumnCount in interface com.onenetwork.platform.data.sql.impl.QueryResult
    • getSqlResultMeta

      public SqlResultMeta getSqlResultMeta()
      Returns:
      result meta-data, including column-to-index mapping
    • getLength

      public int getLength()
      Returns:
      the number of columns in the row