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.


Field Summary
static java.lang.String ATTRIBUTE_MIME_TYPE
           
 
Method Summary
 void deleteAttribute(java.lang.String attributeName)
          Removes any attribute to the data element that has the given name.
 java.lang.String getAttribute(java.lang.String attributeName, java.lang.String defaultValue)
          Returns the value of the data element attribute having the given name.
 java.lang.String getDataElementID()
          Returns the data element's identifier within the object
 java.util.Date getDateCreated()
          Returns the data element's creation date and time
 java.util.Date getDateLastModified()
          Returns the date and time that the element was last modified
 DigitalObject getDigitalObject()
          Return the DigitalObject of which this element is a part
 long getSize()
          Gets the size in bytes of the data element, not including attributes
 java.lang.String[] listAttributes()
          Lists all of the attribute name value pairs for the data element
 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 data element.
 java.lang.String toString()
           
 long write(java.io.InputStream in)
          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
 

Field Detail

ATTRIBUTE_MIME_TYPE

public static final java.lang.String ATTRIBUTE_MIME_TYPE
See Also:
Constant Field Values
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


getDataElementID

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


getDateCreated

public java.util.Date getDateCreated()
Returns the data element's creation date and time


getDateLastModified

public java.util.Date getDateLastModified()
Returns the date and time that the element was last modified


getSize

public long getSize()
Gets the size in bytes of the data element, not including attributes


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

write

public long write(java.io.InputStream in)
           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

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName,
                                     java.lang.String defaultValue)
Returns the value of the data element attribute having the given name. If no attribute with that name exists, return the given defaultValue


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 data element.

Throws:
DOException
java.io.IOException

listAttributes

public java.lang.String[] listAttributes()
                                  throws DOException,
                                         java.io.IOException
Lists all of the attribute name value pairs for the data element

Throws:
DOException
java.io.IOException

deleteAttribute

public void deleteAttribute(java.lang.String attributeName)
                     throws DOException,
                            java.io.IOException
Removes any attribute to the data element that has the given name.

Throws:
DOException
java.io.IOException