Package de.uplanet.lucy.server.util.db
Class DbResultSet
- java.lang.Object
-
- de.uplanet.lucy.server.util.db.DbResultSet
-
- All Implemented Interfaces:
IDbResultSet,IValueAccess,IValueHolderAccess,ICloseable,AutoCloseable,Iterable<IDbRow>
public final class DbResultSet extends Object implements IDbResultSet, Iterable<IDbRow>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()List<?>findAll(groovy.lang.Closure<?> p_closure)Calls the given closure for every row in the result set and returns a list of rows for which the closure is valid.BigDecimalgetBigDecimalValue(int p_iIdx)Get a decimal number value.BigDecimalgetBigDecimalValue(int p_iIdx, BigDecimal p_valueIfNull)Get a decimal number value.BooleangetBooleanValue(int p_iIdx)Get a boolean value.BooleangetBooleanValue(int p_iIdx, Boolean p_valueIfNull)Get a boolean value.bytegetByteValue(int p_iIdx)Get a byte value.BytegetByteValue(int p_iIdx, Byte p_valueIfNull)Get a byte value.DategetDateValue(int p_iIdx)Get a date value.DategetDateValue(int p_iIdx, Calendar p_cal)DategetDateValue(int p_iIdx, Date p_valueIfNull)Get a date value.DategetDateValue(int p_iIdx, Date p_valueIfNull, Calendar p_cal)DategetDateValue(int p_iIdx, Date p_valueIfNull, TimeZone p_tz)DategetDateValue(int p_iIdx, TimeZone p_tz)DbRowListgetDisconnectedRowList()Create a list of disconnected rows from this result set.DoublegetDoubleValue(int p_iIdx)Get a double value.DoublegetDoubleValue(int p_iIdx, Double p_valueIfNull)Get a double precision float value.FloatgetFloatValue(int p_iIdx)Get a single precision float value.FloatgetFloatValue(int p_iIdx, Float p_valueIfNull)Get a single precision float value.IntegergetIntValue(int p_iIdx)Get an integer value.IntegergetIntValue(int p_iIdx, Integer p_valueIfNull)Get an integer value.LonggetLongValue(int p_iIdx)Get a long value.LonggetLongValue(int p_iIdx, Long p_valueIfNull)Get a long value.intgetRowCount()Get the number of rows read so far.ShortgetShortValue(int p_iIdx)Get a short value.ShortgetShortValue(int p_iIdx, Short p_valueIfNull)Get a short value.StringgetStringValue(int p_iIdx)Get a string value.StringgetStringValue(int p_iIdx, String p_valueIfNull)Get a string value.TimestampgetTimestampValue(int p_iIdx)Get a timestamp value.TimestampgetTimestampValue(int p_iIdx, Timestamp p_valueIfNull)Get a timestamp value.TimestampgetTimestampValue(int p_iIdx, Timestamp p_valueIfNull, Calendar p_cal)TimestampgetTimestampValue(int p_iIdx, Timestamp p_valueIfNull, TimeZone p_tz)TimestampgetTimestampValue(int p_iIdx, Calendar p_cal)TimestampgetTimestampValue(int p_iIdx, TimeZone p_tz)DategetTimeValue(int p_iIdx)Get a time value.DategetTimeValue(int p_iIdx, Calendar p_cal)DategetTimeValue(int p_iIdx, Date p_valueIfNull)Get a time value.DategetTimeValue(int p_iIdx, Date p_valueIfNull, Calendar p_cal)DategetTimeValue(int p_iIdx, Date p_valueIfNull, TimeZone p_tz)DategetTimeValue(int p_iIdx, TimeZone p_tz)ObjectgetValue(int p_iIdx)Get a value.ObjectgetValue(int p_iIdx, Object p_valueIfNull)Get a value.IValueHolder<?>getValueHolder(int p_iIdx)IValueHolder<?>getValueHolder(int p_iIdx, String p_strDataTypeAsSerializedQName)IValueHolder<?>getValueHolder(int p_iIdx, String p_strDataTypeAsSerializedQName, IValueHolder<?> p_valueIfNull)IValueHolder<?>getValueHolder(int p_iIdx, QName p_qmnDataType)IValueHolder<?>getValueHolder(int p_iIdx, QName p_qmnDataType, IValueHolder<?> p_valueIfNull)Collection<?>grep(Object p_filter)This method is not supportedIterator<IDbRow>iterator()booleannext()booleanwasNull(int p_iIdx)Check if the value in the given column wasnull.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getRowCount
public int getRowCount()
Get the number of rows read so far.- Returns:
- The number of rows read so far.
-
next
public boolean next() throws SQLException- Specified by:
nextin interfaceIDbResultSet- Throws:
SQLException
-
wasNull
public boolean wasNull(int p_iIdx) throws SQLExceptionDescription copied from interface:IValueAccessCheck if the value in the given column wasnull.- Specified by:
wasNullin interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
trueif the value wasnull, orfalseotherwise.- Throws:
SQLException- If a database error occurred.
-
getValueHolder
public IValueHolder<?> getValueHolder(int p_iIdx) throws SQLException
- Specified by:
getValueHolderin interfaceIValueHolderAccess- Throws:
SQLException
-
getValueHolder
public IValueHolder<?> getValueHolder(int p_iIdx, QName p_qmnDataType) throws SQLException
- Specified by:
getValueHolderin interfaceIValueHolderAccess- Throws:
SQLException
-
getValueHolder
public IValueHolder<?> getValueHolder(int p_iIdx, String p_strDataTypeAsSerializedQName) throws SQLException
- Specified by:
getValueHolderin interfaceIValueHolderAccess- Throws:
SQLException
-
getValueHolder
public IValueHolder<?> getValueHolder(int p_iIdx, QName p_qmnDataType, IValueHolder<?> p_valueIfNull) throws SQLException
- Specified by:
getValueHolderin interfaceIValueHolderAccess- Throws:
SQLException
-
getValueHolder
public IValueHolder<?> getValueHolder(int p_iIdx, String p_strDataTypeAsSerializedQName, IValueHolder<?> p_valueIfNull) throws SQLException
- Specified by:
getValueHolderin interfaceIValueHolderAccess- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIDbResultSet- Throws:
SQLException
-
getValue
public Object getValue(int p_iIdx) throws SQLException
Description copied from interface:IValueAccessGet a value. Note: The use of this method is discouraged. Use a method that returns a specified type instead.- Specified by:
getValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- The value.
- Throws:
SQLException- If a database error occurred.
-
getValue
public Object getValue(int p_iIdx, Object p_valueIfNull) throws SQLException
Description copied from interface:IValueAccessGet a value. Note: The use of this method is discouraged. Use a method that returns a specified type instead.- Specified by:
getValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- The value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.
-
getBooleanValue
public Boolean getBooleanValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a boolean value.- Specified by:
getBooleanValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A boolean value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to boolean.
-
getBooleanValue
public Boolean getBooleanValue(int p_iIdx, Boolean p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a boolean value.- Specified by:
getBooleanValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A boolean value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to boolean.
-
getByteValue
public byte getByteValue(int p_iIdx) throws SQLException, ValueCastExceptionDescription copied from interface:IValueAccessGet a byte value.- Specified by:
getByteValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A byte value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to byte.
-
getByteValue
public Byte getByteValue(int p_iIdx, Byte p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a byte value.- Specified by:
getByteValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A byte value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to byte.
-
getShortValue
public Short getShortValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a short value.- Specified by:
getShortValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A short value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to short.
-
getShortValue
public Short getShortValue(int p_iIdx, Short p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a short value.- Specified by:
getShortValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A short value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to short.
-
getIntValue
public Integer getIntValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet an integer value.- Specified by:
getIntValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- An integer value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to integer.
-
getIntValue
public Integer getIntValue(int p_iIdx, Integer p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet an integer value.- Specified by:
getIntValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- An integer value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to integer.
-
getLongValue
public Long getLongValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a long value.- Specified by:
getLongValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A long value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to long.
-
getLongValue
public Long getLongValue(int p_iIdx, Long p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a long value.- Specified by:
getLongValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A long value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to long.
-
getFloatValue
public Float getFloatValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a single precision float value.- Specified by:
getFloatValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A float value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to float.
-
getFloatValue
public Float getFloatValue(int p_iIdx, Float p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a single precision float value.- Specified by:
getFloatValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A float value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to float.
-
getDoubleValue
public Double getDoubleValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a double value.- Specified by:
getDoubleValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A double value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to double.
-
getDoubleValue
public Double getDoubleValue(int p_iIdx, Double p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a double precision float value.- Specified by:
getDoubleValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A double value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to double.
-
getBigDecimalValue
public BigDecimal getBigDecimalValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a decimal number value.- Specified by:
getBigDecimalValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A BigDecimal value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to BigDecimal.
-
getBigDecimalValue
public BigDecimal getBigDecimalValue(int p_iIdx, BigDecimal p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a decimal number value.- Specified by:
getBigDecimalValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A BigDecimal value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to BigDecimal.
-
getStringValue
public String getStringValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a string value.- Specified by:
getStringValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A string value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to a string.
-
getStringValue
public String getStringValue(int p_iIdx, String p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a string value.- Specified by:
getStringValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A string value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to string.
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a timestamp value.- Specified by:
getTimestampValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A timestamp value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to a timestamp.
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getTimestampValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getTimestampValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx, Timestamp p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a timestamp value.- Specified by:
getTimestampValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A timestamp value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to timestamp.
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx, Timestamp p_valueIfNull, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getTimestampValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimestampValue
public Timestamp getTimestampValue(int p_iIdx, Timestamp p_valueIfNull, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getTimestampValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getDateValue
public Date getDateValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a date value.- Specified by:
getDateValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A date value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to date.
-
getDateValue
public Date getDateValue(int p_iIdx, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getDateValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getDateValue
public Date getDateValue(int p_iIdx, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getDateValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getDateValue
public Date getDateValue(int p_iIdx, Date p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a date value.- Specified by:
getDateValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A date value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to date.
-
getDateValue
public Date getDateValue(int p_iIdx, Date p_valueIfNull, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getDateValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getDateValue
public Date getDateValue(int p_iIdx, Date p_valueIfNull, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getDateValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimeValue
public Date getTimeValue(int p_iIdx) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a time value.- Specified by:
getTimeValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.- Returns:
- A time value, or
null. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to time.
-
getTimeValue
public Date getTimeValue(int p_iIdx, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getTimeValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimeValue
public Date getTimeValue(int p_iIdx, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getTimeValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimeValue
public Date getTimeValue(int p_iIdx, Date p_valueIfNull) throws SQLException, ValueCastException
Description copied from interface:IValueAccessGet a time value.- Specified by:
getTimeValuein interfaceIValueAccess- Parameters:
p_iIdx- The 1-based column index.p_valueIfNull- The value to be returned if the database value wasNULL.- Returns:
- A time value, or
p_valueIfNull. - Throws:
SQLException- If a database error occurred.ValueCastException- If the database value could not be cast to time.
-
getTimeValue
public Date getTimeValue(int p_iIdx, Date p_valueIfNull, TimeZone p_tz) throws SQLException, ValueCastException
- Specified by:
getTimeValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getTimeValue
public Date getTimeValue(int p_iIdx, Date p_valueIfNull, Calendar p_cal) throws SQLException, ValueCastException
- Specified by:
getTimeValuein interfaceIDbResultSet- Throws:
SQLExceptionValueCastException
-
getDisconnectedRowList
public DbRowList getDisconnectedRowList()
Create a list of disconnected rows from this result set.Note:
- The result set data are at once fetched into memory so that calling this method may result in excessive memory consumption.
- After this method has been called, subsequent iterations over this result set will give no result. However anew call to this method will return the previous returned rows.
- Rows that were consumed in previous iterations over this result set will not be present in this list.
- Returns:
- A list of disconnected rows.
-
findAll
public List<?> findAll(groovy.lang.Closure<?> p_closure)
Calls the given closure for every row in the result set and returns a list of rows for which the closure is valid.- Parameters:
p_closure- The closure that's being called.- Returns:
- A list of rows the closure is valid for.
- Throws:
UnsupportedOperationException- - If the result set does not provide disconnected rows.
-
grep
public Collection<?> grep(Object p_filter)
This method is not supported.
- Throws:
UnsupportedOperationException
-
-