|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.AbstractXmlObject
com.waveset.object.RepositoryResult
A class used to represent a simple "query result" containing information about a collection of objects.
This object will typically be created by a storage manager to represent the results of a query, but can also be created manually to represent some arbitrary collection of objects.
This started life as an in-memory result set object, though we've extended it to be more of a "cursor-like" result set iterator.
Users should wean themselves away from the getRows() method and start using hasNext(), next(). This may eventually be refactored into an abstract result interface, with a memory implementation and one or more database implementations such one wrapping a java.sql.ResultSet.
There are still issues that need to be addressed before that happens however, notably the lifespan of java.sql.ResultSet and how they transition between machines during load balancing (i.e. they are not serializable, therefore they cannot be attached to an HttpSession). Because of this, we may not be able to support cursors for the web applications, though it may still be desireable to have them for standalone configuration and report generation apps, which are the ones that are more likely to be dealing with large result sets anyway.
Nested Class Summary | |
static class |
RepositoryResult.OrderByComparator
Internal class that implenents the Comparator interface for sorting the rows in the table based on an ordered set of attributes. |
static class |
RepositoryResult.Row
This class is used to represent each "row" of the result. |
static class |
RepositoryResult.RowComparator
Implements the Comparator interface for sorting the rows in the table. |
static interface |
RepositoryResult.RowMerger
Internal class that specifies an interface for merging two rows where the name is the same. |
Field Summary | |
protected boolean |
_buffered
If true , this result contains only a subset
of rows matching the specified type and attribute conditions. |
protected int |
_index
The current iteration position within the result. |
protected RepositoryResult.Row[] |
_rowArray
A native array representation of the Row objects stored in the _rows field. |
protected java.util.List |
_rows
The list of results. |
protected int |
_size
The estimated number of items (rows) matching the caller's query. |
protected boolean |
_sizeError
If true, we previously caught an exception getting virtual size. |
protected int |
_virtualIndex
Our estimated position within the entire (virtual) result. |
static java.lang.String |
ATT_BLOCK_SIZE
|
static java.lang.String |
ATT_BUFFERED
|
static java.lang.String |
ATT_END_BEFORE
|
static java.lang.String |
ATT_INDEX
|
static java.lang.String |
ATT_NEED_LOCKINFO
|
static java.lang.String |
ATT_NEED_OBJECT
|
static java.lang.String |
ATT_NEED_SUMMARY
|
static java.lang.String |
ATT_ORDER_BY
|
static java.lang.String |
ATT_SIZE_ERROR
|
static java.lang.String |
ATT_START_AFTER
|
static java.lang.String |
ATT_TARGET_TYPE
|
static java.lang.String |
ATT_VIRTUAL_INDEX
|
static java.lang.String |
ATT_VIRTUAL_SIZE
|
static java.lang.String |
code_id
|
static java.lang.String |
ELEMENT
|
protected static Trace |
trace
|
Fields inherited from class com.waveset.util.AbstractXmlObject |
_trace |
Constructor Summary | |
RepositoryResult()
Create an empty result object. |
|
RepositoryResult(org.w3c.dom.Element e)
Create a result object by parsing a DOM element. |
|
RepositoryResult(java.util.List poList,
boolean includeObject,
boolean includeAttributes)
Create a result object containing a collection of objects specified in a List. |
|
RepositoryResult(LockInfo[] lockInfoArray)
Create a result object containing lock information for a collection of objects. |
|
RepositoryResult(PersistentObject[] poArray)
Create a result object containing a collection of objects specified in an array. |
|
RepositoryResult(RepositoryResult in)
Create a result object containing a clone of another repository result |
|
RepositoryResult(java.lang.String xml)
Create a result object by deserializing its XML representation. |
Method Summary | |
void |
add(RepositoryResult.Row r)
Add a new row to the result set. |
void |
append(RepositoryResult s)
Append a result set to this one. |
void |
append(RepositoryResult s,
int limit)
|
protected boolean |
bufferHasNext()
Returns true if there are more rows in this result's current buffer. |
protected boolean |
bufferHasPrevious()
Returns true if there are previous rows in this result's current buffer. |
protected void |
clear()
Remove all of the elements from the row list. |
protected void |
ensureCapacity(int minCapacity)
Increase the size of the row list (if necessary) to hold the specified number of elements. |
RepositoryResult.Row |
first()
|
RepositoryResult.Row |
get(int index)
Deprecated. since GA 1.2. Use next() instead. |
AttributeCondition[] |
getAttributeConditions()
|
protected AttributeExpression |
getAuthorizationFilter()
Cache an attribute expression that describes the set of items of the target type that the caller is allowed to see. |
int |
getBlockSize()
|
protected int |
getCurrentSize()
Package-scope method allows RepositoryProxy to count the row list of this Result. |
java.lang.String |
getDisplayableName(int index)
Return the display name (if there is one) or the name associated with one of the result rows. |
java.lang.String |
getDisplayName(int index)
Return the display name associated with one of the reusult rows. |
java.lang.String |
getElementName()
XmlObjectFactory requires this. |
protected java.lang.String[] |
getEndBefore()
|
protected boolean |
getFetchPrevious()
|
java.lang.String |
getId(int index)
Deprecated. since GA 1.2. RepositoryResult now implements Iterator. |
int |
getIndex()
Get the current iteration index |
java.lang.String |
getName(int index)
Deprecated. since GA 1.2. RepositoryResult now implements Iterator. |
PersistentObject |
getObject(int index)
Deprecated. since GA 1.2. RepositoryResult now implements Iterator. |
protected ObjectLoader |
getObjectLoader()
|
Attribute[] |
getOrderBy()
|
int |
getRowCount()
Deprecated. since GA 1.2. RepositoryResult now implements Iterator. |
RepositoryResult.Row[] |
getRows()
Deprecated. since GA 1.2. RepositoryResult now implements Iterator. |
protected java.lang.String[] |
getStartAfter()
|
boolean |
getSummaryReferencesResolved()
|
Type |
getTargetType()
|
protected int |
getVirtualSize()
|
boolean |
hasNext()
|
boolean |
hasPrevious()
|
boolean |
isBuffered()
|
RepositoryResult.Row |
last()
|
static void |
main(java.lang.String[] args)
|
void |
merge(RepositoryResult s,
int limit,
java.util.Set dupsMap)
|
void |
merge(RepositoryResult s,
int limit,
java.util.Set dupsMap,
RepositoryResult.RowMerger rowMerger)
|
RepositoryResult.Row |
next()
|
RepositoryResult.Row |
previous()
|
void |
remove(int index)
Remove a row from the result set. |
void |
remove(int index,
int count)
|
void |
remove(RepositoryResult.Row r)
Remove a row from the result set. |
void |
resetIteration()
Seeks to the first row in the result. |
protected void |
reverse()
Reverses the order of the elements in the row list. |
void |
seek(int index)
Deprecated. - since GA 1.2. Use hasNext() and next(). |
void |
setAttributeConditions(AttributeCondition[] attrConds)
Cache a set of query attribute conditions supplied by the caller to buffered 'list' and 'get' methods. |
protected void |
setAuthorizationFilter(AttributeExpression filter)
Cache an attribute expression that describes the set of items of the target type that the caller is allowed to see. |
void |
setBlockSize(int blockSize)
Set the number of items (rows) requested by the caller of buffered 'list' and 'get' methods. |
protected void |
setBuffered(boolean b)
Package-level method to set _buffered. |
void |
setEndBefore(int rowNumber)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
protected void |
setEndBefore(RepositoryResult.Row row)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
protected void |
setEndBefore(java.lang.String[] endBefore)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
protected void |
setFetchPrevious(boolean b)
Specify whether the result should return rows in descending order. |
protected void |
setObjectLoader(ObjectLoader objectLoader)
Set handle to Session (for callback to nextBlock). |
protected void |
setOrderBy(Attribute[] orderBy)
Cache a concatenated key specification supplied by the caller to buffered 'list' and 'get' methods. |
void |
setStartAfter(int rowNumber)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
protected void |
setStartAfter(RepositoryResult.Row row)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
protected void |
setStartAfter(java.lang.String[] startAfter)
Set the concatenated key value to select the first row of the next block of items returned by buffered 'list' and 'get' methods. |
void |
setSummaryReferencesResolved(boolean set)
|
void |
setTargetType(Type targetType)
Cache a concatenated key specification supplied by the caller to buffered 'list' and 'get' methods. |
int |
size()
|
int |
size(boolean forceRead)
|
void |
sort()
Deprecated. since GA 1.2. Instead, call a flavor of 'list' or 'get' that takes an 'orderBy' argument. |
void |
sort(Attribute[] orderBy)
Sort based on an ordered set of Attributes. |
protected boolean |
subclassGetNextBlock()
Default implementation can be overridden by subclass. |
protected boolean |
subclassGetPreviousBlock()
Default implementation can be overridden by subclass. |
protected int |
subclassGetVirtualSize()
Default implementation can be overridden by subclass. |
java.lang.String |
toXml()
Serialize a result to an XML string. |
void |
toXml(java.lang.StringBuffer b)
Original interface, maintained for backward compatibility. |
void |
toXml(java.lang.StringBuffer b,
int indent)
Serialize a result into an XML buffer. |
protected void |
trimToSize()
Trim the capacity of the row list to be the list's current size. |
Methods inherited from class com.waveset.util.AbstractXmlObject |
addXmlHeader, cloneObject, dump, dumpFile, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
protected static final Trace trace
public static final java.lang.String ELEMENT
protected java.util.List _rows
Row
protected int _index
It might be nice to support an external Iterator as well so result set iteration could be reentrant.
protected int _virtualIndex
Analogous to the field "_index" in RepositoryResult
,
which represents our position in the current buffer of rows.
protected RepositoryResult.Row[] _rowArray
protected int _size
The RepositoryResult pretends to contain all of the rows, but may actually "page" through the result set internally.
protected boolean _buffered
true
, this result contains only a subset
of rows matching the specified type and attribute conditions.
protected boolean _sizeError
public static final java.lang.String ATT_TARGET_TYPE
public static final java.lang.String ATT_INDEX
public static final java.lang.String ATT_ORDER_BY
public static final java.lang.String ATT_START_AFTER
public static final java.lang.String ATT_END_BEFORE
public static final java.lang.String ATT_BLOCK_SIZE
public static final java.lang.String ATT_NEED_OBJECT
public static final java.lang.String ATT_NEED_LOCKINFO
public static final java.lang.String ATT_NEED_SUMMARY
public static final java.lang.String ATT_BUFFERED
public static final java.lang.String ATT_VIRTUAL_INDEX
public static final java.lang.String ATT_VIRTUAL_SIZE
public static final java.lang.String ATT_SIZE_ERROR
Constructor Detail |
public RepositoryResult()
public RepositoryResult(java.lang.String xml) throws WavesetException
public RepositoryResult(org.w3c.dom.Element e) throws WavesetException
public RepositoryResult(PersistentObject[] poArray)
A convenience constructor to convert an array of objects into a result object. This is used mainly by the Repository.
public RepositoryResult(java.util.List poList, boolean includeObject, boolean includeAttributes)
A convenience constructor to convert a list of objects into a result object.
public RepositoryResult(RepositoryResult in)
public RepositoryResult(LockInfo[] lockInfoArray)
This is used mainly by the Repository.
Method Detail |
public boolean isBuffered()
false
if the result is complete;
that is, physically contains all matching rows in memory.
Returns true
if the result is buffered;
that is, contain only a block of rows at any one time.protected void setBuffered(boolean b)
isBuffered()
public java.lang.String getElementName()
getElementName
in interface XmlObject
getElementName
in class AbstractXmlObject
public void add(RepositoryResult.Row r)
public void remove(RepositoryResult.Row r)
public void remove(int index)
public void remove(int index, int count)
public void append(RepositoryResult s) throws WavesetException
This was necessary for WavesetConsole which assembles an aggregate result from several repository queries.
NOTE: The rows are not copied, both result sets will end up referencing the same row objects. Normally the source result will become garbage shortly, and this result will take ownership of the rows.
WavesetException
public void append(RepositoryResult s, int limit) throws WavesetException
WavesetException
public void merge(RepositoryResult s, int limit, java.util.Set dupsMap, RepositoryResult.RowMerger rowMerger) throws WavesetException
WavesetException
public void merge(RepositoryResult s, int limit, java.util.Set dupsMap) throws WavesetException
WavesetException
protected void ensureCapacity(int minCapacity)
NOTE: This is intended for use only by Repository.
protected void trimToSize()
NOTE: This is intended for use only by Repository.
protected void clear()
NOTE: This is intended for use only by Repository.
protected void reverse()
NOTE: This is intended for use only by Repository.
public Attribute[] getOrderBy()
setOrderBy(com.waveset.object.Attribute[])
protected void setOrderBy(Attribute[] orderBy) throws InvalidArgument
NOTE: This is intended for use only by Repository.
InvalidArgument
setStartAfter(java.lang.String[])
public AttributeCondition[] getAttributeConditions()
public void setAttributeConditions(AttributeCondition[] attrConds) throws InvalidArgument
NOTE: This is intended for use only by Repository. GAW - need to expose this so I can set it when merging repo results from the repo and a rule driven user member query.
InvalidArgument
protected AttributeExpression getAuthorizationFilter()
NOTE: This is intended for use only by Session and Repository.
protected void setAuthorizationFilter(AttributeExpression filter) throws InvalidArgument
NOTE: This is intended for use only by Session and Repository.
InvalidArgument
public Type getTargetType()
public void setTargetType(Type targetType) throws InvalidArgument
NOTE: This is intended for use only by Repository. GAW - need to expose this so I can set it when merging repo results from the repo and a rule driven user member query.
InvalidArgument
protected java.lang.String[] getStartAfter()
setStartAfter(java.lang.String[])
,
setOrderBy(com.waveset.object.Attribute[])
protected void setStartAfter(java.lang.String[] startAfter) throws InvalidArgument
InvalidArgument
protected void setStartAfter(RepositoryResult.Row row) throws InvalidArgument
row
- - a RepositoryResult.Row.
Build a concatenated key from its values.
InvalidArgument
setOrderBy(com.waveset.object.Attribute[])
public void setStartAfter(int rowNumber) throws InvalidArgument
rowNumber
- - the index of a row
currently stored in this RepositoryResult.
Build a concatenated key from its values.
InvalidArgument
setOrderBy(com.waveset.object.Attribute[])
protected java.lang.String[] getEndBefore()
setEndBefore(java.lang.String[])
,
setOrderBy(com.waveset.object.Attribute[])
protected void setEndBefore(java.lang.String[] endBefore) throws InvalidArgument
InvalidArgument
protected void setEndBefore(RepositoryResult.Row row) throws InvalidArgument
row
- - a RepositoryResult.Row.
Build a concatenated key from its values.
InvalidArgument
setOrderBy(com.waveset.object.Attribute[])
public void setEndBefore(int rowNumber) throws InvalidArgument
rowNumber
- - the index of a row
currently stored in this RepositoryResult.
Build a concatenated key from its values.
InvalidArgument
setOrderBy(com.waveset.object.Attribute[])
public int getBlockSize()
public void setBlockSize(int blockSize) throws InvalidArgument
InvalidArgument
public int size()
-1
if the number of rows cannot be estimated.
Service code that needs privileged access to repository result contents may call methods of RepositoryProxy:
RepositoryProxy.getCurrentSize(RepositoryResult)
,
RepositoryProxy.getCurrentRowList(RepositoryResult)
public int size(boolean forceRead)
forceRead
- if true, forces Lighthouse to recalculate the size
of the buffered result. If false, this method will rely on any
previously cached value.
Service code that needs privileged access to repository result contents may call methods of RepositoryProxy:
-1
if the number of rows cannot be estimated.
RepositoryProxy.getCurrentSize(RepositoryResult)
,
RepositoryProxy.getCurrentRowList(RepositoryResult)
protected int getVirtualSize()
-1
if the number of rows cannot be estimated.protected boolean getFetchPrevious()
true
if the result should return rows
in descending order; otherwise false
.
The default is to return rows in ascending order.
NOTE: This is intended for use only by Session and Repository.
protected void setFetchPrevious(boolean b) throws InvalidArgument
NOTE: This is intended for use only by Session and Repository.
InvalidArgument
protected ObjectLoader getObjectLoader()
NOTE: This is intended for use only by Repository.
protected void setObjectLoader(ObjectLoader objectLoader)
NOTE: This is intended for use only by Session.
public void setSummaryReferencesResolved(boolean set)
public boolean getSummaryReferencesResolved()
protected boolean bufferHasNext() throws WavesetException
WavesetException
protected boolean bufferHasPrevious() throws WavesetException
WavesetException
public boolean hasNext() throws WavesetException
true
if there are more rows in the result.
Use next()
(or one of the "get" methods)
to obtain information for the current row.
WavesetException
public boolean hasPrevious() throws WavesetException
true
if there are previous rows in the result.
Use previous()
to get the row prior to the current row.
WavesetException
public RepositoryResult.Row next() throws java.util.NoSuchElementException, WavesetException
// * We could implement the java.util.Iterator interface, // * but then we'd have to return Object and downcast. // * We would also be constrained on the sorts of exceptions we can // * throw, and its likely that we're going to want a number of them. // *
// * Could also support more of a JDBC like interface where // * next() doesn't return anything, and then we'd need a bunch // * of accessors for "columns" in the current row.
java.util.NoSuchElementException
WavesetException
public RepositoryResult.Row previous() throws java.util.NoSuchElementException, WavesetException
// * We could implement the java.util.Iterator interface, // * but then we'd have to return Object and downcast. // * We would also be constrained on the sorts of exceptions we can // * throw, and its likely that we're going to want a number of them. // *
// * Could also support more of a JDBC like interface where // * next() doesn't return anything, and then we'd need a bunch // * of accessors for "columns" in the current row.
java.util.NoSuchElementException
WavesetException
public RepositoryResult.Row first() throws java.util.NoSuchElementException, WavesetException
java.util.NoSuchElementException
WavesetException
public RepositoryResult.Row last() throws java.util.NoSuchElementException, WavesetException
java.util.NoSuchElementException
WavesetException
protected boolean subclassGetNextBlock() throws WavesetException
WavesetException
protected boolean subclassGetPreviousBlock() throws WavesetException
WavesetException
protected int subclassGetVirtualSize() throws WavesetException
WavesetException
public void seek(int index) throws java.util.NoSuchElementException
java.util.NoSuchElementException
public void resetIteration()
first()
public int getIndex()
public void sort() throws InternalError
InternalError
public void sort(Attribute[] orderBy) throws InvalidArgument
InvalidArgument
public RepositoryResult.Row[] getRows()
protected int getCurrentSize()
public int getRowCount()
public RepositoryResult.Row get(int index)
next()
instead.
public PersistentObject getObject(int index)
public java.lang.String getName(int index)
public java.lang.String getDisplayName(int index)
public java.lang.String getDisplayableName(int index)
public java.lang.String getId(int index)
public java.lang.String toXml()
toXml
in interface XmlObject
toXml
in class AbstractXmlObject
public void toXml(java.lang.StringBuffer b)
toXml
in class AbstractXmlObject
public void toXml(java.lang.StringBuffer b, int indent)
toXml
in interface XmlObject
toXml
in class AbstractXmlObject
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |