PullParser
is meant as a better replacement.public class StreamingParser extends Object
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 ) { ... }
Modifier | Constructor and Description |
---|---|
|
StreamingParser(Configuration configuration,
InputStream input,
Class type)
Deprecated.
Creates a new instance of the type based streaming parser.
|
|
StreamingParser(Configuration configuration,
InputStream input,
QName elementName)
Deprecated.
Creates a new instance of the element name based streaming parser.
|
protected |
StreamingParser(Configuration configuration,
InputStream input,
StreamingParserHandler handler)
Deprecated.
Internal constructor.
|
|
StreamingParser(Configuration configuration,
InputStream input,
String xpath)
Deprecated.
Creates a new instance of the xpath based streaming parser.
|
Modifier and Type | Method and Description |
---|---|
Object |
parse()
Deprecated.
Streams the parser to the next element in the instance document which matches the xpath query
specified in the contstructor.
|
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
public Object parse()
Copyright © 1996–2019 Geotools. All rights reserved.