001: /*
002: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
003: * (http://h2database.com/html/license.html).
004: * Initial Developer: H2 Group
005: */
006: package org.h2.result;
007:
008: import java.sql.SQLException;
009:
010: import org.h2.value.Value;
011:
012: /**
013: * The result interface is used by the LocalResult and ResultRemote class.
014: * A result may contain rows, or just an update count.
015: */
016: public interface ResultInterface {
017:
018: /**
019: * Go to the beginning of the result, that means
020: * before the first row.
021: */
022: void reset() throws SQLException;
023:
024: /**
025: * Get the current row.
026: *
027: * @return the row
028: */
029: Value[] currentRow();
030:
031: /**
032: * Go to the next row.
033: *
034: * @return true if a row exists
035: */
036: boolean next() throws SQLException;
037:
038: /**
039: * Get the current row id, starting with 0.
040: * -1 is returned when next() was not called yet.
041: *
042: * @return the row id
043: */
044: int getRowId();
045:
046: /**
047: * Get the number of visible columns.
048: * More columns may exist internally for sorting or grouping.
049: *
050: * @return the number of columns
051: */
052: int getVisibleColumnCount();
053:
054: /**
055: * Get the number of rows in this object.
056: *
057: * @return the number of rows
058: */
059: int getRowCount();
060:
061: /**
062: * Close the result and delete any temporary files
063: */
064: void close();
065:
066: /**
067: * Get the column alias name for the column.
068: *
069: * @param i the column number (starting with 0)
070: * @return the alias name
071: */
072: String getAlias(int i);
073:
074: /**
075: * Get the schema name for the column, if one exists.
076: *
077: * @param i the column number (starting with 0)
078: * @return the schema name or null
079: */
080: String getSchemaName(int i);
081:
082: /**
083: * Get the table name for the column, if one exists.
084: *
085: * @param i the column number (starting with 0)
086: * @return the table name or null
087: */
088: String getTableName(int i);
089:
090: /**
091: * Get the column name.
092: *
093: * @param i the column number (starting with 0)
094: * @return the column name
095: */
096: String getColumnName(int i);
097:
098: /**
099: * Get the column data type.
100: *
101: * @param i the column number (starting with 0)
102: * @return the column data type
103: */
104: int getColumnType(int i);
105:
106: /**
107: * Get the precision for this column.
108: *
109: * @param i the column number (starting with 0)
110: * @return the precision
111: */
112: long getColumnPrecision(int i);
113:
114: /**
115: * Get the scale for this column.
116: *
117: * @param i the column number (starting with 0)
118: * @return the scale
119: */
120: int getColumnScale(int i);
121:
122: /**
123: * Get the display size for this column.
124: *
125: * @param i the column number (starting with 0)
126: * @return the display size
127: */
128: int getDisplaySize(int i);
129:
130: /**
131: * Check if this is an auto-increment column.
132: *
133: * @param i the column number (starting with 0)
134: * @return true for auto-increment columns
135: */
136: boolean isAutoIncrement(int i);
137:
138: /**
139: * Check if this column is nullable.
140: *
141: * @param i the column number (starting with 0)
142: * @return Column.NULLABLE_*
143: */
144: int getNullable(int i);
145:
146: /**
147: * Check if this result is in fact an update count.
148: *
149: * @return if it is an update count
150: */
151: boolean isUpdateCount();
152:
153: /**
154: * Get the update count for this result.
155: *
156: * @return the update count
157: */
158: int getUpdateCount();
159: }
|