Class SearchResponseXmlProductSource

All Implemented Interfaces:
ProductSource, ContentHandler, DTDHandler, EntityResolver, 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 Details

    • SearchResponseXmlProductSource

      public SearchResponseXmlProductSource(FileProductStorage storage)
      Construct a SearchResponseXmlProductSource.
      Parameters:
      storage - the storage where the parsed product is stored.
  • Method Details

    • 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:
      streamTo in interface ProductSource
      Overrides:
      streamTo in class XmlProductSource
      Parameters:
      handler - the receiving ProductOutput.
    • startElement

      public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
      Description copied from class: XmlProductSource
      Override DefaultHandler startElement. Adds a new element content buffer and calls onStartElement.
      Specified by:
      startElement in interface ContentHandler
      Overrides:
      startElement in class XmlProductSource
      Parameters:
      uri - element uri.
      localName - element localName.
      qName - element qName.
      attributes - element attributes.
      Throws:
      SAXException - if onStartElement throws a SAXException.
    • endElement

      public void endElement(String uri, String localName, String qName) throws SAXException
      Description copied from class: XmlProductSource
      Override DefaultHandler endElement. Retrieves element content buffer and passes it to onEndElement.
      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class XmlProductSource
      Parameters:
      uri - element uri.
      localName - element localName.
      qName - element qName.
      Throws:
      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