Class SaxEventHandlerDelegate
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
This class is used by the
XmlInputTransformer to delegate SAX Parse events to the
relevant handlers. Its primary method is read(java.io.InputStream) which takes in an
InputStream returns a Metacard, populated with all the Attributes parsed
by the eventHandlers-
Constructor Summary
ConstructorsConstructorDescriptionSaxEventHandlerDelegate(List<org.codice.ddf.transformer.xml.streaming.SaxEventHandler> eventHandlers) -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) Takes in a sax event fromparserand passes it to theeventHandlersvoidTakes in a sax event fromparserand passes it to theeventHandlersvoidendElement(String namespaceURI, String localName, String qName) Takes in a sax event fromparserand passes it to theeventHandlersvoidendPrefixMapping(String prefix) ddf.catalog.data.MetacardgetMetacard(String id) ddf.catalog.data.MetacardTypeDefines and returns aDynamicMetacardTypebased on component Sax Event Handlers and what attributes they populateorg.apache.commons.io.input.TeeInputStreamgetMetadataStream(InputStream inputStream, OutputStream outputStream) read(InputStream inputStream) Takes in anInputStreamreturns aMetacard, populated with all theAttributes parsed by theeventHandlersvoidTakes in a sax event fromparserand passes it to theeventHandlersvoidstartElement(String uri, String localName, String qName, Attributes attributes) Takes in a sax event fromparserand passes it to theeventHandlersvoidstartPrefixMapping(String prefix, String uri) Takes in a sax event fromparserand passes it to theeventHandlersMethods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
SaxEventHandlerDelegate
public SaxEventHandlerDelegate() -
SaxEventHandlerDelegate
public SaxEventHandlerDelegate(List<org.codice.ddf.transformer.xml.streaming.SaxEventHandler> eventHandlers)
-
-
Method Details
-
read
public SaxEventHandlerDelegate read(InputStream inputStream) throws ddf.catalog.transform.CatalogTransformerException Takes in anInputStreamreturns aMetacard, populated with all theAttributes parsed by theeventHandlers- Parameters:
inputStream- an XML document that can be parsed into a Metacard- Returns:
- a
Metacard, populated with all theAttributes parsed by theeventHandlers - Throws:
ddf.catalog.transform.CatalogTransformerException
-
getMetacard
-
startDocument
Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
endDocument
Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
uri- the URI that is passed in bySaxEventHandlerDelegatelocalName- the localName that is passed in bySaxEventHandlerDelegateqName- the qName that is passed in bySaxEventHandlerDelegateattributes- the attributes that are passed in bySaxEventHandlerDelegate- Throws:
SAXException
-
characters
Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
ch- the ch that is passed in bySaxEventHandlerDelegatestart- the start that is passed in bySaxEventHandlerDelegatelength- the length that is passed in bySaxEventHandlerDelegate- Throws:
SAXException
-
endElement
Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
namespaceURI- the namespaceURI that is passed in bySaxEventHandlerDelegatelocalName- the localName that is passed in bySaxEventHandlerDelegateqName- the qName that is passed in bySaxEventHandlerDelegate- Throws:
SAXException
-
startPrefixMapping
Takes in a sax event fromparserand passes it to theeventHandlers- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Parameters:
prefix- the prefix that is passed in bySaxEventHandlerDelegateuri- the uri that is passed in bySaxEventHandlerDelegate- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Throws:
SAXException
-
getMetadataStream
public org.apache.commons.io.input.TeeInputStream getMetadataStream(InputStream inputStream, OutputStream outputStream) -
getMetacardType
Defines and returns aDynamicMetacardTypebased on component Sax Event Handlers and what attributes they populate- Returns:
- a DynamicMetacardType that describes the type of metacard that is created in this transformer
-