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 String
Content attribute for encodedstatic final String
Used with URLContent.static final String
Content attribute for lengthstatic final String
Content attribute for modifiedstatic final String
Content attribute for pathstatic final String
Content attribute for typestatic final String
Element for contentstatic final String
Link attribute for hrefstatic final String
Link attribute for relationstatic final String
Element for linkstatic final String
Product Attribute for idstatic final String
Product Attribute for statusstatic final String
Product Attribute for updateTimestatic final String
Element for productstatic final String
Namespace for XML productstatic final String
Property attribute for namestatic final String
Property attribute for valuestatic final String
Element for propertystatic final String
Signature attribute for versionstatic final String
Element for signaturestatic final String
Element for signature historystatic final String
Element for entries to the signature historystatic final String
Signature history attribute for signaturestatic final String
Signature history attribute for signature versionstatic final String
Declaration 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 TypeMethodDescriptionvoid
close()
Free any resources associated with this handler.void
onBeginProduct
(ProductId id, String status) Output the product root element.void
Output a content object as xml.void
Output the closing product element.void
Output a link element as xml.void
onProperty
(ProductId id, String name, String value) Output the property element as xml.void
onSignature
(ProductId id, String signature) Output the signature element as xml.void
onSignatureHistory
(ProductId id, List<ProductSignature> signatureHistory) Product signature history.void
onSignatureVersion
(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:
onBeginProduct
in interfaceProductHandler
- Parameters:
id
- which product.status
- the product's status.- Throws:
Exception
- if error occurs
-
onContent
Output a content object as xml.- Specified by:
onContent
in 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:
onEndProduct
in interfaceProductHandler
- Parameters:
id
- which product.- Throws:
Exception
- if error occurs
-
onLink
Output a link element as xml.- 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
-
onProperty
Output the property element as xml.- Specified by:
onProperty
in interfaceProductHandler
- Parameters:
id
- which product.name
- the property name.value
- the property value.- 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
Output the signature element as xml.- 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
-
close
public void close()Free any resources associated with this handler.- Specified by:
close
in interfaceProductHandler
-