com.googlecode.fascinator.common.storage.impl
Class GenericPayload

java.lang.Object
  extended by com.googlecode.fascinator.common.storage.impl.GenericPayload
All Implemented Interfaces:
Payload

public class GenericPayload
extends java.lang.Object
implements Payload

Generic Payload implementation

Author:
Oliver Lucido

Constructor Summary
GenericPayload(Payload payload)
          Creates a copy of the specified payload
GenericPayload(java.lang.String id)
          Creates an empty payload
GenericPayload(java.lang.String id, java.io.File payloadFile)
          Creates an file based payload
GenericPayload(java.lang.String id, java.lang.String label, java.lang.String contentType)
          Creates a data payload with the specified identifier, label and content type, but no content stream
GenericPayload(java.lang.String id, java.lang.String label, java.lang.String contentType, PayloadType payloadType)
          Creates a data payload with the specified identifier, label, content type and payload type but no content stream
 
Method Summary
 void close()
          Close the input stream for this payload
 java.lang.String getContentType()
          Gets the content (MIME) type for this payload
 java.lang.String getId()
          Gets the identifier for this payload
 java.lang.String getLabel()
          Gets the descriptive label for this payload
 PayloadType getType()
          Gets the type of this payload
 boolean hasMetaChanged()
          Status of the metadata if it has changed
 boolean isLinked()
          Returns whether the file is linked or stored
 java.lang.Long lastModified()
          Return the timestamp when the payload was last modified
 java.io.InputStream open()
          Gets the input stream to access the content for this payload
 void setContentType(java.lang.String contentType)
          Sets the content (MIME) type for this payload
 void setId(java.lang.String id)
          Sets the identifier for this payload
 void setInputStream(java.io.InputStream in)
          Sets the input stream to access the content for this payload.
 void setLabel(java.lang.String label)
          Sets the descriptive label for this payload
 void setLinked(boolean newLinked)
          Set the link state
 void setMetaChanged(boolean metaChanged)
          Set the metadata changed flag to a specific value.
 void setType(PayloadType type)
          Sets the type of this payload
 java.lang.Long size()
          Return the size of the payload in byte
 java.lang.String toString()
          Gets the Payload identifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericPayload

public GenericPayload(java.lang.String id)
Creates an empty payload

Parameters:
id - an identifier

GenericPayload

public GenericPayload(java.lang.String id,
                      java.lang.String label,
                      java.lang.String contentType)
Creates a data payload with the specified identifier, label and content type, but no content stream

Parameters:
id - an identifier
label - a descriptive label
contentType - the content type

GenericPayload

public GenericPayload(java.lang.String id,
                      java.lang.String label,
                      java.lang.String contentType,
                      PayloadType payloadType)
Creates a data payload with the specified identifier, label, content type and payload type but no content stream

Parameters:
id - an identifier
label - a descriptive label
contentType - the content type
payloadType - the payload type

GenericPayload

public GenericPayload(java.lang.String id,
                      java.io.File payloadFile)
Creates an file based payload

Parameters:
id - an identifier
payloadFile - the file for the payload

GenericPayload

public GenericPayload(Payload payload)
Creates a copy of the specified payload

Parameters:
payload - payload to copy
Method Detail

hasMetaChanged

public boolean hasMetaChanged()
Status of the metadata if it has changed

Returns:
true if metadata has changed, false otherwise

setMetaChanged

public void setMetaChanged(boolean metaChanged)
Set the metadata changed flag to a specific value.

Parameters:
metaChanged -

getId

public java.lang.String getId()
Gets the identifier for this payload

Specified by:
getId in interface Payload
Returns:
an identifier

setId

public void setId(java.lang.String id)
Sets the identifier for this payload

Specified by:
setId in interface Payload
Parameters:
id - A string identifier for this payload

getType

public PayloadType getType()
Gets the type of this payload

Specified by:
getType in interface Payload
Returns:
payload type

isLinked

public boolean isLinked()
Returns whether the file is linked or stored

Specified by:
isLinked in interface Payload
Returns:
true if linked, false if stored

setLinked

public void setLinked(boolean newLinked)
Set the link state

Parameters:
newLinked - True if linked, otherwise false

setType

public void setType(PayloadType type)
Sets the type of this payload

Specified by:
setType in interface Payload
Parameters:
A - PayloadType

getLabel

public java.lang.String getLabel()
Gets the descriptive label for this payload

Specified by:
getLabel in interface Payload
Returns:
a label

setLabel

public void setLabel(java.lang.String label)
Sets the descriptive label for this payload

Specified by:
setLabel in interface Payload
Parameters:
a - String label for this payload

getContentType

public java.lang.String getContentType()
Gets the content (MIME) type for this payload

Specified by:
getContentType in interface Payload
Returns:
a MIME type

setContentType

public void setContentType(java.lang.String contentType)
Sets the content (MIME) type for this payload

Specified by:
setContentType in interface Payload
Parameters:
a - String MIME type

open

public java.io.InputStream open()
                         throws StorageException
Gets the input stream to access the content for this payload

Specified by:
open in interface Payload
Returns:
an input stream
Throws:
java.io.IOException - if there was an error reading the stream
StorageException

close

public void close()
           throws StorageException
Close the input stream for this payload

Specified by:
close in interface Payload
Throws:
StorageException - if there was an error closing the stream

setInputStream

public void setInputStream(java.io.InputStream in)
Sets the input stream to access the content for this payload. Note this stores the stream into memory, proper Payload implementations should override this method.

Parameters:
in - the content input stream

toString

public java.lang.String toString()
Gets the Payload identifier

Overrides:
toString in class java.lang.Object
Returns:
an identifier

lastModified

public java.lang.Long lastModified()
Return the timestamp when the payload was last modified

Specified by:
lastModified in interface Payload

size

public java.lang.Long size()
Return the size of the payload in byte

Specified by:
size in interface Payload


Copyright © 2009-2013. All Rights Reserved.