Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.database
Class DbAttachment

java.lang.Object
  extended by com.jivesoftware.forum.database.DbAttachment
All Implemented Interfaces:
Attachment, Cacheable, com.tangosol.io.ExternalizableLite, java.io.Serializable

public class DbAttachment
extends java.lang.Object
implements Attachment, Cacheable, com.tangosol.io.ExternalizableLite

Database implementation of the Attachment interface. Attachment data can be stored in one of two ways:

  1. On the file system (default).
  2. In the database using BLOBS. In this mode, attachments are cached on the file system for improved performance.

See Also:
Serialized Form

Field Summary
protected static java.lang.String INSERT_ATTACHMENT_DATA
           
protected static java.lang.String INSERT_ATTACHMENT_DATA_ORACLE
           
 
Constructor Summary
DbAttachment()
          Constructor for internal use only.
DbAttachment(int objectType, long objectID, java.lang.String name, java.lang.String contentType, java.io.InputStream data)
           
DbAttachment(long attachmentID)
          Loads an existing Attachment object.
DbAttachment(long attachmentID, java.sql.Connection con)
          Loads an existing Attachment object.
 
Method Summary
protected  void delete(java.sql.Connection con)
          Deletes the attachment.
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 int getCachedSize()
          Returns the approximate size of the Object in bytes.
 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.
 long getObjectID()
          Returns the objectID associated with this attachment, or -1 if not associated with a specific object.
 int getObjectType()
          Returns the object type associated with this 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 readExternal(java.io.DataInput in)
           
 void setName(java.lang.String name)
          Sets the name of the attachment.
static void setObjectID(long attachmentID, long objectID, java.sql.Connection con)
          Sets the objectID associated with an attachmentID.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of the attachment.
 void writeExternal(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSERT_ATTACHMENT_DATA

protected static final java.lang.String INSERT_ATTACHMENT_DATA
See Also:
Constant Field Values

INSERT_ATTACHMENT_DATA_ORACLE

protected static final java.lang.String INSERT_ATTACHMENT_DATA_ORACLE
See Also:
Constant Field Values
Constructor Detail

DbAttachment

public DbAttachment(long attachmentID)
             throws AttachmentNotFoundException
Loads an existing Attachment object.

Parameters:
attachmentID - the ID of the attachment to load.
Throws:
AttachmentNotFoundException - if loading the specified attachment fails.

DbAttachment

public DbAttachment(long attachmentID,
                    java.sql.Connection con)
             throws AttachmentNotFoundException
Loads an existing Attachment object.

Parameters:
attachmentID - the ID of the attachment to load.
con - the database connection to use to load the attachment
Throws:
AttachmentNotFoundException - if loading the specified attachment fails.

DbAttachment

public DbAttachment(int objectType,
                    long objectID,
                    java.lang.String name,
                    java.lang.String contentType,
                    java.io.InputStream data)
             throws AttachmentException
Throws:
AttachmentException

DbAttachment

public DbAttachment()
Constructor for internal use only.

Method Detail

getID

public long getID()
Description copied from interface: Attachment
Returns the unique ID of the attachment.

Specified by:
getID in interface Attachment
Returns:
the attachment ID.

getName

public java.lang.String getName()
Description copied from interface: Attachment
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"

Specified by:
getName in interface Attachment
Returns:
the name of the attachment.

setName

public void setName(java.lang.String name)
             throws UnauthorizedException
Description copied from interface: Attachment
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"

Specified by:
setName in interface Attachment
Parameters:
name - the new name of the attachment.
Throws:
UnauthorizedException - if not allowed to modify the attachment

getSize

public long getSize()
Description copied from interface: Attachment
Returns the size of the attachment in bytes.

Specified by:
getSize in interface Attachment
Returns:
the size of the attachment.

getContentType

public java.lang.String getContentType()
Description copied from interface: Attachment
Returns the content type of the attachment. For example, the content type of an image attachment might be "image/gif" or "image/jpeg".

Specified by:
getContentType in interface Attachment
Returns:
the attachment content type.

getCreationDate

public java.util.Date getCreationDate()
Description copied from interface: Attachment
Returns the date the attachment was created.

Specified by:
getCreationDate in interface Attachment
Returns:
the date the attachment was created.

getModificationDate

public java.util.Date getModificationDate()
Description copied from interface: Attachment
Returns the date the attachment was last modified.

Specified by:
getModificationDate in interface Attachment
Returns:
the date the attachment was last modified.

getData

public java.io.InputStream getData()
                            throws java.io.IOException
Description copied from interface: Attachment
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.

Specified by:
getData in interface Attachment
Returns:
the binary contents of the attachment.
Throws:
java.io.IOException - if an error occurs reading the attachment from storage.

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: Attachment
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.

Specified by:
getProperty in interface Attachment
Parameters:
name - the name of the property to get.
Returns:
the value of the property specified by name.

getProperties

public java.util.Collection getProperties(java.lang.String parentName)
Description copied from interface: Attachment
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).

Specified by:
getProperties in interface Attachment
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

public void setProperty(java.lang.String name,
                        java.lang.String value)
Description copied from interface: Attachment
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.

Specified by:
setProperty in interface Attachment
Parameters:
name - the name of the property to set.
value - the new value for the property.

deleteProperty

public void deleteProperty(java.lang.String name)
Description copied from interface: Attachment
Deletes an extended property. If the property specified by name does not exist, this method will do nothing.

Specified by:
deleteProperty in interface Attachment
Parameters:
name - the name of the property to delete.

getPropertyNames

public java.util.Iterator getPropertyNames()
Description copied from interface: Attachment
Returns an Iterator for the names of the extended properties.

Specified by:
getPropertyNames in interface Attachment
Returns:
an Iterator for the names of the extended properties.

getCachedSize

public int getCachedSize()
Description copied from interface: Cacheable
Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

Specified by:
getCachedSize in interface Cacheable
Returns:
the size of the Object in bytes.

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Specified by:
readExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

getObjectType

public int getObjectType()
Returns the object type associated with this attachment.

Returns:
the objectType the type of the object the attachment belongs to.

getObjectID

public long getObjectID()
Returns the objectID associated with this attachment, or -1 if not associated with a specific object.

Returns:
the objectID the id of the object the attachment belongs to.

setObjectID

public static void setObjectID(long attachmentID,
                               long objectID,
                               java.sql.Connection con)
                        throws java.sql.SQLException
Sets the objectID associated with an attachmentID.

Parameters:
attachmentID - the attachmentID.
objectID - the object ID.
con - the database connection.
Throws:
java.sql.SQLException

delete

protected void delete(java.sql.Connection con)
               throws java.sql.SQLException
Deletes the attachment.

Throws:
java.sql.SQLException

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.