org.dspace.content
Class Bitstream

java.lang.Object
  extended by org.dspace.content.DSpaceObject
      extended by org.dspace.content.Bitstream

public class Bitstream
extends DSpaceObject

Class representing bitstreams stored in the DSpace system.

When modifying the bitstream metadata, changes are not reflected in the database until update is called. Note that you cannot alter the contents of a bitstream; you need to create a new bitstream.

Version:
$Revision: 4657 $
Author:
Robert Tansley

Method Summary
static Bitstream find(Context context, int id)
          Get a bitstream from the database.
static Bitstream[] findAll(Context context)
           
 Bundle[] getBundles()
          Get the bundles this bitstream appears in
 String getChecksum()
          Get the checksum of the content of the bitstream, for integrity checking
 String getChecksumAlgorithm()
          Get the algorithm used to calculate the checksum
 String getDescription()
          Get the description of this bitstream - optional free text, typically provided by a user at submission time
 BitstreamFormat getFormat()
          Get the format of the bitstream
 String getFormatDescription()
          Get the description of the format - either the user's or the description of the format defined by the system.
 String getHandle()
          Get the Handle of the object.
 int getID()
          Get the internal identifier of this bitstream
 String getName()
          Get the name of this bitstream - typically the filename, without any path information
 DSpaceObject getParentObject()
          Return the dspace object that "own" the current object in the hierarchy.
 int getSequenceID()
          Get the sequence ID of this bitstream
 long getSize()
          Get the size of the bitstream
 String getSource()
          Get the source of this bitstream - typically the filename with path information (if originally provided) or the name of the tool that generated this bitstream
 int getStoreNumber()
          Get the asset store number where this bitstream is stored
 int getType()
          return type found in Constants
 String getUserFormatDescription()
          Get the user's format description.
 boolean isRegisteredBitstream()
          Determine if this bitstream is registered
 InputStream retrieve()
          Retrieve the contents of the bitstream
 void setDescription(String n)
          Set the description of the bitstream
 void setFormat(BitstreamFormat f)
          Set the format of the bitstream.
 void setName(String n)
          Set the name of the bitstream
 void setSequenceID(int sid)
          Set the sequence ID of this bitstream
 void setSource(String n)
          Set the source of the bitstream
 void setUserFormatDescription(String desc)
          Set the user's format description.
 void update()
          Update the bitstream metadata.
 
Methods inherited from class org.dspace.content.DSpaceObject
addDetails, clearDetails, find, getAdminObject, getDetails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

find

public static Bitstream find(Context context,
                             int id)
                      throws SQLException
Get a bitstream from the database. The bitstream metadata is loaded into memory.

Parameters:
context - DSpace context object
id - ID of the bitstream
Returns:
the bitstream, or null if the ID is invalid.
Throws:
SQLException

findAll

public static Bitstream[] findAll(Context context)
                           throws SQLException
Throws:
SQLException

getID

public int getID()
Get the internal identifier of this bitstream

Specified by:
getID in class DSpaceObject
Returns:
the internal identifier

getHandle

public String getHandle()
Description copied from class: DSpaceObject
Get the Handle of the object. This may return null

Specified by:
getHandle in class DSpaceObject
Returns:
Handle of the object, or null if it doesn't have one

getSequenceID

public int getSequenceID()
Get the sequence ID of this bitstream

Returns:
the sequence ID

setSequenceID

public void setSequenceID(int sid)
Set the sequence ID of this bitstream

Parameters:
sid - the ID

getName

public String getName()
Get the name of this bitstream - typically the filename, without any path information

Specified by:
getName in class DSpaceObject
Returns:
the name of the bitstream

setName

public void setName(String n)
Set the name of the bitstream

Parameters:
n - the new name of the bitstream

getSource

public String getSource()
Get the source of this bitstream - typically the filename with path information (if originally provided) or the name of the tool that generated this bitstream

Returns:
the source of the bitstream

setSource

public void setSource(String n)
Set the source of the bitstream

Parameters:
n - the new source of the bitstream

getDescription

public String getDescription()
Get the description of this bitstream - optional free text, typically provided by a user at submission time

Returns:
the description of the bitstream

setDescription

public void setDescription(String n)
Set the description of the bitstream

Parameters:
n - the new description of the bitstream

getChecksum

public String getChecksum()
Get the checksum of the content of the bitstream, for integrity checking

Returns:
the checksum

getChecksumAlgorithm

public String getChecksumAlgorithm()
Get the algorithm used to calculate the checksum

Returns:
the algorithm, e.g. "MD5"

getSize

public long getSize()
Get the size of the bitstream

Returns:
the size in bytes

setUserFormatDescription

public void setUserFormatDescription(String desc)
                              throws SQLException
Set the user's format description. This implies that the format of the bitstream is uncertain, and the format is set to "unknown."

Parameters:
desc - the user's description of the format
Throws:
SQLException

getUserFormatDescription

public String getUserFormatDescription()
Get the user's format description. Returns null if the format is known by the system.

Returns:
the user's format description.

getFormatDescription

public String getFormatDescription()
Get the description of the format - either the user's or the description of the format defined by the system.

Returns:
a description of the format.

getFormat

public BitstreamFormat getFormat()
Get the format of the bitstream

Returns:
the format of this bitstream

setFormat

public void setFormat(BitstreamFormat f)
               throws SQLException
Set the format of the bitstream. If the user has supplied a type description, it is cleared. Passing in null sets the type of this bitstream to "unknown".

Parameters:
f - the format of this bitstream, or null for unknown
Throws:
SQLException

update

public void update()
            throws SQLException,
                   AuthorizeException
Update the bitstream metadata. Note that the content of the bitstream cannot be changed - for that you need to create a new bitstream.

Throws:
SQLException
AuthorizeException

retrieve

public InputStream retrieve()
                     throws IOException,
                            SQLException,
                            AuthorizeException
Retrieve the contents of the bitstream

Returns:
a stream from which the bitstream can be read.
Throws:
IOException
SQLException
AuthorizeException

getBundles

public Bundle[] getBundles()
                    throws SQLException
Get the bundles this bitstream appears in

Returns:
array of Bundle s this bitstream appears in
Throws:
SQLException

getType

public int getType()
return type found in Constants

Specified by:
getType in class DSpaceObject
Returns:
int Constants.BITSTREAM

isRegisteredBitstream

public boolean isRegisteredBitstream()
Determine if this bitstream is registered

Returns:
true if the bitstream is registered, false otherwise

getStoreNumber

public int getStoreNumber()
Get the asset store number where this bitstream is stored

Returns:
the asset store number of the bitstream

getParentObject

public DSpaceObject getParentObject()
                             throws SQLException
Description copied from class: DSpaceObject
Return the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.

Overrides:
getParentObject in class DSpaceObject
Returns:
the dspace object that "own" the current object in the hierarchy
Throws:
SQLException


Copyright © 2010 DuraSpace. All Rights Reserved.