Package gov.usgs.earthquake.product.io
Class BinaryProductHandler
java.lang.Object
gov.usgs.earthquake.product.io.BinaryProductHandler
- All Implemented Interfaces:
ProductHandler
Generator of binary format for product data.
Binary representation of data types:
- Integer
- 4-bytes
- Long
- 8-bytes
- Date
- Long (Date.getTime())
- byte[]
- Integer length, raw bytes
- String
- byte[] (String.getBytes(StandardCharsets.UTF_8))
- URL/URI
- String (URL.toString())
- Header, exactly 1
- "BEGINPRODUCT" (string)
- ProductId (String)
- Status (String)
- Properties, 0 to many:
- "PROPERTY" (String)
- name (String)
- value (String)
- Links, 0 to many:
- "LINK" (String)
- relation (String)
- href (URI)
- Contents, 0 to many:
- "CONTENT" (String)
- path (String)
- contentType (String)
- lastModified (Date)
- length (Long)
- raw bytes
- Signature Version, 0 or 1. Note, only sent when version !=
SIGNATURE_V1 for backward compatibility
- "SIGNATUREVERSION" (String)
- version (String)
- Signature, 0 or 1:
- "SIGNATURE" (String)
- signature (String)
- Footer, exactly 1:
- "ENDPRODUCT" (String)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
CONTENTstatic final String
End of SIGNATURE HISTORY liststatic final String
ENDPRODUCTstatic final String
HEADER - BEGINPRODUCTstatic final String
LINKstatic final String
PROPERTYstatic final String
SIGNATUREstatic final String
SIGNATURE HISTORYstatic final String
map entry for SIGNATURE HISTORY liststatic final String
SIGNATURE VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Free any resources associated with this source.void
onBeginProduct
(ProductId id, String status) A new product is being output.void
Product content.void
A product is finished being output.void
A product link.void
onProperty
(ProductId id, String name, String value) A product property value.void
onSignature
(ProductId id, String signature) Product signature.void
onSignatureHistory
(ProductId id, List<ProductSignature> signatureHistory) Product signature history.void
onSignatureVersion
(ProductId id, CryptoUtils.Version version) Product signature version.
-
Field Details
-
HEADER
HEADER - BEGINPRODUCT- See Also:
-
PROPERTY
PROPERTY- See Also:
-
LINK
LINK- See Also:
-
CONTENT
CONTENT- See Also:
-
SIGNATUREVERSION
SIGNATURE VERSION- See Also:
-
SIGNATURE
SIGNATURE- See Also:
-
SIGNATUREHISTORY
SIGNATURE HISTORY- See Also:
-
SIGNATUREHISTORYENTRY
map entry for SIGNATURE HISTORY list- See Also:
-
ENDSIGNATUREHISTORY
End of SIGNATURE HISTORY list- See Also:
-
FOOTER
ENDPRODUCT- See Also:
-
-
Constructor Details
-
BinaryProductHandler
Constructor. Sets up a new BinaryIO- Parameters:
out
- an OutputStream
-
-
Method Details
-
onBeginProduct
Description copied from interface:ProductHandler
A 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:
onBeginProduct
in interfaceProductHandler
- Parameters:
id
- which product.status
- the product's status.- Throws:
Exception
- if error occurs
-
onProperty
Description copied from interface:ProductHandler
A product property value. Products have zero or more properties.- Specified by:
onProperty
in interfaceProductHandler
- Parameters:
id
- which product.name
- the property name.value
- the property value.- Throws:
Exception
- if error occurs
-
onLink
Description copied from interface:ProductHandler
A product link. Products have zero or more links.- Specified by:
onLink
in interfaceProductHandler
- Parameters:
id
- which product.relation
- how the URI is related to this product.href
- the URI that is related to this product.- Throws:
Exception
- if error occurs
-
onContent
Description copied from interface:ProductHandler
Product content. Products have one or more Contents.- Specified by:
onContent
in interfaceProductHandler
- Parameters:
id
- which product.path
- path to content within product.content
- the product content.- Throws:
Exception
- if error occurs
-
onSignatureVersion
Description copied from interface:ProductHandler
Product signature version.- Specified by:
onSignatureVersion
in interfaceProductHandler
- Parameters:
id
- which product.version
- product version- Throws:
Exception
- if error occurs
-
onSignature
Description copied from interface:ProductHandler
Product signature. Producers may optionally sign products to confirm they were the producer.- Specified by:
onSignature
in interfaceProductHandler
- Parameters:
id
- which product.signature
- the product signature, which can be verified using the ProductSigner class.- Throws:
Exception
- if error occurs
-
onSignatureHistory
public void onSignatureHistory(ProductId id, List<ProductSignature> signatureHistory) throws Exception Description copied from interface:ProductHandler
Product signature history.- Specified by:
onSignatureHistory
in interfaceProductHandler
- Parameters:
id
- which product.signatureHistory
- signature history of product.- Throws:
Exception
- if error occurs
-
onEndProduct
Description copied from interface:ProductHandler
A 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:
onEndProduct
in interfaceProductHandler
- Parameters:
id
- which product.- Throws:
Exception
- if error occurs
-
close
public void close()Free any resources associated with this source.- Specified by:
close
in interfaceProductHandler
-