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.StringCONTENT_ATTRIBUTE_ENCODEDContent attribute for encodedstatic java.lang.StringCONTENT_ATTRIBUTE_HREFUsed with URLContent.static java.lang.StringCONTENT_ATTRIBUTE_LENGTHContent attribute for lengthstatic java.lang.StringCONTENT_ATTRIBUTE_MODIFIEDContent attribute for modifiedstatic java.lang.StringCONTENT_ATTRIBUTE_PATHContent attribute for pathstatic java.lang.StringCONTENT_ATTRIBUTE_TYPEContent attribute for typestatic java.lang.StringCONTENT_ELEMENTElement for contentstatic java.lang.StringLINK_ATTRIBUTE_HREFLink attribute for hrefstatic java.lang.StringLINK_ATTRIBUTE_RELATIONLink attribute for relationstatic java.lang.StringLINK_ELEMENTElement for linkstatic java.lang.StringPRODUCT_ATTRIBUTE_IDProduct Attribute for idstatic java.lang.StringPRODUCT_ATTRIBUTE_STATUSProduct Attribute for statusstatic java.lang.StringPRODUCT_ATTRIBUTE_TRACKER_URLProduct Attribute for trackerURLstatic java.lang.StringPRODUCT_ATTRIBUTE_UPDATEDProduct Attribute for updateTimestatic java.lang.StringPRODUCT_ELEMENTElement for productstatic java.lang.StringPRODUCT_XML_NAMESPACENamespace for XML productstatic java.lang.StringPROPERTY_ATTRIBUTE_NAMEProperty attribute for namestatic java.lang.StringPROPERTY_ATTRIBUTE_VALUEProperty attribute for valuestatic java.lang.StringPROPERTY_ELEMENTElement for propertystatic java.lang.StringSIGNATURE_ATTRIBUTE_VERSIONSignature attribute for versionstatic java.lang.StringSIGNATURE_ELEMENTElement for signaturestatic java.lang.StringXML_DECLARATIONDeclaration 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 voidclose()Free any resources associated with this handler.voidonBeginProduct(ProductId id, java.lang.String status, java.net.URL trackerURL)Output the product root element.voidonContent(ProductId id, java.lang.String path, Content content)Output a content object as xml.voidonEndProduct(ProductId id)Output the closing product element.voidonLink(ProductId id, java.lang.String relation, java.net.URI href)Output a link element as xml.voidonProperty(ProductId id, java.lang.String name, java.lang.String value)Output the property element as xml.voidonSignature(ProductId id, java.lang.String signature)Output the signature element as xml.voidonSignatureVersion(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:
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
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:
java.lang.Exception- if error occurs
-
onEndProduct
public void onEndProduct(ProductId id) throws java.lang.Exception
Output the closing product element.- 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
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:
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:
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
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:
java.lang.Exception- if error occurs
-
close
public void close()
Free any resources associated with this handler.- Specified by:
closein interfaceProductHandler
-
-