|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectStreamingParser
public class StreamingParser
XML parser capable of streaming.
Performs the same task as Parser
, with the addition
that objects are streamed back to the client. Streaming can occur in a
number of different modes.
As an example consider the following gml document:
<test:TestFeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:test="http://www.geotools.org/test" xsi:schemaLocation="http://www.geotools.org/test test.xsd"> <gml:featureMember> <test:TestFeature fid="0"> ... </test:TestFeature> </gml:featureMember> <gml:featureMember> <test:TestFeature fid="1"> ... </test:TestFeature> </gml:featureMember> <gml:featureMember> <test:TestFeature fid="2"> .... </test:TestFeature> </gml:featureMember> </test:TestFeatureCollection>And suppose we want to stream back each feature as it is parsed.
Configuration configuration = new GMLConfiguration(); QName elementName = new QName( "http://www.geotools.org/test", "TestFeature" ); StreamingParser parser = new StreamingParser( configuration, elementName ); Feature f = null; while ( ( f = parser.parse() ) != null ) { ... }
Configuration configuration = new GMLConfiguration(); StreamingParser parser = new StreamingParser( configuration, Feature.class ); Feature f = null; while ( ( f = parser.parse() ) != null ) { ... }
Configuration configuration = new GMLConfiguration(); String xpath = "//TestFeature"; StreamingParser parser = new StreamingParser( configuration, xpath ); Feature f = null; while ( ( f = parser.parse() ) != null ) { ... }
Constructor Summary | |
---|---|
|
StreamingParser(Configuration configuration,
InputStream input,
Class type)
Creates a new instance of the type based streaming parser. |
|
StreamingParser(Configuration configuration,
InputStream input,
QName elementName)
Creates a new instance of the element name based streaming parser. |
protected |
StreamingParser(Configuration configuration,
InputStream input,
StreamingParserHandler handler)
Internal constructor. |
|
StreamingParser(Configuration configuration,
InputStream input,
String xpath)
Creates a new instance of the xpath based streaming parser. |
Method Summary | |
---|---|
Object |
parse()
Streams the parser to the next element in the instance document which matches the xpath query specified in the contstructor. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamingParser(Configuration configuration, InputStream input, Class type) throws ParserConfigurationException, SAXException
configuration
- Object representing the configuration of the parser.input
- The input stream representing the instance document to be parsed.type
- The type of parsed objects to stream back.
ParserConfigurationException
SAXException
public StreamingParser(Configuration configuration, InputStream input, QName elementName) throws ParserConfigurationException, SAXException
configuration
- Object representing the configuration of the parser.input
- The input stream representing the instance document to be parsed.elementName
- The name of elements to stream back.
ParserConfigurationException
SAXException
public StreamingParser(Configuration configuration, InputStream input, String xpath) throws ParserConfigurationException, SAXException
configuration
- Object representing the configuration of the parser.input
- The input stream representing the instance document to be parsed.xpath
- An xpath expression which dictates how the parser streams
objects back to the client.
ParserConfigurationException
SAXException
protected StreamingParser(Configuration configuration, InputStream input, StreamingParserHandler handler) throws ParserConfigurationException, SAXException
ParserConfigurationException
SAXException
Method Detail |
---|
public Object parse()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |