ResultSetpublic class ResultSetWrapper extends Object implements ResultSet
ResultSet to its
implementation class.
This class is mainly used to extend ResultSet by overriding some of its methods.
ResultSetSystemCapability.Data#DATA_APPDATAMGRResultSet.ColumnType| 限定符和类型 | 字段 | 说明 |
|---|---|---|
protected ResultSet |
mResultSet |
Indicates the result set wrapped by the wrapper class.
|
| 构造器 | 说明 |
|---|---|
ResultSetWrapper(ResultSet inputResultSet) |
A parameterized constructor used to create a
ResultSetWrapper instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
close() |
Closes the result set.
|
List<Uri> |
getAffectedByUris() |
Obtains the list of URIs registered to observe changes that affect the result set.
|
String[] |
getAllColumnNames() |
Obtains the names of all columns in a result set.
|
byte[] |
getBlob(int columnIndex) |
Obtains the value of the specified column in the current row as a byte array.
|
int |
getColumnCount() |
Obtains the number of columns in the result set.
|
int |
getColumnIndexForName(String columnName) |
Obtains the column index based on the specified column name.
|
String |
getColumnNameForIndex(int columnIndex) |
Obtains the column name based on the specified column index.
|
ResultSet.ColumnType |
getColumnTypeForIndex(int columnIndex) |
Obtains the data type based on the specified column index.
|
double |
getDouble(int columnIndex) |
Obtains the value of the specified column in the current row as a double.
|
PacMap |
getExtensions() |
Obtains extensions of the result set.
|
float |
getFloat(int columnIndex) |
Obtains the value of the specified column in the current row as a float.
|
int |
getInt(int columnIndex) |
Obtains the value of the specified column in the current row as an int.
|
long |
getLong(int columnIndex) |
Obtains the value of the specified column in the current row as a long.
|
ResultSet |
getResultSet() |
Obtains the result set from
ResultSetWrapper. |
int |
getRowCount() |
Obtains the number of rows in the result set.
|
int |
getRowIndex() |
Obtains the current index of the result set.
|
short |
getShort(int columnIndex) |
Obtains the value of the specified column in the current row as a short.
|
String |
getString(int columnIndex) |
Obtains the value of the specified column in the current row as a string.
|
boolean |
goTo(int offset) |
Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
|
boolean |
goToFirstRow() |
Go to the first row of the result set.
|
boolean |
goToLastRow() |
Go to the last row of the result set.
|
boolean |
goToNextRow() |
Go to the next row of the result set.
|
boolean |
goToPreviousRow() |
Go to the previous row of the result set.
|
boolean |
goToRow(int rowIndex) |
Go to the specified row of the result set.
|
boolean |
isAtFirstRow() |
Checks whether the result set is positioned at the first row.
|
boolean |
isAtLastRow() |
Checks whether the result set is positioned at the last row.
|
boolean |
isClosed() |
Checks whether the current result set is closed.
|
boolean |
isColumnNull(int columnIndex) |
Checks whether the value of the specified column in the current row is null.
|
boolean |
isEnded() |
Checks whether the result set is positioned after the last row.
|
boolean |
isStarted() |
Checks whether a result set has been moved.
|
void |
registerObserver(DataObserver observer) |
Registers an observer that listens for data changes.
|
void |
setAffectedByUris(Object context,
List<Uri> uris) |
Sets the URIs of the data to be observed.
|
void |
setExtensions(PacMap extensions) |
Sets extensions of the result set.
|
void |
unregisterObserver(DataObserver observer) |
Deregisters an observer that listens for data changes.
|
protected ResultSet mResultSet
After the result set is wrapped, if any of its methods are not overridden in the wrapper class,
these methods in the ResultSet object will be called.
public ResultSetWrapper(ResultSet inputResultSet)
ResultSetWrapper instance.
The input result set will be wrapped in the ResultSetWrapper.
inputResultSet - Indicates the input result set.public ResultSet getResultSet()
ResultSetWrapper.
The result set you will obtain is the one you input for wrapping.
ResultSetWrapper.public String[] getAllColumnNames()
ResultSetThe column names are returned as a string array, in which the strings are in the same order as the columns in the result set.
getAllColumnNames 在接口中 ResultSetpublic int getColumnCount()
ResultSetThe returned number is equal to the length of the string array returned by the
getAllColumnNames method.
getColumnCount 在接口中 ResultSetResultSet.getAllColumnNames()public ResultSet.ColumnType getColumnTypeForIndex(int columnIndex)
ResultSetThe return value is of the enumeration type, which can be an integer, float, String, Blob, or null.
getColumnTypeForIndex 在接口中 ResultSetcolumnIndex - Indicates the specified column index.public int getColumnIndexForName(String columnName)
ResultSetThe column name is passed as an input parameter.
getColumnIndexForName 在接口中 ResultSetcolumnName - Indicates the name of the specified column in the result set.public String getColumnNameForIndex(int columnIndex)
ResultSetThe column index is passed as an input parameter.
getColumnNameForIndex 在接口中 ResultSetcolumnIndex - Indicates the index of the specified column in the result set.public int getRowCount()
ResultSetgetRowCount 在接口中 ResultSetpublic int getRowIndex()
ResultSetThe result set index starts from 0.
getRowIndex 在接口中 ResultSetpublic boolean goTo(int offset)
ResultSetpublic boolean goToRow(int rowIndex)
ResultSetpublic boolean goToFirstRow()
ResultSetgoToFirstRow 在接口中 ResultSettrue if the result set is moved successfully;
returns false otherwise, for example, if the result set is empty.public boolean goToLastRow()
ResultSetgoToLastRow 在接口中 ResultSettrue if the result set is moved successfully;
returns false otherwise, for example, if the result set is empty.public boolean goToNextRow()
ResultSetgoToNextRow 在接口中 ResultSettrue if the result set is moved successfully;
returns false otherwise, for example, if the result set is already in the last row.public boolean goToPreviousRow()
ResultSetgoToPreviousRow 在接口中 ResultSettrue if the result set is moved successfully;
returns false otherwise, for example, if the result set is already in the first row.public boolean isEnded()
ResultSetpublic boolean isStarted()
ResultSetpublic boolean isAtFirstRow()
ResultSetisAtFirstRow 在接口中 ResultSettrue if the result set is positioned at the first row; returns false otherwise.public boolean isAtLastRow()
ResultSetisAtLastRow 在接口中 ResultSettrue if the result set is positioned at the last row; returns false otherwise.public byte[] getBlob(int columnIndex)
ResultSetThe implementation class determines whether to throw an exception if the value of the specified column in the current row is null or the specified column is not of the Blob type.
public String getString(int columnIndex)
ResultSetThe implementation class determines whether to throw an exception if the value of the specified column in the current row is null or the specified column is not of the string type.
public short getShort(int columnIndex)
ResultSet
he implementation class determines whether to throw an exception if the value of the specified column
in the current row is null, the specified column is not of the integer type, or the integer is beyond
the range [Short.MIN_VALUE, Short.MAX_VALUE].
public int getInt(int columnIndex)
ResultSet
The implementation class determines whether to throw an exception if the value of the specified column
in the current row is null, the specified column is not of the integer type, or the integer is beyond
the range [Integer.MIN_VALUE, Integer.MAX_VALUE].
public long getLong(int columnIndex)
ResultSetThe implementation class determines whether to throw an exception if the value of the specified column
in the current row is null, the specified column is not of the integer type, or the integer is beyond the
range [Long.MIN_VALUE, Long.MAX_VALUE].
public float getFloat(int columnIndex)
ResultSetThe implementation class determines whether to throw an exception if the value of the specified column in
the current row is null, the specified column is not of the floating-point type, or the floating-point value
cannot be represented by a float.
public double getDouble(int columnIndex)
ResultSetThe implementation class determines whether to throw an exception if the value of the specified column
in the current row is null, the specified column is not of the floating-point type, or the floating-point
value cannot be represented by a double.
public boolean isColumnNull(int columnIndex)
ResultSetisColumnNull 在接口中 ResultSetcolumnIndex - Indicates the specified column index, which starts from 0.true if the value of the specified column in the current row is null;
returns false otherwise.public boolean isClosed()
ResultSetIf the result set is closed by calling the close method, true will be returned.
isClosed 在接口中 ResultSettrue if the result set is closed; returns false otherwise.ResultSet.close()public void close()
ResultSetCalling this method on the result set will release all of its resources and makes it ineffective.
close 在接口中 ResultSetResultSet.isClosed()public void setExtensions(PacMap extensions)
ResultSetYou can set extensions based on your service requirements.
setExtensions 在接口中 ResultSetextensions - Indicates the extensions to set.ResultSet.getExtensions()public PacMap getExtensions()
ResultSetThe extensions you will obtain are those set based on your service requirements.
getExtensions 在接口中 ResultSetResultSet.setExtensions(ohos.utils.PacMap)public void setAffectedByUris(Object context, List<Uri> uris)
ResultSetAfter setting the URIs, call the ResultSet#registerObserver method to register an observer
that listens for data changes.
setAffectedByUris 在接口中 ResultSetcontext - Indicates the context.uris - Uri list to observe changes which affect this ResultSet.ResultSet.registerObserver(ohos.data.rdb.DataObserver)public List<Uri> getAffectedByUris()
ResultSetThe list of URIs is set using the ResultSet#setAffectedByUris method.
getAffectedByUris 在接口中 ResultSetpublic void registerObserver(DataObserver observer)
ResultSetWhen a notification of the change of data with a specified URI is received, this observer will be triggered.
registerObserver 在接口中 ResultSetobserver - Indicates the observer to be registered.ResultSet.setAffectedByUris(java.lang.Object, java.util.List<ohos.utils.net.Uri>),
ResultSet.unregisterObserver(ohos.data.rdb.DataObserver)public void unregisterObserver(DataObserver observer)
ResultSetThis method is used to release the observer before the component to which the observer belongs is destroyed.
unregisterObserver 在接口中 ResultSetobserver - Indicates the observer to be deregistered.