Package gov.usgs.earthquake.product.io
Class ObjectProductHandler
- java.lang.Object
-
- gov.usgs.earthquake.product.io.ObjectProductHandler
-
- All Implemented Interfaces:
ProductHandler
- Direct Known Subclasses:
DirectoryProductHandler,JsonProductHandler,ZipProductHandler
public class ObjectProductHandler extends java.lang.Object implements ProductHandler
Convert ProductSource events into a java Product object. ObjectProductHandlers are not designed to handle multiple products simultaneously and separate objects must be created for each unique product id. The static method ObjectProductHandler.getProduct(ProductInput) should usually be used instead of constructing objects manually.
-
-
Constructor Summary
Constructors Constructor Description ObjectProductHandler()Empty constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Free any resources associated with this handler.ProductgetProduct()static ProductgetProduct(ProductSource in)Convenience method to get a Product object from a ProductInput.voidonBeginProduct(ProductId id, java.lang.String status, java.net.URL trackerURL)A new product is being output.voidonContent(ProductId id, java.lang.String path, Content content)Product content.voidonEndProduct(ProductId id)A product is finished being output.voidonLink(ProductId id, java.lang.String relation, java.net.URI href)A product link.voidonProperty(ProductId id, java.lang.String name, java.lang.String value)A product property value.voidonSignature(ProductId id, java.lang.String signature)Product signature.voidonSignatureVersion(ProductId id, CryptoUtils.Version version)Product signature version.
-
-
-
Method Detail
-
getProduct
public Product getProduct() throws java.lang.Exception
- Returns:
- the product object that was created.
- Throws:
java.lang.Exception- if error occurs
-
onBeginProduct
public void onBeginProduct(ProductId id, java.lang.String status, java.net.URL trackerURL) throws java.lang.Exception
Description copied from interface:ProductHandlerA new product is being output. The ProductHandler should expect calls to other on-Methods until the onEndProduct method is called. No calls to other on-Methods will occur before onBeginProduct.- Specified by:
onBeginProductin interfaceProductHandler- Parameters:
id- which product.status- the product's status.trackerURL- a location to send status updates.- Throws:
java.lang.Exception- if error occurs
-
onContent
public void onContent(ProductId id, java.lang.String path, Content content) throws java.lang.Exception
Description copied from interface:ProductHandlerProduct content. Products have one or more Contents.- Specified by:
onContentin interfaceProductHandler- Parameters:
id- which product.path- path to content within product.content- the product content.- Throws:
java.lang.Exception- if error occurs
-
onEndProduct
public void onEndProduct(ProductId id) throws java.lang.Exception
Description copied from interface:ProductHandlerA product is finished being output. The ProductHandler should expect no more calls to other on-Methods, except perhaps onBeginProduct again, after the onEndProduct method is called.- Specified by:
onEndProductin interfaceProductHandler- Parameters:
id- which product.- Throws:
java.lang.Exception- if error occurs
-
onLink
public void onLink(ProductId id, java.lang.String relation, java.net.URI href) throws java.lang.Exception
Description copied from interface:ProductHandlerA product link. Products have zero or more links.- Specified by:
onLinkin interfaceProductHandler- Parameters:
id- which product.relation- how the URI is related to this product.href- the URI that is related to this product.- Throws:
java.lang.Exception- if error occurs
-
onProperty
public void onProperty(ProductId id, java.lang.String name, java.lang.String value) throws java.lang.Exception
Description copied from interface:ProductHandlerA product property value. Products have zero or more properties.- Specified by:
onPropertyin interfaceProductHandler- Parameters:
id- which product.name- the property name.value- the property value.- Throws:
java.lang.Exception- if error occurs
-
onSignatureVersion
public void onSignatureVersion(ProductId id, CryptoUtils.Version version) throws java.lang.Exception
Description copied from interface:ProductHandlerProduct signature version.- Specified by:
onSignatureVersionin interfaceProductHandler- Parameters:
id- which product.version- product version- Throws:
java.lang.Exception- if error occurs
-
onSignature
public void onSignature(ProductId id, java.lang.String signature) throws java.lang.Exception
Description copied from interface:ProductHandlerProduct signature. Producers may optionally sign products to confirm they were the producer.- Specified by:
onSignaturein interfaceProductHandler- Parameters:
id- which product.signature- the product signature, which can be verified using the ProductSigner class.- Throws:
java.lang.Exception- if error occurs
-
getProduct
public static Product getProduct(ProductSource in) throws java.lang.Exception
Convenience method to get a Product object from a ProductInput.- Parameters:
in- the ProductInput to read.- Returns:
- the Product read, or null if errors occur.
- Throws:
java.lang.Exception- if error occurs
-
close
public void close()
Free any resources associated with this handler.- Specified by:
closein interfaceProductHandler
-
-