Class Fedora.DigitalObject.DataStreamImpl
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Fedora.DigitalObject.DataStreamImpl

Object
   |
   +----ObjectImpl
           |
           +----DynamicImplementation
                   |
                   +----_DataStreamSkeleton
                           |
                           +----_DataStreamImplBase
                                   |
                                   +----Fedora.DigitalObject.DataStreamImpl

public class DataStreamImpl
extends _DataStreamImplBase
implements Serializable
Class that implements the RAP.DataStream interface. In the abstract a DataStream is a typed stream of data that is stored inside a a DigitalObject. A DataStream has a unique identifier that is assigned by FEDORA. It also has a set of administrative attributes, specifically a MIME type, a descriptor, the size of the stored stream of data, the date the DataStream was created, and the date of last update.

A DataStream may be local or remote. A local DataStream actually contains a stream of data. A remote DataStrea, does not store a stream of data, but a location (URN or URL) of a remotely stored stream of data. The current implementation of FEDORA has not exploited the remote DataStream notion. This class will require modifications to accommodate the remote DataStream notion. DataStreams are stored by reference inside DigitalObjects and instantiated as needed. DigitalObjects store lightweight DataStream components called DataStreamShadows that contain the DataStreamID and a method to load the full DataStream from persistent storage.

See Also:
DataStreamShadow, DigitalObjectImpl

Variable Index

 o DataStreamID
 o MIMEType
 o data
 o dateDeposited
 o dateLastRevised
 o descriptor
 o parentDigitalObjectID
 o size

Constructor Index

 o Fedora.DigitalObject.DataStreamImpl()
Default constructor for a DataStream
 o Fedora.DigitalObject.DataStreamImpl(String, String, byte[], String)
Constructor to create a new DataStream inside a DigitalObject

Method Index

 o GetBytes(int, int)
Return the stream of data that is stored in the DataStream.
 o GetDataStreamID()
Return the DataStreamID which is a system assigned value.
 o GetKeyMetadata()
Return the set of administrative attributes for the DataStream.
 o GetMIMEType()
Return the MIME type for the DataStream.
 o WriteBytes(int, int, WriteBytesMode, byte[])
Updates the array of bytes (data) that is stored in the DataStream.
 o createDSShadow()
Create a DataStreamShadow object for the DataStream object
 o getParentDOID()
Return the parent DigitalObjectID for this Datastream

Variables

 o DataStreamID
protected java.lang.String DataStreamID
 o MIMEType
protected java.lang.String MIMEType
 o data
protected byte[] data
 o dateDeposited
protected java.lang.String dateDeposited
 o dateLastRevised
protected java.lang.String dateLastRevised
 o descriptor
protected java.lang.String descriptor
 o parentDigitalObjectID
protected java.lang.String parentDigitalObjectID
 o size
protected int size

Constructors

 o DataStreamImpl
public DataStreamImpl()
Default constructor for a DataStream

 o DataStreamImpl
public DataStreamImpl(String dsType,
                      String ds_desc,
                      byte data,
                      String parentDOID)
Constructor to create a new DataStream inside a DigitalObject

Parameters:
dsType - MIME type of datastream
ds_desc - descriptor (user assigned) for datastream
data - the stream data itself as an array of bytes
parentDOID - DigitalObjectID of parent digital object
Returns:
an instance of the new DataStream

Methods

 o GetBytes
public byte[] GetBytes(int length,
                       int offset) throws RepositorySystemError
Return the stream of data that is stored in the DataStream. The bytes returned will be determined by the values in the arguments offset and length. The array of bytes returned will be either the whole stream or a segment of the stream.

If a length of zero is requested, the default behavior of this method will be to return the entire stream of bytes, regardless of any value specified in the offset argument. If a length greater than zero and the offset is greater than zero (but not exceeding the length of the stream), then a segment of the stream will be returned. The bytes at positions offset through offset+length-1 in the source array of bytes are returned.

Parameters:
length - the number of bytes to return, starting at the offset point. A length of zero will set off the default behavior of this method which is to return the entire stream of bytes.
offset - the starting point in the DataStream's array of bytes (data).
Returns:
an array of bytes that is either the entire byte stream or a segment of it.
Overrides:
GetBytes in class _DataStreamSkeleton
 o GetDataStreamID
public java.lang.String GetDataStreamID() throws RepositorySystemError
Return the DataStreamID which is a system assigned value. The DataStream ID is the component ID used to identify the DataStream in persistent storage.

Returns:
a string that is the unique identifier for a DataStream
Overrides:
GetDataStreamID in class _DataStreamSkeleton
 o GetKeyMetadata
public RAP.DSKeyMetadata GetKeyMetadata() throws RepositorySystemError
Return the set of administrative attributes for the DataStream. Some of these attributes were assigned by the client at the time the DataStream is created. These attributes are: MIMEType and the DataStream descriptor. The other administrative attributes were assigned by the Repository. These are: the size of the stream the DataStream's date of deposit, and the DataStream's date of last revision.

Returns:
a structure containing the administrative attributes of a DataStream. These attributes are: MIMEType, descriptor, size of stream, date of deposit (creation), and date of last revision.
Overrides:
GetKeyMetadata in class _DataStreamSkeleton
 o GetMIMEType
public java.lang.String GetMIMEType() throws RepositorySystemError
Return the MIME type for the DataStream. The MIME type for a DataStream is assigned by a client at the time the DataStream is created. The Repository does not automatically derive it from a stream of bytes. Thus, care must be taken at the client end to ensure accuracy of MIME types at the time of DataStream creation.

Returns:
a string that is MIME type for the DataStream
Overrides:
GetMIMEType in class _DataStreamSkeleton
 o WriteBytes
public int WriteBytes(int bufferLength,
                      int absoluteDataStreamOffset,
                      WriteBytesMode mode,
                      byte buffer) throws RepositorySystemError
Updates the array of bytes (data) that is stored in the DataStream. A new array of bytes can be sent into the DataStream and appended to the existing array of bytes. Also, the existing array of bytes in the DataStream can be completely overwritten with a new array of bytes.

The WriteBytes method is intended as a means of updating the data stream in DataStreams. However, it is possible that a DataStream was initially created with an empty data attribute. This would occur if the CreateDataStream request was issued on the DigitalObject with an empty array of bytes in the parameter named data. In such cases the WriteBytes method may be used as the means of initially populating the DataStreams data attribute.

WARNING!!! This method has not been used frequently in the current FEDORA implementation and it could probably use some more rigorous testing!!

Parameters:
bufferLength - the length of the new data (found in parameter named buffer)
absoluteDataStreamOffset - the starting point for writing new bytes in the DataStream's existing array of bytes.
mode - the update mode, either APPEND or OVERWRITE
buffer - the new data that will either be appended to the existing array of bytes in the DataStream, or that will overwrite the existing array of bytes in the DataStream.
Returns:
an array of bytes that is either the entire byte stream or a segment of it.
Overrides:
WriteBytes in class _DataStreamSkeleton
 o createDSShadow
protected Fedora.DigitalObject.DataStreamShadow createDSShadow() throws RepositorySystemError
Create a DataStreamShadow object for the DataStream object

 o getParentDOID
public java.lang.String getParentDOID()
Return the parent DigitalObjectID for this Datastream

Returns:
a string that is the URN of the parent DigitalObject for the DataStream.

All Packages  Class Hierarchy  This Package  Previous  Next  Index