SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

com.solarmetric.kodo.impl.jdbc.runtime
Class LazyResultList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList
All Implemented Interfaces:
Collection, CustomResultList, List, ResultList, Serializable

public class LazyResultList
extends AbstractList
implements CustomResultList

Lazy ResultList implementation. It maintains a SoftValueMap of the rows that we have already instantiated. If we ever resolve all of the values in the ResultSet, they will be copied over to a HashMap so that the ResultSet and Statement can be closed.

This implementation does not invoke the ResultObjectProvider.open(java.lang.Object) or ResultObjectProvider.advance(java.lang.Object) APIs. Instead, it manipulates the underlying ResultSet directly.

Since:
2.2.6
See Also:
Serialized Form

Field Summary
static int SIZE_UNINITIALIZED
           
static int SIZE_UNKNOWN
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
  LazyResultList()
           
(package private) LazyResultList(ResultSet rs, ResultObjectProvider rop, Configuration config)
           
 
Method Summary
 void checkClosed()
          Check to see if this ResultList has been closed, and if so, throw a JDOUserException.
 void close()
          Close the list.
 boolean equals(Object other)
           
protected  void finalize()
           
 void flush(int targetReduction)
          Internal method to try to flush out all references that are not present elsewhere.
protected  void free()
           
 Object get(int index)
           
 int getCacheSize()
           
protected  Collection getCacheValues()
           
 int getInstantiatedCount()
          Returns the number of objects that are currently instantiated internally in this list.
protected  int getSize()
          Return the size of the result set in this ResultList.
 int hashCode()
          Returns the hashCode of an internally held identity object, so that the entire list does not need to be traversed in order to calculate the hashCode.
 void initResultList(Object input, ResultObjectProvider rop, Configuration config)
          Initialize the ResultList implementation, which will allow custom ResultList objects to be used for Query results.
 boolean isClosed()
          Returns true if the list has been closed.
 Iterator iterator()
           
 ListIterator listIterator()
           
 int size()
          Return the size of this List.
 String toString()
           
 void useSoftMap()
           
 void useWeakMap()
           
 Object writeReplace()
           
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, lastIndexOf, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
, clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Field Detail

SIZE_UNINITIALIZED

public static final int SIZE_UNINITIALIZED

SIZE_UNKNOWN

public static final int SIZE_UNKNOWN
Constructor Detail

LazyResultList

public LazyResultList()

LazyResultList

LazyResultList(ResultSet rs,
               ResultObjectProvider rop,
               Configuration config)
         throws SQLException
Method Detail

initResultList

public void initResultList(Object input,
                           ResultObjectProvider rop,
                           Configuration config)
Description copied from interface: CustomResultList
Initialize the ResultList implementation, which will allow custom ResultList objects to be used for Query results.
Specified by:
initResultList in interface CustomResultList
Following copied from interface: com.solarmetric.kodo.runtime.objectprovider.CustomResultList
Parameters:
input - the source of the results (e.g., a JDBC ResultSet)
rop - the provider used to obtain the next element from the list
config - the Configuration object to use

toString

public String toString()
Overrides:
toString in class AbstractCollection

getInstantiatedCount

public int getInstantiatedCount()
Description copied from interface: ResultList
Returns the number of objects that are currently instantiated internally in this list.
Specified by:
getInstantiatedCount in interface ResultList

getCacheSize

public int getCacheSize()

getCacheValues

protected Collection getCacheValues()

get

public Object get(int index)
Specified by:
get in interface List
Overrides:
get in class AbstractList

flush

public void flush(int targetReduction)
Internal method to try to flush out all references that are not present elsewhere.

useWeakMap

public void useWeakMap()

useSoftMap

public void useSoftMap()

size

public int size()
Return the size of this List. Since at any given time, only some (or none) of the results may be cached, we calculate the size by jumping to the last row in the ResultSet and getting its row index: this will be the correct size, according to the JDBC 2.0 specification.
Specified by:
size in interface List
Overrides:
size in class AbstractCollection

getSize

protected int getSize()
               throws SQLException
Return the size of the result set in this ResultList. This should not return cached values.

checkClosed

public void checkClosed()
Description copied from interface: ResultList
Check to see if this ResultList has been closed, and if so, throw a JDOUserException.
Specified by:
checkClosed in interface ResultList

close

public void close()
Description copied from interface: ResultList
Close the list.
Specified by:
close in interface ResultList

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object

free

protected void free()

iterator

public Iterator iterator()
Specified by:
iterator in interface List
Overrides:
iterator in class AbstractList

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
Overrides:
listIterator in class AbstractList

isClosed

public boolean isClosed()
Description copied from interface: ResultList
Returns true if the list has been closed.
Specified by:
isClosed in interface ResultList

writeReplace

public Object writeReplace()
                    throws ObjectStreamException

hashCode

public int hashCode()
Returns the hashCode of an internally held identity object, so that the entire list does not need to be traversed in order to calculate the hashCode.
Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList

equals

public boolean equals(Object other)
Specified by:
equals in interface List
Overrides:
equals in class AbstractList

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.