Package org.apache.cayenne.util
Class GenericResponse
- java.lang.Object
-
- org.apache.cayenne.util.GenericResponse
-
- All Implemented Interfaces:
Serializable,QueryResponse
public class GenericResponse extends Object implements QueryResponse, Serializable
A simple serializable implementation of QueryResponse.- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcurrentIndexprotected Listresults
-
Constructor Summary
Constructors Constructor Description GenericResponse()Creates an empty BaseResponse.GenericResponse(List list)Creates a BaseResponse with a single result list.GenericResponse(QueryResponse response)Creates a response that it a shallow copy of another response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBatchUpdateCount(int[] resultCount)voidaddResultList(List list)voidaddUpdateCount(int resultCount)voidclear()Clears any previously collected information.ListcurrentList()Returns a List under the current iterator position.int[]currentUpdateCount()Returns an update count under the current iterator position.ListfirstList()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.booleanisList()Returns whether current iteration result is a list or an update count.booleannext()Rewinds response iterator to the next result, returning true if it is available.voidreplaceResult(Object oldResult, Object newResult)Replaces previously stored result with a new result.voidreset()Restarts response iterator.intsize()Returns a number of results in the response.
-
-
-
Field Detail
-
results
protected List results
-
currentIndex
protected transient int currentIndex
-
-
Constructor Detail
-
GenericResponse
public GenericResponse()
Creates an empty BaseResponse.
-
GenericResponse
public GenericResponse(List list)
Creates a BaseResponse with a single result list.
-
GenericResponse
public GenericResponse(QueryResponse response)
Creates a response that it a shallow copy of another response.
-
-
Method Detail
-
firstList
public List firstList()
Description copied from interface:QueryResponseA 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:
firstListin interfaceQueryResponse
-
firstUpdateCount
public int[] firstUpdateCount()
Description copied from interface:QueryResponseA 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:
firstUpdateCountin interfaceQueryResponse
-
currentList
public List currentList()
Description copied from interface:QueryResponseReturns a List under the current iterator position. UseQueryResponse.isList()to check the result type before calling this method.- Specified by:
currentListin interfaceQueryResponse
-
currentUpdateCount
public int[] currentUpdateCount()
Description copied from interface:QueryResponseReturns 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:
currentUpdateCountin interfaceQueryResponse
-
isList
public boolean isList()
Description copied from interface:QueryResponseReturns whether current iteration result is a list or an update count.- Specified by:
isListin interfaceQueryResponse
-
next
public boolean next()
Description copied from interface:QueryResponseRewinds response iterator to the next result, returning true if it is available.- Specified by:
nextin interfaceQueryResponse
-
reset
public void reset()
Description copied from interface:QueryResponseRestarts response iterator.- Specified by:
resetin interfaceQueryResponse
-
size
public int size()
Description copied from interface:QueryResponseReturns a number of results in the response.- Specified by:
sizein interfaceQueryResponse
-
clear
public void clear()
Clears any previously collected information.
-
addBatchUpdateCount
public void addBatchUpdateCount(int[] resultCount)
-
addUpdateCount
public void addUpdateCount(int resultCount)
-
addResultList
public void addResultList(List list)
-
-