|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.AbstractSequentialList<XmlResource> net.sf.xaj.core.StaxXQuerySearchResults
public class StaxXQuerySearchResults
Implementation of XmlDb.XQuerySearchResults
using StAX parsing
to conserve memory on large result sets.
There are some limitations to consider when using this class. Every XmlResource
returned from AbstractSequentialList.iterator()
should be "consumed" in some way before calling
Iterator.next()
. By "consumed" we refer to calling any of the
XmlResource.getAs*
or XmlResource.free()
methods. This is because
of how the XML input is internally streamed with StAX. Additionally, each
XmlResource may only be consumed once.
This class can also be used as a convienent method of parsing a large
XML document into smaller, individual XML resources by splitting the document
into individual resources for each element that is a child of the root element.
By default this class will skip the root element, returning one XmlResource
for each element that is a child of the root element. Simply pass a null
Metadata
value to one of the constructors, and then you can call
the AbstractSequentialList.iterator()
method to get an iterator over these XML resources.
The Iterator
returned by AbstractSequentialList.iterator()
is an implementation of
ListIterator
but does not support the remove()
,
previous()
, add()
, or set()
methods.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
StaxXQuerySearchResults(java.io.Reader xmlStream,
XmlDb.SearchResultsMetadata metadata)
Construct instance from stream. |
|
StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile,
XmlDb.SearchResultsMetadata metadata)
Construct instance. |
|
StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile,
XmlDb.SearchResultsMetadata metadata,
boolean deleteOnClear)
Construct instance. |
|
StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile,
XmlDb.SearchResultsMetadata metadata,
boolean deleteOnClear,
java.util.concurrent.ExecutorService executorService)
Construct instance. |
Method Summary | |
---|---|
void |
clear()
|
void |
clearTempData()
Delete the temporary file associated with this instance. |
XmlDb.SearchResultsMetadata |
getMetadata()
Get the result metadata. |
boolean |
isSkipRootElement()
|
java.util.ListIterator<XmlResource> |
listIterator(int index)
|
void |
setSkipRootElement(boolean skipXmlDbXQueryResultListRootElement)
|
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.util.AbstractSequentialList |
---|
add, addAll, get, iterator, remove, set |
Methods inherited from class java.util.AbstractList |
---|
add, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, 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, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
add, add, addAll, addAll, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray |
Constructor Detail |
---|
public StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile, XmlDb.SearchResultsMetadata metadata)
Calls #StaxXQuerySearchResults(File, SearchResultsMetadata, boolean)
passing true for the deleteOnClear
parameter.
xmlFile
- the XML file to read frommetadata
- the metadatapublic StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile, XmlDb.SearchResultsMetadata metadata, boolean deleteOnClear)
xmlFile
- the XML file to read frommetadata
- the metadatadeleteOnClear
- if true then delete the xml file when clear()
is called, otherwise do notpublic StaxXQuerySearchResults(org.springframework.core.io.Resource xmlFile, XmlDb.SearchResultsMetadata metadata, boolean deleteOnClear, java.util.concurrent.ExecutorService executorService)
xmlFile
- the XML file to read frommetadata
- the metadatadeleteOnClear
- if true then delete the xml file when clear()
is called, otherwise do notexecutorService
- if provided, then will be used by returned
XmlResource.getAsStream()
method, to allow for returning large
input streams via a PipedInputStream
.public StaxXQuerySearchResults(java.io.Reader xmlStream, XmlDb.SearchResultsMetadata metadata)
xmlStream
- the XML data to read frommetadata
- the metadataMethod Detail |
---|
public java.util.ListIterator<XmlResource> listIterator(int index)
listIterator
in interface java.util.List<XmlResource>
listIterator
in class java.util.AbstractSequentialList<XmlResource>
public int size()
size
in interface java.util.Collection<XmlResource>
size
in interface java.util.List<XmlResource>
size
in class java.util.AbstractCollection<XmlResource>
public void clear()
clear
in interface java.util.Collection<XmlResource>
clear
in interface java.util.List<XmlResource>
clear
in class java.util.AbstractList<XmlResource>
public void clearTempData()
This method can be called to delete the temp file holding the search results data. This might be useful in a running server, which does not terminate for a very long time but these objects are cached, even after this search results object might not be valid any more.
After calling this method, the instance is no longer valid and calls to other methods will fail. Repeated calls to this method have no effect.
public XmlDb.SearchResultsMetadata getMetadata()
XmlDb.XQuerySearchResults
getMetadata
in interface XmlDb.XQuerySearchResults
public java.lang.String toString()
toString
in class java.util.AbstractCollection<XmlResource>
public boolean isSkipRootElement()
public void setSkipRootElement(boolean skipXmlDbXQueryResultListRootElement)
skipXmlDbXQueryResultListRootElement
- the skipXmlDbXQueryResultListRootElement to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |