Permalink
Browse files

Merge pull request #86 from jiwalker-usgs/master

Moving PullParser back to geotools package
  • Loading branch information...
2 parents 0744689 + 2a8281c commit 138eb95b8ddd964d9474b4d98f680ca6b2f32f0c @jiwalker-usgs jiwalker-usgs committed Feb 27, 2014
@@ -1,7 +1,7 @@
package gov.usgs.cida.gdp.wps.parser;
import gov.usgs.cida.gdp.wps.util.GMLUtil;
-import gov.usgs.cida.gdp.wps.util.xml.GDPFeatureParser;
+import org.geotools.xml.PullParser;
import java.io.BufferedInputStream;
import java.io.File;
@@ -274,7 +274,7 @@ private SimpleFeature wrap(SimpleFeature base) {
private final class StreamingFeatureIterator implements FeatureIterator<Feature>, Iterator<Feature> {
- private GDPFeatureParser parser;
+ private PullParser parser;
private InputStream bufferedInputStream;
private InputStream fileInputStream;
private Filter filter;
@@ -298,7 +298,7 @@ private StreamingFeatureIterator(Filter filter, boolean wrap) throws ParserConfi
Configuration newConfiguration = GMLUtil.generateGMLConfiguration(file);
- parser = new GDPFeatureParser(
+ parser = new PullParser(
newConfiguration,
bufferedInputStream,
SimpleFeature.class);
@@ -1,129 +0,0 @@
-package gov.usgs.cida.gdp.wps.util.xml;
-
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFactory;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.geotools.xml.ElementInstance;
-import org.geotools.xml.InstanceComponent;
-import org.geotools.xml.Node;
-import org.geotools.xml.ParserDelegate;
-import org.geotools.xml.impl.DocumentHandler;
-import org.geotools.xml.impl.ElementHandler;
-import org.geotools.xml.impl.ElementImpl;
-import org.geotools.xml.impl.Handler;
-import org.geotools.xml.impl.NodeImpl;
-import org.picocontainer.MutablePicoContainer;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- *
- *
- * @source $URL$
- */
-public class GDPDelegatingHandler implements DocumentHandler, ElementHandler {
-
- ParserDelegate delegate;
- Handler parent;
- QName elementName;
- NodeImpl parseTree;
-
- GDPDelegatingHandler( ParserDelegate delegate, QName elementName, Handler parent) {
- this.delegate = delegate;
- this.parent = parent;
- this.elementName = elementName;
-
- //create a parse tree
- XSDElementDeclaration e = XSDFactory.eINSTANCE.createXSDElementDeclaration();
- e.setTargetNamespace( elementName.getNamespaceURI() );
- e.setName( elementName.getLocalPart() );
-
- ElementImpl instance = new ElementImpl( e );
- instance.setName( elementName.getLocalPart() );
- instance.setNamespace( elementName.getNamespaceURI() );
-
- parseTree = new NodeImpl( instance );
- }
-
- public void setContext(MutablePicoContainer context) {
- }
-
- public MutablePicoContainer getContext() {
- return null;
- }
-
-
- public XSDElementDeclaration getElementDeclaration() {
- return ((ElementInstance)parseTree.getComponent()).getElementDeclaration();
- }
-
- public Handler getParentHandler() {
- return parent;
- }
-
- public Handler createChildHandler(QName name) {
- return new GDPDelegatingHandler( delegate, name, this );
- }
-
- public void startChildHandler(Handler child) {
- }
-
- public void endChildHandler(Handler child) {
- }
-
- public InstanceComponent getComponent() {
- return null;
- }
-
- public Node getParseNode() {
- return parseTree;
- }
-
- public XSDSchemaContent getSchemaContent() {
- return null;
- }
-
- public void startDocument() throws SAXException {
- delegate.startDocument();
- }
-
- public void endDocument() throws SAXException {
- delegate.endDocument();
- }
-
- @Override
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- delegate.startPrefixMapping(prefix, uri);
- }
-
- public void startElement(QName name, Attributes attributes)
- throws SAXException {
-
- if ( !( parent instanceof GDPDelegatingHandler ) ) {
- parent.startChildHandler( this );
- }
-
- delegate.startElement(name.getNamespaceURI(), name.getLocalPart(),
- qname(name) , attributes);
- }
-
- public void characters(char[] ch, int start, int length)
- throws SAXException {
- delegate.characters( ch, start, length );
- }
-
- public void endElement(QName name) throws SAXException {
- delegate.endElement( name.getNamespaceURI(), name.getLocalPart(), qname( name ) );
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- delegate.endPrefixMapping(prefix);
- }
-
- String qname( QName name ) {
- return name.getNamespaceURI() != null ? name.getPrefix() + ":" + name.getLocalPart() : name.getLocalPart();
- }
-}
@@ -1,98 +0,0 @@
-package gov.usgs.cida.gdp.wps.util.xml;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.xsd.XSDSchemaContent;
-import org.geotools.xml.InstanceComponent;
-import org.geotools.xml.Node;
-import org.geotools.xml.impl.DocumentHandler;
-import org.geotools.xml.impl.Handler;
-import org.geotools.xml.impl.HandlerImpl;
-
-
-/**
- *
- *
- * @source $URL$
- */
-public class GDPDocumentHandlerImpl extends HandlerImpl implements DocumentHandler {
- /** factory used to create a handler for the root element **/
- GDPHandlerFactory factory;
-
- /** root node of the parse tree */
- Node tree;
-
- //ElementHandler handler;
-
- /** the parser */
- GDPParserHandler parser;
-
- public GDPDocumentHandlerImpl(GDPHandlerFactory factory, GDPParserHandler parser) {
- this.factory = factory;
- this.parser = parser;
- }
-
- public XSDSchemaContent getSchemaContent() {
- return null;
- }
-
- public InstanceComponent getComponent() {
- return null;
- }
-
- public Object getValue() {
- //jsut return the root of the parse tree's value
- if (tree != null) {
- return tree.getValue();
- }
-
- // //just return the root handler value
- // if (handler != null) {
- // return handler.getValue();
- // }
- return null;
- }
-
- public Node getParseNode() {
- return tree;
- }
-
- public Handler createChildHandler(QName qName) {
- return factory.createElementHandler(qName, this, parser);
- }
-
- // public List getChildHandlers() {
- // if ( handler == null ) {
- // return Collections.EMPTY_LIST;
- // }
- //
- // ArrayList list = new ArrayList();
- // list.add( handler );
- //
- // return list;
- // }
- public void startChildHandler(Handler child) {
- this.tree = child.getParseNode();
-
- //this.handler = (ElementHandler) child;
- }
-
- public void endChildHandler(Handler child) {
- //this.handler = null;
- }
-
- public Handler getParentHandler() {
- //always null, this is the root handler
- return null;
- }
-
- // public ElementHandler getDocumentElementHandler() {
- // return handler;
- // }
-
- public void startDocument() {
- }
-
- public void endDocument() {
- }
-}
Oops, something went wrong.

0 comments on commit 138eb95

Please sign in to comment.