Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum
Interface Attachment

All Known Implementing Classes:
AttachmentProxy, DbAttachment

public interface Attachment

An object that encapsulates a message attachment. Each attachment has a unique ID and is made up of three parts: binary data (read and written using an InputStream), a name, and content type. An image attachment might have a name "stockchart.gif" and corresponding content type of "image/gif". A full listing of possible content types can be found at: ftp://ftp.iana.org/in-notes/iana/assignments/media-types/ The storage mechanism of attachments is unspecified, although the default implementation puts attachments on the filesystem.


Method Summary
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 java.lang.String getContentType()
          Returns the content type of the attachment.
 java.util.Date getCreationDate()
          Returns the date the attachment was created.
 java.io.InputStream getData()
          Returns a InputStream for the binary contents of the attachment.
 long getID()
          Returns the unique ID of the attachment.
 java.util.Date getModificationDate()
          Returns the date the attachment was last modified.
 java.lang.String getName()
          Returns the name of the attachment.
 java.util.Collection getProperties(java.lang.String parentName)
          Return all immediate children property values of a parent property as an unmodifiable Collection of String values.
 java.lang.String getProperty(java.lang.String name)
          Returns an extended property of the attachment.
 java.util.Iterator getPropertyNames()
          Returns an Iterator for the names of the extended properties.
 long getSize()
          Returns the size of the attachment in bytes.
 void setName(java.lang.String name)
          Sets the name of the attachment.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of the attachment.
 

Method Detail

getID

long getID()
Returns the unique ID of the attachment.

Returns:
the attachment ID.

getContentType

java.lang.String getContentType()
Returns the content type of the attachment. For example, the content type of an image attachment might be "image/gif" or "image/jpeg".

Returns:
the attachment content type.

getName

java.lang.String getName()
Returns the name of the attachment. Most often, the attachment name is the original name of the file that created the attachment, such as "report.doc"

Returns:
the name of the attachment.

setName

void setName(java.lang.String name)
             throws UnauthorizedException
Sets the name of the attachment. Most often, the attachment name is the original name of the file that created the attachment, such as "report.doc"

Parameters:
name - the new name of the attachment.
Throws:
UnauthorizedException - if not allowed to modify the attachment
Since:
4.0

getSize

long getSize()
Returns the size of the attachment in bytes.

Returns:
the size of the attachment.

getData

java.io.InputStream getData()
                            throws java.io.IOException
Returns a InputStream for the binary contents of the attachment. The stream should be closed after reading the attachment is completed. The InputStream will already be buffered, so there is no advantage to using additional buffering.

Returns:
the binary contents of the attachment.
Throws:
java.io.IOException - if an error occurs reading the attachment from storage.

getCreationDate

java.util.Date getCreationDate()
Returns the date the attachment was created.

Returns:
the date the attachment was created.

getModificationDate

java.util.Date getModificationDate()
Returns the date the attachment was last modified.

Returns:
the date the attachment was last modified.

getProperty

java.lang.String getProperty(java.lang.String name)
Returns an extended property of the attachment. Each attachment can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface.

Parameters:
name - the name of the property to get.
Returns:
the value of the property specified by name.

getProperties

java.util.Collection getProperties(java.lang.String parentName)
Return all immediate children property values of a parent property as an unmodifiable Collection of String values. A parent/child relationship is denoted by the "." character. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C (the value of X.Y.C.D would not be returned using this method).

Parameters:
parentName - the name of the parent property to return the children for.
Returns:
all Collection of all child property values for the given parent.

setProperty

void setProperty(java.lang.String name,
                 java.lang.String value)
                 throws UnauthorizedException
Sets an extended property of the attachment. Each attachment can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface.

If the property referenced by name already exists, its value will be updated.

Parameters:
name - the name of the property to set.
value - the new value for the property.
Throws:
UnauthorizedException - if does not have admin permissions.

deleteProperty

void deleteProperty(java.lang.String name)
                    throws UnauthorizedException
Deletes an extended property. If the property specified by name does not exist, this method will do nothing.

Parameters:
name - the name of the property to delete.
Throws:
UnauthorizedException - if does not have ADMIN permissions.

getPropertyNames

java.util.Iterator getPropertyNames()
Returns an Iterator for the names of the extended properties.

Returns:
an Iterator for the names of the extended properties.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.