Package gov.usgs.earthquake.indexer
Class SearchResponseXmlProductSource
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- gov.usgs.earthquake.product.io.XmlProductSource
-
- gov.usgs.earthquake.indexer.SearchResponseXmlProductSource
-
- All Implemented Interfaces:
ProductSource,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
public class SearchResponseXmlProductSource extends XmlProductSource
Used by SearchResponseParser to store products during parsing. Creates a "background" storage thread for storing, while this classes startElement, characters, and endElement methods are called by the "foreground" xml parsing thread.
-
-
Constructor Summary
Constructors Constructor Description SearchResponseXmlProductSource(FileProductStorage storage)Construct a SearchResponseXmlProductSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Override DefaultHandler endElement.ProductgetProduct()FileProductStoragegetStorage()protected voidsetProduct(Product product)Method used by storage to provide the parsed product.voidsetStorage(FileProductStorage storage)voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)Override DefaultHandler startElement.voidstreamTo(ProductHandler handler)Called by the underlying product storage as part os storeProductSource.-
Methods inherited from class gov.usgs.earthquake.product.io.XmlProductSource
characters, close, closeContent, getHandler, openContentStream, setHandler
-
-
-
-
Constructor Detail
-
SearchResponseXmlProductSource
public SearchResponseXmlProductSource(FileProductStorage storage)
Construct a SearchResponseXmlProductSource.- Parameters:
storage- the storage where the parsed product is stored.
-
-
Method Detail
-
streamTo
public void streamTo(ProductHandler handler)
Called by the underlying product storage as part os storeProductSource. This method notifies the XML parsing thread that parsing may continue, since the handler is now setup.- Specified by:
streamToin interfaceProductSource- Overrides:
streamToin classXmlProductSource- Parameters:
handler- the receiving ProductOutput.
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXExceptionDescription copied from class:XmlProductSourceOverride DefaultHandler startElement. Adds a new element content buffer and calls onStartElement.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classXmlProductSource- Parameters:
uri- element uri.localName- element localName.qName- element qName.attributes- element attributes.- Throws:
org.xml.sax.SAXException- if onStartElement throws a SAXException.
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXExceptionDescription copied from class:XmlProductSourceOverride DefaultHandler endElement. Retrieves element content buffer and passes it to onEndElement.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classXmlProductSource- Parameters:
uri- element uri.localName- element localName.qName- element qName.- Throws:
org.xml.sax.SAXException- if onEndElement throws a SAXException.
-
setStorage
public void setStorage(FileProductStorage storage)
- Parameters:
storage- FileProductStorage to set
-
getStorage
public FileProductStorage getStorage()
- Returns:
- FileProductStorage
-
getProduct
public Product getProduct()
- Returns:
- the parsed, stored product.
-
setProduct
protected void setProduct(Product product)
Method used by storage to provide the parsed product.- Parameters:
product- to set
-
-