implementation designed to be subclassed easily by
implementations. All
that are not exactly
the right type. For example, any numeric type can be returned as any
type, and dates, locales, characters, and booleans can be
returned as strings.
| Method from org.apache.openjpa.jdbc.sql.AbstractResult Detail: |
public boolean absolute(int row) throws SQLException {
_gotEager = false;
return absoluteInternal(row);
}
|
protected boolean absoluteInternal(int row) throws SQLException {
throw new UnsupportedException();
}
Throws an exception by default. |
protected Object checkNull(Object val) {
_wasNull = (val == null);
return val;
}
|
public void close() {
closeEagerMap(_eager);
}
Closes all eager results. |
protected void closeEagerMap(Map eager) {
if (eager != null) {
Object res;
for (Iterator itr = eager.values().iterator(); itr.hasNext();) {
res = itr.next();
if (res != this && res instanceof Closeable)
try {
((Closeable) res).close();
} catch (Exception e) {
}
}
}
}
Close all results in eager map. |
public boolean contains(Object obj) throws SQLException {
return containsInternal(obj, null);
}
|
public boolean contains(Column col,
Joins joins) throws SQLException {
return containsInternal(col, joins);
}
|
public boolean containsAll(Object[] objs) throws SQLException {
return containsAllInternal(objs, null);
}
|
public boolean containsAll(Column[] cols,
Joins joins) throws SQLException {
return containsAllInternal(cols, joins);
}
|
protected boolean containsAllInternal(Object[] objs,
Joins joins) throws SQLException {
for (int i = 0; i < objs.length; i++)
if (!containsInternal(objs[i], joins))
return false;
return true;
}
Return whether this result contains data for all the given ids or
columns. The ids or columns have not been passed through
#translate . Delegates to #containsInternal by default. |
abstract protected boolean containsInternal(Object obj,
Joins joins) throws SQLException
Return whether this result contains data for the given id or column.
The id or column has not beed passed through #translate . |
public void endDataRequest() {
}
|
public Array getArray(Object obj) throws SQLException {
return getArrayInternal(translate(obj, null), null);
}
|
public Array getArray(Column col,
Joins joins) throws SQLException {
return getArrayInternal(translate(col, joins), joins);
}
|
protected Array getArrayInternal(Object obj,
Joins joins) throws SQLException {
return (Array) checkNull(getObjectInternal(obj,
JavaSQLTypes.SQL_ARRAY, null, joins));
}
|
public InputStream getAsciiStream(Object obj) throws SQLException {
return getAsciiStreamInternal(translate(obj, null), null);
}
|
public InputStream getAsciiStream(Column col,
Joins joins) throws SQLException {
return getAsciiStreamInternal(translate(col, joins), joins);
}
|
protected InputStream getAsciiStreamInternal(Object obj,
Joins joins) throws SQLException {
return (InputStream) checkNull(getObjectInternal(obj,
JavaSQLTypes.ASCII_STREAM, null, joins));
}
|
public ClassMapping getBaseMapping() {
// if we've returned an eager result this call might be for that eager
// result instead of our primary mapping, so return null
return (_gotEager) ? null : _base;
}
|
public BigDecimal getBigDecimal(Object obj) throws SQLException {
return getBigDecimalInternal(translate(obj, null), null);
}
|
public BigDecimal getBigDecimal(Column col,
Joins joins) throws SQLException {
return getBigDecimalInternal(translate(col, joins), joins);
}
|
protected BigDecimal getBigDecimalInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj,
JavaTypes.BIGDECIMAL, null, joins));
if (val == null)
return null;
if (val instanceof BigDecimal)
return (BigDecimal) val;
return new BigDecimal(val.toString());
}
|
public BigInteger getBigInteger(Object obj) throws SQLException {
return getBigIntegerInternal(translate(obj, null), null);
}
|
public BigInteger getBigInteger(Column col,
Joins joins) throws SQLException {
return getBigIntegerInternal(translate(col, joins), joins);
}
|
protected BigInteger getBigIntegerInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj,
JavaTypes.BIGINTEGER, null, joins));
if (val == null)
return null;
if (val instanceof BigInteger)
return (BigInteger) val;
return new BigInteger(val.toString());
}
|
public InputStream getBinaryStream(Object obj) throws SQLException {
return getBinaryStreamInternal(translate(obj, null), null);
}
|
public InputStream getBinaryStream(Column col,
Joins joins) throws SQLException {
return getBinaryStreamInternal(translate(col, joins), joins);
}
|
protected InputStream getBinaryStreamInternal(Object obj,
Joins joins) throws SQLException {
return (InputStream) checkNull(getObjectInternal(obj,
JavaSQLTypes.BINARY_STREAM, null, joins));
}
|
public Blob getBlob(Object obj) throws SQLException {
return getBlobInternal(translate(obj, null), null);
}
|
public Blob getBlob(Column col,
Joins joins) throws SQLException {
return getBlobInternal(translate(col, joins), joins);
}
|
protected Blob getBlobInternal(Object obj,
Joins joins) throws SQLException {
return (Blob) checkNull(getObjectInternal(obj, JavaSQLTypes.BLOB,
null, joins));
}
|
public boolean getBoolean(Object obj) throws SQLException {
return getBooleanInternal(translate(obj, null), null);
}
|
public boolean getBoolean(Column col,
Joins joins) throws SQLException {
return getBooleanInternal(translate(col, joins), joins);
}
|
protected boolean getBooleanInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.BOOLEAN,
null, joins));
if (val == null)
return false;
return Boolean.valueOf(val.toString()).booleanValue();
}
|
public byte getByte(Object obj) throws SQLException {
return getByteInternal(translate(obj, null), null);
}
|
public byte getByte(Column col,
Joins joins) throws SQLException {
return getByteInternal(translate(col, joins), joins);
}
|
protected byte getByteInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.BYTE, null, joins));
return (val == null) ? 0 : val.byteValue();
}
|
public byte[] getBytes(Object obj) throws SQLException {
return getBytesInternal(translate(obj, null), null);
}
|
public byte[] getBytes(Column col,
Joins joins) throws SQLException {
return getBytesInternal(translate(col, joins), joins);
}
|
protected byte[] getBytesInternal(Object obj,
Joins joins) throws SQLException {
return (byte[]) checkNull(getObjectInternal(obj,
JavaSQLTypes.BYTES, null, joins));
}
|
public Calendar getCalendar(Object obj) throws SQLException {
return getCalendarInternal(translate(obj, null), null);
}
|
public Calendar getCalendar(Column col,
Joins joins) throws SQLException {
return getCalendarInternal(translate(col, joins), joins);
}
|
protected Calendar getCalendarInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.CALENDAR,
null, joins));
if (val == null)
return null;
if (val instanceof Calendar)
return (Calendar) val;
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(val.toString()));
return cal;
}
|
public char getChar(Object obj) throws SQLException {
return getCharInternal(translate(obj, null), null);
}
|
public char getChar(Column col,
Joins joins) throws SQLException {
return getCharInternal(translate(col, joins), joins);
}
|
protected char getCharInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.CHAR,
null, joins));
if (val == null)
return 0;
if (val instanceof Character)
return ((Character) val).charValue();
String str = val.toString();
return (str.length() == 0) ? 0 : str.charAt(0);
}
|
public Reader getCharacterStream(Object obj) throws SQLException {
return getCharacterStreamInternal(translate(obj, null), null);
}
|
public Reader getCharacterStream(Column col,
Joins joins) throws SQLException {
return getCharacterStreamInternal(translate(col, joins), joins);
}
|
protected Reader getCharacterStreamInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj,
JavaSQLTypes.CHAR_STREAM, null, joins));
if (val == null)
return null;
if (val instanceof Reader)
return (Reader) val;
return new StringReader(val.toString());
}
|
public Clob getClob(Object obj) throws SQLException {
return getClobInternal(translate(obj, null), null);
}
|
public Clob getClob(Column col,
Joins joins) throws SQLException {
return getClobInternal(translate(col, joins), joins);
}
|
protected Clob getClobInternal(Object obj,
Joins joins) throws SQLException {
return (Clob) checkNull(getObjectInternal(obj, JavaSQLTypes.CLOB,
null, joins));
}
|
public Date getDate(Object obj) throws SQLException {
return getDateInternal(translate(obj, null), null);
}
|
public Date getDate(Column col,
Joins joins) throws SQLException {
return getDateInternal(translate(col, joins), joins);
}
|
public Date getDate(Object obj,
Calendar cal) throws SQLException {
return getDateInternal(translate(obj, null), cal, null);
}
|
public Date getDate(Column col,
Calendar cal,
Joins joins) throws SQLException {
return getDateInternal(translate(col, joins), cal, joins);
}
|
protected Date getDateInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.DATE,
null, joins));
if (val == null)
return null;
if (val instanceof Date)
return (Date) val;
return new Date(val.toString());
}
|
protected Date getDateInternal(Object obj,
Calendar cal,
Joins joins) throws SQLException {
return (java.sql.Date) checkNull(getObjectInternal(obj,
JavaSQLTypes.SQL_DATE, cal, joins));
}
|
public double getDouble(Object obj) throws SQLException {
return getDoubleInternal(translate(obj, null), null);
}
|
public double getDouble(Column col,
Joins joins) throws SQLException {
return getDoubleInternal(translate(col, joins), joins);
}
|
protected double getDoubleInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.DOUBLE, null, joins));
return (val == null) ? 0 : val.doubleValue();
}
|
public Object getEager(FieldMapping key) {
Map map = getEagerMap(true);
return (map == null) ? null : map.get(key);
}
|
protected Map getEagerMap(boolean client) {
if (client)
_gotEager = true;
return _eager;
}
Raw eager information. May be null. |
public float getFloat(Object obj) throws SQLException {
return getFloatInternal(translate(obj, null), null);
}
|
public float getFloat(Column col,
Joins joins) throws SQLException {
return getFloatInternal(translate(col, joins), joins);
}
|
protected float getFloatInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.FLOAT, null, joins));
return (val == null) ? 0 : val.floatValue();
}
|
public int getInt(Object obj) throws SQLException {
return getIntInternal(translate(obj, null), null);
}
|
public int getInt(Column col,
Joins joins) throws SQLException {
return getIntInternal(translate(col, joins), joins);
}
|
protected int getIntInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.INT, null, joins));
return (val == null) ? 0 : val.intValue();
}
|
public InputStream getLOBStream(JDBCStore store,
Object obj) throws SQLException {
return getLOBStreamInternal(store, translate(obj, null), null);
}
|
protected InputStream getLOBStreamInternal(JDBCStore store,
Object obj,
Joins joins) throws SQLException {
return (InputStream) checkNull(getStreamInternal(store, obj,
JavaSQLTypes.BINARY_STREAM, null, joins));
}
|
public Locale getLocale(Object obj) throws SQLException {
return getLocaleInternal(translate(obj, null), null);
}
|
public Locale getLocale(Column col,
Joins joins) throws SQLException {
return getLocaleInternal(translate(col, joins), joins);
}
|
protected Locale getLocaleInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.LOCALE,
null, joins));
if (val == null)
return null;
if (val instanceof Locale)
return (Locale) val;
String[] vals = Strings.split(val.toString(), "_", 0);
if (vals.length < 2)
throw new SQLException(val.toString());
if (vals.length == 2)
return new Locale(vals[0], vals[1]);
return new Locale(vals[0], vals[1], vals[2]);
}
|
public long getLong(Object obj) throws SQLException {
return getLongInternal(translate(obj, null), null);
}
|
public long getLong(Column col,
Joins joins) throws SQLException {
return getLongInternal(translate(col, joins), joins);
}
|
protected long getLongInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.INT, null, joins));
return (val == null) ? 0 : val.intValue();
}
|
public Number getNumber(Object obj) throws SQLException {
return getNumberInternal(translate(obj, null), null);
}
|
public Number getNumber(Column col,
Joins joins) throws SQLException {
return getNumberInternal(translate(col, joins), joins);
}
|
protected Number getNumberInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj,
JavaTypes.NUMBER, null, joins));
if (val == null)
return null;
if (val instanceof Number)
return (Number) val;
return new BigDecimal(val.toString());
}
|
public Object getObject(Object obj,
int metaType,
Object arg) throws SQLException {
return getObjectInternal(translate(obj, null), metaType, arg, null);
}
|
public Object getObject(Column col,
Object arg,
Joins joins) throws SQLException {
return getObjectInternal(translate(col, joins), col.getJavaType(),
arg, joins);
}
|
abstract protected Object getObjectInternal(Object obj,
int metaType,
Object arg,
Joins joins) throws SQLException
Return the value stored in the given id or column. |
public Ref getRef(Object obj,
Map map) throws SQLException {
return getRefInternal(translate(obj, null), map, null);
}
|
public Ref getRef(Column col,
Map map,
Joins joins) throws SQLException {
return getRefInternal(translate(col, joins), map, joins);
}
|
protected Ref getRefInternal(Object obj,
Map map,
Joins joins) throws SQLException {
return (Ref) checkNull(getObjectInternal(obj, JavaSQLTypes.REF,
map, joins));
}
|
public Object getSQLObject(Object obj,
Map map) throws SQLException {
return getSQLObjectInternal(translate(obj, null), map, null);
}
|
public Object getSQLObject(Column col,
Map map,
Joins joins) throws SQLException {
return getSQLObjectInternal(translate(col, joins), map, joins);
}
|
protected Object getSQLObjectInternal(Object obj,
Map map,
Joins joins) throws SQLException {
return checkNull(getObjectInternal(obj, JavaSQLTypes.SQL_OBJECT,
map, joins));
}
|
public short getShort(Object obj) throws SQLException {
return getShortInternal(translate(obj, null), null);
}
|
public short getShort(Column col,
Joins joins) throws SQLException {
return getShortInternal(translate(col, joins), joins);
}
|
protected short getShortInternal(Object obj,
Joins joins) throws SQLException {
Number val = (Number) checkNull(getObjectInternal(obj,
JavaTypes.SHORT, null, joins));
return (val == null) ? 0 : val.shortValue();
}
|
abstract protected Object getStreamInternal(JDBCStore store,
Object obj,
int metaType,
Object arg,
Joins joins) throws SQLException
|
public String getString(Object obj) throws SQLException {
return getStringInternal(translate(obj, null), null);
}
|
public String getString(Column col,
Joins joins) throws SQLException {
return getStringInternal(translate(col, joins), joins);
}
|
protected String getStringInternal(Object obj,
Joins joins) throws SQLException {
Object val = checkNull(getObjectInternal(obj, JavaTypes.STRING,
null, joins));
return (val == null) ? null : val.toString();
}
|
public Time getTime(Object obj,
Calendar cal) throws SQLException {
return getTimeInternal(translate(obj, null), cal, null);
}
|
public Time getTime(Column col,
Calendar cal,
Joins joins) throws SQLException {
return getTimeInternal(translate(col, joins), cal, joins);
}
|
protected Time getTimeInternal(Object obj,
Calendar cal,
Joins joins) throws SQLException {
return (Time) checkNull(getObjectInternal(obj, JavaSQLTypes.TIME,
cal, joins));
}
|
public Timestamp getTimestamp(Object obj,
Calendar cal) throws SQLException {
return getTimestampInternal(translate(obj, null), cal, null);
}
|
public Timestamp getTimestamp(Column col,
Calendar cal,
Joins joins) throws SQLException {
return getTimestampInternal(translate(col, joins), cal, joins);
}
|
protected Timestamp getTimestampInternal(Object obj,
Calendar cal,
Joins joins) throws SQLException {
return (Timestamp) checkNull(getObjectInternal(obj,
JavaSQLTypes.TIMESTAMP, cal, joins));
}
|
public int indexOf() {
return _index;
}
|
public boolean isLocking() {
return _locking;
}
|
public Object load(ClassMapping mapping,
JDBCStore store,
JDBCFetchConfiguration fetch) throws SQLException {
return load(mapping, store, fetch, null);
}
|
public Object load(ClassMapping mapping,
JDBCStore store,
JDBCFetchConfiguration fetch,
Joins joins) throws SQLException {
return ((JDBCStoreManager) store).load(mapping, fetch, null, this);
}
|
public Joins newJoins() {
return JOINS;
}
Returns a no-op joins object by default. |
public boolean next() throws SQLException {
_gotEager = false;
if (_ignoreNext) {
_ignoreNext = false;
return _last;
}
_last = nextInternal();
return _last;
}
|
abstract protected boolean nextInternal() throws SQLException
|
public void pushBack() throws SQLException {
_ignoreNext = true;
}
|
public void putEager(FieldMapping key,
Object res) {
Map map = getEagerMap(false);
if (map == null) {
map = new HashMap();
setEagerMap(map);
}
map.put(key, res);
}
|
public void setBaseMapping(ClassMapping base) {
_base = base;
}
|
protected void setEagerMap(Map eager) {
_eager = eager;
}
|
public void setIndexOf(int idx) {
_index = idx;
}
|
public void setLocking(boolean locking) {
_locking = locking;
}
|
public void startDataRequest(Object mapping) {
}
|
public boolean supportsRandomAccess() throws SQLException {
return false;
}
Returns false by default. |
protected Object translate(Object obj,
Joins joins) throws SQLException {
return obj;
}
Translate the user-given id or column. This method is called before
delegating to any get*Internal methods. Return the
original value by default. |
public boolean wasNull() throws SQLException {
return _wasNull;
}
|