SMILA 1.0 API documentation

org.eclipse.smila.datamodel
Class StoredAttachment

java.lang.Object
  extended by org.eclipse.smila.datamodel.StoredAttachment
All Implemented Interfaces:
java.io.Serializable, Attachment

public class StoredAttachment
extends java.lang.Object
implements Attachment, java.io.Serializable

Placeholder for an attachment where the content is stored in some storage service instead of in-memory. All methods of this class that access the attachment content just throw an AttachmentException.

TODO: Add subclasses that are able to deliver the attachment content from the respective storage.

See Also:
Serialized Form

Field Summary
static long SIZE_UNKNOWN
          result of size() if size is not known.
 
Constructor Summary
StoredAttachment(java.lang.String name)
          create instance with unknown size.
StoredAttachment(java.lang.String name, long size)
          create instance.
 
Method Summary
 void dispose()
          called to denote that this attachment is not needed anymore and used resources can be released.
 byte[] getAsBytes()
          get attachment content as a byte array.
 byte[] getAsBytes(int length)
          get start of attachment content as byte[].
 java.io.InputStream getAsStream()
          get attachment content for streaming.
 java.lang.String getName()
           
 long size()
          get size of attachments.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE_UNKNOWN

public static final long SIZE_UNKNOWN
result of size() if size is not known.

See Also:
Constant Field Values
Constructor Detail

StoredAttachment

public StoredAttachment(java.lang.String name)
create instance with unknown size.


StoredAttachment

public StoredAttachment(java.lang.String name,
                        long size)
create instance.

Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface Attachment
Returns:
name of attachment.

size

public long size()
Description copied from interface: Attachment
get size of attachments. Result can be negative is the implementation does not know the size.

Specified by:
size in interface Attachment
Returns:
number of bytes in attachment.

getAsBytes

public byte[] getAsBytes()
Description copied from interface: Attachment
get attachment content as a byte array.

Specified by:
getAsBytes in interface Attachment
Returns:
attachment content as a byte[]

getAsBytes

public byte[] getAsBytes(int length)
Description copied from interface: Attachment
get start of attachment content as byte[].

Specified by:
getAsBytes in interface Attachment
Returns:
first length bytes of attachment content.

getAsStream

public java.io.InputStream getAsStream()
Description copied from interface: Attachment
get attachment content for streaming.

Specified by:
getAsStream in interface Attachment
Returns:
a stream for reading the attachment.

dispose

public void dispose()
Description copied from interface: Attachment
called to denote that this attachment is not needed anymore and used resources can be released.

Specified by:
dispose in interface Attachment

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

SMILA 1.0 API documentation