Class ObjectProductSource

  • All Implemented Interfaces:
    ProductSource

    public class ObjectProductSource
    extends java.lang.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 Detail

      • ObjectProductSource

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

      • streamTo

        public void streamTo​(ProductHandler out)
                      throws java.lang.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. sendEndProducct
        Specified by:
        streamTo in interface ProductSource
        Parameters:
        out - the ProductOutput that will receive the Product.
        Throws:
        java.lang.Exception - if error occurs
      • sendBeginProduct

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

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

        public void sendLinks​(ProductHandler out)
                       throws java.lang.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:
        java.lang.Exception - if out.onProperty throws an Exception.
      • sendContents

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

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

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

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

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