Package gov.usgs.earthquake.product
Class AbstractContent
java.lang.Object
gov.usgs.earthquake.product.AbstractContent
- All Implemented Interfaces:
Content
- Direct Known Subclasses:
ByteContent,FileContent,InputStreamContent,URLContent
AbstractContent is a base class for other content classes and implements
common functionality.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor which requires no arguments.AbstractContent(Content content) Copy constructor from another content.AbstractContent(String contentType, Date lastModified, Long length) Null values are replaced with defaults. -
Method Summary
Modifier and TypeMethodDescriptionThe type of content.When the content was modified.How much content there is.Get the Sha256 hash.getSha256(boolean computeIfMissing) Get or generate the MD5 hash of content.voidsetContentType(String contentType) Set the content mime type.voidsetLastModified(Date lastModified) Set when this content was created.voidSet the content length.voidSet the sha256 hash of content.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.usgs.earthquake.product.Content
close, getInputStream
-
Constructor Details
-
AbstractContent
Null values are replaced with defaults.- Parameters:
contentType- defaults to "text/plain".lastModified- defaults to new Date().length- defaults to -1L.
-
AbstractContent
Copy constructor from another content.- Parameters:
content- the content to copy.
-
AbstractContent
public AbstractContent()Default Constructor which requires no arguments. Default values are used for all fields.
-
-
Method Details
-
getContentType
Description copied from interface:ContentThe type of content.- Specified by:
getContentTypein interfaceContent- Returns:
- the content mime type.
-
setContentType
Set the content mime type.- Parameters:
contentType- the content mime type.
-
getLastModified
Description copied from interface:ContentWhen the content was modified.- Specified by:
getLastModifiedin interfaceContent- Returns:
- the content creation date.
-
setLastModified
Set when this content was created.- Parameters:
lastModified- when this content was created.
-
getLength
Description copied from interface:ContentHow much content there is. -
setLength
Set the content length.- Parameters:
length- long to set
-
getSha256
Get the Sha256 hash. -
getSha256
Get or generate the MD5 hash of content.- Parameters:
computeIfMissing- Use getInputStream to generate hash if missing.- Returns:
- sha256 string
- Throws:
Exception- if error occurs
-
setSha256
Set the sha256 hash of content.- Parameters:
sha256- to set
-