Class ObjectProductSource

java.lang.Object
gov.usgs.earthquake.product.io.ObjectProductSource
All Implemented Interfaces:
ProductSource

public class ObjectProductSource extends Object implements ProductSource
Convert a java Product object into events for a ProductHandler. ObjectProductSource turns a product object into a stream of events for ProductOutputs. ObjectProductSources are reuseable for a given product.
  • Constructor Details

    • ObjectProductSource

      public ObjectProductSource(Product product)
      Construct a new ObjectProductSource.
      Parameters:
      product - the product used for input.
  • Method Details

    • streamTo

      public void streamTo(ProductHandler out) throws Exception
      Send a product object to a ProductOutput. Calls these methods in the following order:
      1. sendBeginProduct
      2. sendProperties
      3. sendLinks
      4. sendContents
      5. sendSignature
      6. sendEndProduct
      Specified by:
      streamTo in interface ProductSource
      Parameters:
      out - the ProductOutput that will receive the Product.
      Throws:
      Exception - if error occurs
    • sendBeginProduct

      public void sendBeginProduct(ProductHandler out) throws Exception
      Call out's onBeginProduct method for this product.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onBeginProduct throws an Exception.
    • sendProperties

      public void sendProperties(ProductHandler out) throws Exception
      Call out's onProperty method for each product property. Calls in alphabetical order by property name.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onProperty throws an Exception.
    • sendLinks

      public void sendLinks(ProductHandler out) throws Exception
      Call out's onLink method for each product link. Calls in alphabetical order by relation name, by URI.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onProperty throws an Exception.
    • sendContents

      public void sendContents(ProductHandler out) throws Exception
      Call out's onContent method for each product content. Calls alphabetically by content path.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onContent throws an Exception.
    • sendSignatureVersion

      public void sendSignatureVersion(ProductHandler out) throws Exception
      Call out's onSignature method with product signature.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onSignature throws an Exception.
    • sendSignature

      public void sendSignature(ProductHandler out) throws Exception
      Call out's onSignature method with product signature.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onSignature throws an Exception.
    • sendSignatureHistory

      public void sendSignatureHistory(ProductHandler out) throws Exception
      Call out's onSignatureHistory method with product signature history.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onSignature throws an Exception.
    • sendEndProduct

      public void sendEndProduct(ProductHandler out) throws Exception
      Call out's onEndProduct method for product.
      Parameters:
      out - the receiving ProductOutput.
      Throws:
      Exception - if out.onEndProduct throws an Exception.
    • close

      public void close()
      Free any resources associated with this source.
      Specified by:
      close in interface ProductSource