Package gov.usgs.earthquake.product.io
Class ObjectProductSource
- java.lang.Object
-
- gov.usgs.earthquake.product.io.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 Summary
Constructors Constructor Description ObjectProductSource(Product product)
Construct a new ObjectProductSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free any resources associated with this source.void
sendBeginProduct(ProductHandler out)
Call out's onBeginProduct method for this product.void
sendContents(ProductHandler out)
Call out's onContent method for each product content.void
sendEndProduct(ProductHandler out)
Call out's onEndProduct method for product.void
sendLinks(ProductHandler out)
Call out's onLink method for each product link.void
sendProperties(ProductHandler out)
Call out's onProperty method for each product property.void
sendSignature(ProductHandler out)
Call out's onSignature method with product signature.void
sendSignatureVersion(ProductHandler out)
Call out's onSignature method with product signature.void
streamTo(ProductHandler out)
Send a product object to a ProductOutput.
-
-
-
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:- sendBeginProduct
- sendProperties
- sendLinks
- sendContents
- sendSignature
- sendEndProducct
- Specified by:
streamTo
in interfaceProductSource
- 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 interfaceProductSource
-
-