net.cnri.do_api
Class DataElement

java.lang.Object
  extended by net.cnri.do_api.DataElement

public class DataElement
extends java.lang.Object

This is a high level interface to a data element for a digital object.


Method Summary
 long append(java.io.InputStream in)
          Appends the bytes from the given InputStream to the data element, returning the total number of bytes written.
 void deleteAttribute(java.lang.String attributeName)
          Delete the given attributeName for this object.
 void deleteAttributes(java.lang.String[] atts)
          Atomically delete more than one attribute
 java.lang.String getAttribute(java.lang.String attributeName, java.lang.String defaultValue)
          Associates the given attributeValue with the given attributeName for this object.
 HeaderSet getAttributes()
          Return all attributes
 java.lang.String getDataElementID()
          Returns the data element's identifier within the object
 java.util.Date getDateCreated()
          Return the date that this object was created
 java.util.Date getDateLastModified()
          Return the date that this object was last modified
 DigitalObject getDigitalObject()
          Return the DigitalObject of which this element is a part
 java.lang.String getObjectID()
           
 Repository getRepository()
           
 long getSize()
          Gets the size in bytes of the data element, not including attributes
 java.lang.String[] listAttributes()
          Return the list of attribute names for this object
 java.io.InputStream read()
          Returns an InputStream from which the element's data can be read
 void setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Associates the given attributeValue with the given attributeName for this object.
 void setAttributes(HeaderSet atts)
          Atomically set more than one attribute
 java.lang.String toString()
           
 long write(java.io.InputStream in)
           
 long write(java.io.InputStream in, boolean append)
          Writes the bytes from the given InputStream to the data element, returning the total number of bytes written.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

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

getDigitalObject

public DigitalObject getDigitalObject()
Return the DigitalObject of which this element is a part


getObjectID

public java.lang.String getObjectID()

getRepository

public Repository getRepository()

getDataElementID

public java.lang.String getDataElementID()
Returns the data element's identifier within the object


read

public java.io.InputStream read()
                         throws DOException,
                                java.io.IOException
Returns an InputStream from which the element's data can be read

Throws:
DOException
java.io.IOException

append

public long append(java.io.InputStream in)
            throws DOException,
                   java.io.IOException
Appends the bytes from the given InputStream to the data element, returning the total number of bytes written. Note: It is possible to write enough bytes to overflow the 64 bit return value, so if you are writing more than about 9,223,372,036,854,775,808 bytes then don't count on the return value to be accurate.

Throws:
DOException
java.io.IOException

write

public long write(java.io.InputStream in)
           throws DOException,
                  java.io.IOException
Throws:
DOException
java.io.IOException

write

public long write(java.io.InputStream in,
                  boolean append)
           throws DOException,
                  java.io.IOException
Writes the bytes from the given InputStream to the data element, returning the total number of bytes written. Note: It is possible to write enough bytes to overflow the 64 bit return value, so if you are writing more than about 9,223,372,036,854,775,808 bytes then don't count on the return value to be accurate.

Throws:
DOException
java.io.IOException

getDateCreated

public java.util.Date getDateCreated()
                              throws DOException,
                                     java.io.IOException
Return the date that this object was created

Throws:
DOException
java.io.IOException

getDateLastModified

public java.util.Date getDateLastModified()
                                   throws DOException,
                                          java.io.IOException
Return the date that this object was last modified

Throws:
DOException
java.io.IOException

getSize

public long getSize()
             throws DOException,
                    java.io.IOException
Gets the size in bytes of the data element, not including attributes

Throws:
DOException
java.io.IOException

setAttribute

public void setAttribute(java.lang.String attributeName,
                         java.lang.String attributeValue)
                  throws DOException,
                         java.io.IOException
Associates the given attributeValue with the given attributeName for this object.

Throws:
DOException
java.io.IOException

setAttributes

public void setAttributes(HeaderSet atts)
                   throws DOException,
                          java.io.IOException
Atomically set more than one attribute

Throws:
DOException
java.io.IOException

deleteAttribute

public void deleteAttribute(java.lang.String attributeName)
                     throws DOException,
                            java.io.IOException
Delete the given attributeName for this object.

Throws:
DOException
java.io.IOException

deleteAttributes

public void deleteAttributes(java.lang.String[] atts)
                      throws DOException,
                             java.io.IOException
Atomically delete more than one attribute

Throws:
DOException
java.io.IOException

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName,
                                     java.lang.String defaultValue)
                              throws DOException,
                                     java.io.IOException
Associates the given attributeValue with the given attributeName for this object.

Throws:
DOException
java.io.IOException

getAttributes

public HeaderSet getAttributes()
                        throws DOException,
                               java.io.IOException
Return all attributes

Throws:
DOException
java.io.IOException

listAttributes

public java.lang.String[] listAttributes()
                                  throws DOException,
                                         java.io.IOException
Return the list of attribute names for this object

Throws:
DOException
java.io.IOException