Package gov.usgs.earthquake.product.io
Class XmlProductHandler
java.lang.Object
gov.usgs.earthquake.product.io.XmlProductHandler
- All Implemented Interfaces:
ProductHandler
Store a product to an OutputStream using XML.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringContent attribute for encodedstatic final StringUsed with URLContent.static final StringContent attribute for lengthstatic final StringContent attribute for modifiedstatic final StringContent attribute for pathstatic final StringContent attribute for typestatic final StringElement for contentstatic final StringLink attribute for hrefstatic final StringLink attribute for relationstatic final StringElement for linkstatic final StringProduct Attribute for idstatic final StringProduct Attribute for statusstatic final StringProduct Attribute for updateTimestatic final StringElement for productstatic final StringNamespace for XML productstatic final StringProperty attribute for namestatic final StringProperty attribute for valuestatic final StringElement for propertystatic final StringSignature attribute for versionstatic final StringElement for signaturestatic final StringElement for signature historystatic final StringElement for entries to the signature historystatic final StringSignature history attribute for signaturestatic final StringSignature history attribute for signature versionstatic final StringDeclaration for XML and version -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new XmlProductHandler object.XmlProductHandler(OutputStream out, boolean includeDeclaration) Create a new XmlProductHandler object. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Free any resources associated with this handler.voidonBeginProduct(ProductId id, String status) Output the product root element.voidOutput a content object as xml.voidOutput the closing product element.voidOutput a link element as xml.voidonProperty(ProductId id, String name, String value) Output the property element as xml.voidonSignature(ProductId id, String signature) Output the signature element as xml.voidonSignatureHistory(ProductId id, List<ProductSignature> signatureHistory) Product signature history.voidonSignatureVersion(ProductId id, CryptoUtils.Version version) Product signature version.
-
Field Details
-
XML_DECLARATION
Declaration for XML and version- See Also:
-
PRODUCT_XML_NAMESPACE
Namespace for XML product- See Also:
-
PRODUCT_ELEMENT
Element for product- See Also:
-
PRODUCT_ATTRIBUTE_ID
Product Attribute for id- See Also:
-
PRODUCT_ATTRIBUTE_UPDATED
Product Attribute for updateTime- See Also:
-
PRODUCT_ATTRIBUTE_STATUS
Product Attribute for status- See Also:
-
PROPERTY_ELEMENT
Element for property- See Also:
-
PROPERTY_ATTRIBUTE_NAME
Property attribute for name- See Also:
-
PROPERTY_ATTRIBUTE_VALUE
Property attribute for value- See Also:
-
LINK_ELEMENT
Element for link- See Also:
-
LINK_ATTRIBUTE_RELATION
Link attribute for relation- See Also:
-
LINK_ATTRIBUTE_HREF
Link attribute for href- See Also:
-
CONTENT_ELEMENT
Element for content- See Also:
-
CONTENT_ATTRIBUTE_PATH
Content attribute for path- See Also:
-
CONTENT_ATTRIBUTE_TYPE
Content attribute for type- See Also:
-
CONTENT_ATTRIBUTE_LENGTH
Content attribute for length- See Also:
-
CONTENT_ATTRIBUTE_MODIFIED
Content attribute for modified- See Also:
-
CONTENT_ATTRIBUTE_HREF
Used with URLContent.- See Also:
-
CONTENT_ATTRIBUTE_ENCODED
Content attribute for encoded- See Also:
-
SIGNATURE_ELEMENT
Element for signature- See Also:
-
SIGNATURE_ATTRIBUTE_VERSION
Signature attribute for version- See Also:
-
SIGNATURE_HISTORY_ELEMENT
Element for signature history- See Also:
-
SIGNATURE_HISTORY_ENTRY_ELEMENT
Element for entries to the signature history- See Also:
-
SIGNATURE_HISTORY_SIGNATURE_ATTRIBUTE_
Signature history attribute for signature- See Also:
-
SIGNATURE_HISTORY_VERSION_ATTRIBUTE_
Signature history attribute for signature version- See Also:
-
-
Constructor Details
-
XmlProductHandler
Create a new XmlProductHandler object.- Parameters:
out- the OutputStream where xml will be written.
-
XmlProductHandler
Create a new XmlProductHandler object.- Parameters:
out- the OutputStream where xml will be written.includeDeclaration- whether to include the XML declaration with output
-
-
Method Details
-
onBeginProduct
Output the product root element.- Specified by:
onBeginProductin interfaceProductHandler- Parameters:
id- which product.status- the product's status.- Throws:
Exception- if error occurs
-
onContent
Output a content object as xml.- Specified by:
onContentin interfaceProductHandler- Parameters:
id- which product.path- path to content within product.content- the product content.- Throws:
Exception- if error occurs
-
onEndProduct
Output the closing product element.- Specified by:
onEndProductin interfaceProductHandler- Parameters:
id- which product.- Throws:
Exception- if error occurs
-
onLink
Output a link element as xml.- 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:
Exception- if error occurs
-
onProperty
Output the property element as xml.- Specified by:
onPropertyin interfaceProductHandler- Parameters:
id- which product.name- the property name.value- the property value.- Throws:
Exception- if error occurs
-
onSignatureVersion
Description copied from interface:ProductHandlerProduct signature version.- Specified by:
onSignatureVersionin interfaceProductHandler- Parameters:
id- which product.version- product version- Throws:
Exception- if error occurs
-
onSignature
Output the signature element as xml.- Specified by:
onSignaturein 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:ProductHandlerProduct signature history.- Specified by:
onSignatureHistoryin interfaceProductHandler- Parameters:
id- which product.signatureHistory- signature history of product.- Throws:
Exception- if error occurs
-
close
public void close()Free any resources associated with this handler.- Specified by:
closein interfaceProductHandler
-