Package org.h2.result

Class SimpleResult

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  SimpleResult.Column
      Column info for the simple result.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        SimpleResult()
      Creates new instance of simple result.
        SimpleResult​(java.lang.String schemaName, java.lang.String tableName)
      Creates new instance of simple result.
      private SimpleResult​(java.util.ArrayList<SimpleResult.Column> columns, java.util.ArrayList<Value[]> rows, java.lang.String schemaName, java.lang.String tableName)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addColumn​(java.lang.String alias, java.lang.String columnName, int columnType, long columnPrecision, int columnScale)
      Add column to the result.
      void addColumn​(java.lang.String alias, java.lang.String columnName, TypeInfo columnType)
      Add column to the result.
      void addColumn​(java.lang.String columnName, TypeInfo columnType)
      Add column to the result.
      (package private) void addColumn​(SimpleResult.Column column)
      Add column to the result.
      void addRow​(Value... values)
      Add the row to the result set.
      void close()
      Close the result and delete any temporary files
      SimpleResult createShallowCopy​(Session targetSession)
      Create a shallow copy of the result set.
      Value[] currentRow()
      Get the current row.
      java.lang.String getAlias​(int i)
      Get the column alias name for the column.
      java.lang.String getColumnName​(int i)
      Get the column name.
      TypeInfo getColumnType​(int i)
      Get the column data type.
      int getFetchSize()
      Get the current fetch size for this result set.
      int getNullable​(int i)
      Check if this column is nullable.
      long getRowCount()
      Get the number of rows in this object.
      long getRowId()
      Get the current row id, starting with 0.
      java.lang.String getSchemaName​(int i)
      Get the schema name for the column, if one exists.
      java.lang.String getTableName​(int i)
      Get the table name for the column, if one exists.
      int getVisibleColumnCount()
      Get the number of visible columns.
      boolean hasNext()
      Check if this result has more rows to fetch.
      boolean isAfterLast()
      Check if the current position is after last row.
      boolean isClosed()
      Check if this result set is closed.
      boolean isIdentity​(int i)
      Check if this is an identity column.
      boolean isLazy()
      Check if this a lazy execution result.
      void limitsWereApplied()
      A hint that sorting, offset and limit may be ignored by this result because they were applied during the query.
      boolean needToClose()
      Check if this result set should be closed, for example because it is buffered using a temporary file.
      boolean next()
      Go to the next row.
      void reset()
      Go to the beginning of the result, that means before the first row.
      void setFetchSize​(int fetchSize)
      Set the fetch size for this result set.
      void sortRows​(java.util.Comparator<? super Value[]> comparator)
      Sort rows in the list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rows

        private final java.util.ArrayList<Value[]> rows
      • schemaName

        private final java.lang.String schemaName
      • tableName

        private final java.lang.String tableName
      • rowId

        private int rowId
    • Constructor Detail

      • SimpleResult

        public SimpleResult()
        Creates new instance of simple result.
      • SimpleResult

        public SimpleResult​(java.lang.String schemaName,
                            java.lang.String tableName)
        Creates new instance of simple result.
        Parameters:
        schemaName - the name of the schema
        tableName - the name of the table
      • SimpleResult

        private SimpleResult​(java.util.ArrayList<SimpleResult.Column> columns,
                             java.util.ArrayList<Value[]> rows,
                             java.lang.String schemaName,
                             java.lang.String tableName)
    • Method Detail

      • addColumn

        public void addColumn​(java.lang.String alias,
                              java.lang.String columnName,
                              int columnType,
                              long columnPrecision,
                              int columnScale)
        Add column to the result.
        Parameters:
        alias - Column's alias.
        columnName - Column's name.
        columnType - Column's value type.
        columnPrecision - Column's precision.
        columnScale - Column's scale.
      • addColumn

        public void addColumn​(java.lang.String columnName,
                              TypeInfo columnType)
        Add column to the result.
        Parameters:
        columnName - Column's name.
        columnType - Column's type.
      • addColumn

        public void addColumn​(java.lang.String alias,
                              java.lang.String columnName,
                              TypeInfo columnType)
        Add column to the result.
        Parameters:
        alias - Column's alias.
        columnName - Column's name.
        columnType - Column's type.
      • addColumn

        void addColumn​(SimpleResult.Column column)
        Add column to the result.
        Parameters:
        column - Column info.
      • addRow

        public void addRow​(Value... values)
        Description copied from interface: ResultTarget
        Add the row to the result set.
        Specified by:
        addRow in interface ResultTarget
        Parameters:
        values - the values
      • reset

        public void reset()
        Description copied from interface: ResultInterface
        Go to the beginning of the result, that means before the first row.
        Specified by:
        reset in interface ResultInterface
      • next

        public boolean next()
        Description copied from interface: ResultInterface
        Go to the next row.
        Specified by:
        next in interface ResultInterface
        Returns:
        true if a row exists
      • getRowId

        public long getRowId()
        Description copied from interface: ResultInterface
        Get the current row id, starting with 0. -1 is returned when next() was not called yet.
        Specified by:
        getRowId in interface ResultInterface
        Returns:
        the row id
      • isAfterLast

        public boolean isAfterLast()
        Description copied from interface: ResultInterface
        Check if the current position is after last row.
        Specified by:
        isAfterLast in interface ResultInterface
        Returns:
        true if after last
      • getVisibleColumnCount

        public int getVisibleColumnCount()
        Description copied from interface: ResultInterface
        Get the number of visible columns. More columns may exist internally for sorting or grouping.
        Specified by:
        getVisibleColumnCount in interface ResultInterface
        Returns:
        the number of columns
      • hasNext

        public boolean hasNext()
        Description copied from interface: ResultInterface
        Check if this result has more rows to fetch.
        Specified by:
        hasNext in interface ResultInterface
        Returns:
        true if it has
      • needToClose

        public boolean needToClose()
        Description copied from interface: ResultInterface
        Check if this result set should be closed, for example because it is buffered using a temporary file.
        Specified by:
        needToClose in interface ResultInterface
        Returns:
        true if close should be called.
      • close

        public void close()
        Description copied from interface: ResultInterface
        Close the result and delete any temporary files
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface ResultInterface
      • getAlias

        public java.lang.String getAlias​(int i)
        Description copied from interface: ResultInterface
        Get the column alias name for the column.
        Specified by:
        getAlias in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        the alias name
      • getSchemaName

        public java.lang.String getSchemaName​(int i)
        Description copied from interface: ResultInterface
        Get the schema name for the column, if one exists.
        Specified by:
        getSchemaName in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        the schema name or null
      • getTableName

        public java.lang.String getTableName​(int i)
        Description copied from interface: ResultInterface
        Get the table name for the column, if one exists.
        Specified by:
        getTableName in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        the table name or null
      • getColumnName

        public java.lang.String getColumnName​(int i)
        Description copied from interface: ResultInterface
        Get the column name.
        Specified by:
        getColumnName in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        the column name
      • getColumnType

        public TypeInfo getColumnType​(int i)
        Description copied from interface: ResultInterface
        Get the column data type.
        Specified by:
        getColumnType in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        the column data type
      • isIdentity

        public boolean isIdentity​(int i)
        Description copied from interface: ResultInterface
        Check if this is an identity column.
        Specified by:
        isIdentity in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        true for identity columns
      • getNullable

        public int getNullable​(int i)
        Description copied from interface: ResultInterface
        Check if this column is nullable.
        Specified by:
        getNullable in interface ResultInterface
        Parameters:
        i - the column number (starting with 0)
        Returns:
        Column.NULLABLE_*
      • setFetchSize

        public void setFetchSize​(int fetchSize)
        Description copied from interface: ResultInterface
        Set the fetch size for this result set.
        Specified by:
        setFetchSize in interface ResultInterface
        Parameters:
        fetchSize - the new fetch size
      • getFetchSize

        public int getFetchSize()
        Description copied from interface: ResultInterface
        Get the current fetch size for this result set.
        Specified by:
        getFetchSize in interface ResultInterface
        Returns:
        the fetch size
      • isLazy

        public boolean isLazy()
        Description copied from interface: ResultInterface
        Check if this a lazy execution result.
        Specified by:
        isLazy in interface ResultInterface
        Returns:
        true if it is a lazy result
      • isClosed

        public boolean isClosed()
        Description copied from interface: ResultInterface
        Check if this result set is closed.
        Specified by:
        isClosed in interface ResultInterface
        Returns:
        true if it is
      • createShallowCopy

        public SimpleResult createShallowCopy​(Session targetSession)
        Description copied from interface: ResultInterface
        Create a shallow copy of the result set. The data and a temporary table (if there is any) is not copied.
        Specified by:
        createShallowCopy in interface ResultInterface
        Parameters:
        targetSession - the session of the copy
        Returns:
        the copy if possible, or null if copying is not possible
      • limitsWereApplied

        public void limitsWereApplied()
        Description copied from interface: ResultTarget
        A hint that sorting, offset and limit may be ignored by this result because they were applied during the query. This is useful for WITH TIES clause because result may contain tied rows above limit.
        Specified by:
        limitsWereApplied in interface ResultTarget
      • sortRows

        public void sortRows​(java.util.Comparator<? super Value[]> comparator)
        Sort rows in the list.
        Parameters:
        comparator - the comparator