Package org.apache.cayenne.util
Class ListResponse
- java.lang.Object
-
- org.apache.cayenne.util.ListResponse
-
- All Implemented Interfaces:
Serializable
,QueryResponse
- Direct Known Subclasses:
IncrementalListResponse
public class ListResponse extends Object implements QueryResponse, Serializable
A QueryResponse optimized to hold a single object or data row list.- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentIndex
protected List
objectList
-
Constructor Summary
Constructors Constructor Description ListResponse()
Creates an empty response.ListResponse(Object object)
ListResponse(List objectList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List
currentList()
Returns a List under the current iterator position.int[]
currentUpdateCount()
Returns an update count under the current iterator position.List
firstList()
A utility method for quickly retrieving the first list in the response.int[]
firstUpdateCount()
A utility method for quickly retrieving the first update count from the response.boolean
isList()
Returns whether current iteration result is a list or an update count.boolean
next()
Rewinds response iterator to the next result, returning true if it is available.void
reset()
Restarts response iterator.int
size()
Returns a number of results in the response.
-
-
-
Field Detail
-
objectList
protected List objectList
-
currentIndex
protected transient int currentIndex
-
-
Method Detail
-
size
public int size()
Description copied from interface:QueryResponse
Returns a number of results in the response.- Specified by:
size
in interfaceQueryResponse
-
isList
public boolean isList()
Description copied from interface:QueryResponse
Returns whether current iteration result is a list or an update count.- Specified by:
isList
in interfaceQueryResponse
-
currentList
public List currentList()
Description copied from interface:QueryResponse
Returns a List under the current iterator position. UseQueryResponse.isList()
to check the result type before calling this method.- Specified by:
currentList
in interfaceQueryResponse
-
currentUpdateCount
public int[] currentUpdateCount()
Description copied from interface:QueryResponse
Returns an update count under the current iterator position. Returned value is an int[] to accommodate batch queries. For a regular update result, the value will be an int[1]. UseQueryResponse.isList()
to check the result type before calling this method.- Specified by:
currentUpdateCount
in interfaceQueryResponse
-
next
public boolean next()
Description copied from interface:QueryResponse
Rewinds response iterator to the next result, returning true if it is available.- Specified by:
next
in interfaceQueryResponse
-
reset
public void reset()
Description copied from interface:QueryResponse
Restarts response iterator.- Specified by:
reset
in interfaceQueryResponse
-
firstList
public List firstList()
Description copied from interface:QueryResponse
A utility method for quickly retrieving the first list in the response. Returns null if the query has no lists. Note that this method resets current iterator to an undefined state.- Specified by:
firstList
in interfaceQueryResponse
-
firstUpdateCount
public int[] firstUpdateCount()
Description copied from interface:QueryResponse
A utility method for quickly retrieving the first update count from the response. Note that this method resets current iterator to an undefined state.- Specified by:
firstUpdateCount
in interfaceQueryResponse
-
-