Package gov.usgs.earthquake.product.io
Class XmlProductHandler
- java.lang.Object
-
- gov.usgs.earthquake.product.io.XmlProductHandler
-
- All Implemented Interfaces:
ProductHandler
public class XmlProductHandler extends java.lang.Object implements ProductHandler
Store a product to an OutputStream using XML.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENT_ATTRIBUTE_ENCODED
Content attribute for encodedstatic java.lang.String
CONTENT_ATTRIBUTE_HREF
Used with URLContent.static java.lang.String
CONTENT_ATTRIBUTE_LENGTH
Content attribute for lengthstatic java.lang.String
CONTENT_ATTRIBUTE_MODIFIED
Content attribute for modifiedstatic java.lang.String
CONTENT_ATTRIBUTE_PATH
Content attribute for pathstatic java.lang.String
CONTENT_ATTRIBUTE_TYPE
Content attribute for typestatic java.lang.String
CONTENT_ELEMENT
Element for contentstatic java.lang.String
LINK_ATTRIBUTE_HREF
Link attribute for hrefstatic java.lang.String
LINK_ATTRIBUTE_RELATION
Link attribute for relationstatic java.lang.String
LINK_ELEMENT
Element for linkstatic java.lang.String
PRODUCT_ATTRIBUTE_ID
Product Attribute for idstatic java.lang.String
PRODUCT_ATTRIBUTE_STATUS
Product Attribute for statusstatic java.lang.String
PRODUCT_ATTRIBUTE_TRACKER_URL
Product Attribute for trackerURLstatic java.lang.String
PRODUCT_ATTRIBUTE_UPDATED
Product Attribute for updateTimestatic java.lang.String
PRODUCT_ELEMENT
Element for productstatic java.lang.String
PRODUCT_XML_NAMESPACE
Namespace for XML productstatic java.lang.String
PROPERTY_ATTRIBUTE_NAME
Property attribute for namestatic java.lang.String
PROPERTY_ATTRIBUTE_VALUE
Property attribute for valuestatic java.lang.String
PROPERTY_ELEMENT
Element for propertystatic java.lang.String
SIGNATURE_ATTRIBUTE_VERSION
Signature attribute for versionstatic java.lang.String
SIGNATURE_ELEMENT
Element for signaturestatic java.lang.String
XML_DECLARATION
Declaration for XML and version
-
Constructor Summary
Constructors Constructor Description XmlProductHandler(java.io.OutputStream out)
Create a new XmlProductHandler object.XmlProductHandler(java.io.OutputStream out, boolean includeDeclaration)
Create a new XmlProductHandler object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free any resources associated with this handler.void
onBeginProduct(ProductId id, java.lang.String status, java.net.URL trackerURL)
Output the product root element.void
onContent(ProductId id, java.lang.String path, Content content)
Output a content object as xml.void
onEndProduct(ProductId id)
Output the closing product element.void
onLink(ProductId id, java.lang.String relation, java.net.URI href)
Output a link element as xml.void
onProperty(ProductId id, java.lang.String name, java.lang.String value)
Output the property element as xml.void
onSignature(ProductId id, java.lang.String signature)
Output the signature element as xml.void
onSignatureVersion(ProductId id, CryptoUtils.Version version)
Product signature version.
-
-
-
Field Detail
-
XML_DECLARATION
public static final java.lang.String XML_DECLARATION
Declaration for XML and version- See Also:
- Constant Field Values
-
PRODUCT_XML_NAMESPACE
public static final java.lang.String PRODUCT_XML_NAMESPACE
Namespace for XML product- See Also:
- Constant Field Values
-
PRODUCT_ELEMENT
public static final java.lang.String PRODUCT_ELEMENT
Element for product- See Also:
- Constant Field Values
-
PRODUCT_ATTRIBUTE_ID
public static final java.lang.String PRODUCT_ATTRIBUTE_ID
Product Attribute for id- See Also:
- Constant Field Values
-
PRODUCT_ATTRIBUTE_UPDATED
public static final java.lang.String PRODUCT_ATTRIBUTE_UPDATED
Product Attribute for updateTime- See Also:
- Constant Field Values
-
PRODUCT_ATTRIBUTE_STATUS
public static final java.lang.String PRODUCT_ATTRIBUTE_STATUS
Product Attribute for status- See Also:
- Constant Field Values
-
PRODUCT_ATTRIBUTE_TRACKER_URL
public static final java.lang.String PRODUCT_ATTRIBUTE_TRACKER_URL
Product Attribute for trackerURL- See Also:
- Constant Field Values
-
PROPERTY_ELEMENT
public static final java.lang.String PROPERTY_ELEMENT
Element for property- See Also:
- Constant Field Values
-
PROPERTY_ATTRIBUTE_NAME
public static final java.lang.String PROPERTY_ATTRIBUTE_NAME
Property attribute for name- See Also:
- Constant Field Values
-
PROPERTY_ATTRIBUTE_VALUE
public static final java.lang.String PROPERTY_ATTRIBUTE_VALUE
Property attribute for value- See Also:
- Constant Field Values
-
LINK_ELEMENT
public static final java.lang.String LINK_ELEMENT
Element for link- See Also:
- Constant Field Values
-
LINK_ATTRIBUTE_RELATION
public static final java.lang.String LINK_ATTRIBUTE_RELATION
Link attribute for relation- See Also:
- Constant Field Values
-
LINK_ATTRIBUTE_HREF
public static final java.lang.String LINK_ATTRIBUTE_HREF
Link attribute for href- See Also:
- Constant Field Values
-
CONTENT_ELEMENT
public static final java.lang.String CONTENT_ELEMENT
Element for content- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_PATH
public static final java.lang.String CONTENT_ATTRIBUTE_PATH
Content attribute for path- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_TYPE
public static final java.lang.String CONTENT_ATTRIBUTE_TYPE
Content attribute for type- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_LENGTH
public static final java.lang.String CONTENT_ATTRIBUTE_LENGTH
Content attribute for length- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_MODIFIED
public static final java.lang.String CONTENT_ATTRIBUTE_MODIFIED
Content attribute for modified- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_HREF
public static final java.lang.String CONTENT_ATTRIBUTE_HREF
Used with URLContent.- See Also:
- Constant Field Values
-
CONTENT_ATTRIBUTE_ENCODED
public static final java.lang.String CONTENT_ATTRIBUTE_ENCODED
Content attribute for encoded- See Also:
- Constant Field Values
-
SIGNATURE_ELEMENT
public static final java.lang.String SIGNATURE_ELEMENT
Element for signature- See Also:
- Constant Field Values
-
SIGNATURE_ATTRIBUTE_VERSION
public static final java.lang.String SIGNATURE_ATTRIBUTE_VERSION
Signature attribute for version- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XmlProductHandler
public XmlProductHandler(java.io.OutputStream out)
Create a new XmlProductHandler object.- Parameters:
out
- the OutputStream where xml will be written.
-
XmlProductHandler
public XmlProductHandler(java.io.OutputStream out, boolean includeDeclaration)
Create a new XmlProductHandler object.- Parameters:
out
- the OutputStream where xml will be written.includeDeclaration
- whether to include the XML declaration with output
-
-
Method Detail
-
onBeginProduct
public void onBeginProduct(ProductId id, java.lang.String status, java.net.URL trackerURL) throws java.lang.Exception
Output the product root element.- Specified by:
onBeginProduct
in 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
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:
java.lang.Exception
- if error occurs
-
onEndProduct
public void onEndProduct(ProductId id) throws java.lang.Exception
Output the closing product element.- Specified by:
onEndProduct
in 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
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:
java.lang.Exception
- if error occurs
-
onProperty
public void onProperty(ProductId id, java.lang.String name, java.lang.String value) throws java.lang.Exception
Output the property element as xml.- Specified by:
onProperty
in 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:ProductHandler
Product signature version.- Specified by:
onSignatureVersion
in 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
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:
java.lang.Exception
- if error occurs
-
close
public void close()
Free any resources associated with this handler.- Specified by:
close
in interfaceProductHandler
-
-