tribble.archive
Class AbstractWritableDocument

java.lang.Object
  extended by tribble.archive.AbstractDocument
      extended by tribble.archive.AbstractWritableDocument
All Implemented Interfaces:
java.io.Closeable, ArchiveDocument, WritableDocument

public abstract class AbstractWritableDocument
extends AbstractDocument
implements WritableDocument

Generic read-only archive document.

An archive document is composed of content data (such as an image, text, or other kind of user data) and one or more properties.

Most of the methods in this base class that implement the ArchiveDocument interface do not throw any checked exceptions.

Note: This requires Java 1.5 or later.

Source code:
http://david.tribble.com/src/java/tribble/archive/AbstractWritableDocument.java
Documentation:
http://david.tribble.com/docs/tribble/archive/AbstractWritableDocument.html

Since:
2008-04-03
Version:
API 2.0, $Revision: 1.1 $ $Date: 2008/04/03 22:03:56 $
Author:
David R. Tribble (david@tribble.com) Copyright ©2004 by David R. Tribble, all rights reserved.

Field Summary
 
Fields inherited from class tribble.archive.AbstractDocument
m_id, m_props, m_propVals, m_size
 
Constructor Summary
protected AbstractWritableDocument(DocumentProperty[] props)
          Constructor.
 
Method Summary
 void addProperty(WritableProperty prop)
          Add a property to this archive document.
 void setID(java.lang.String id)
          Establish the ID of this archive document.
 void setProperty(java.lang.String prop, java.lang.Object val)
          Set the value of a property in this archive document.
 void setSize(long len)
          Establish the data size for this archive document.
 
Methods inherited from class tribble.archive.AbstractDocument
checkOpen, close, finalize, getID, getProperties, getProperty, getSize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tribble.archive.WritableDocument
putDataStream
 
Methods inherited from interface tribble.archive.ArchiveDocument
close, getDataStream, getID, getProperties, getProperty, getSize
 

Constructor Detail

AbstractWritableDocument

protected AbstractWritableDocument(DocumentProperty[] props)
Constructor.

Parameters:
props - The properties which define the documents in the archive.
Since:
API 2.0, 2008-04-03
Method Detail

setID

public void setID(java.lang.String id)
           throws java.io.IOException,
                  java.lang.UnsupportedOperationException
Establish the ID of this archive document.

Specified by:
setID in interface WritableDocument
Parameters:
id - A name that identifies the document within the archive. Whether or not this name is unique is up to the implementation.
Throws:
java.io.IOException - Thrown if an error occurred while accessing the document.
java.lang.UnsupportedOperationException - (unchecked) Thrown if this operation is not allowed by the implementation, i.e., if IDs are assigned to archive documents by some other means.
java.lang.IllegalStateException - (unchecked) Thrown if AbstractDocument.close() has been called for this object.
Since:
API 2.0, 2008-04-03

setSize

public void setSize(long len)
Establish the data size for this archive document.

Specified by:
setSize in interface WritableDocument
Parameters:
len - The size (typically in bytes) of the document data, or -1 if the size is not known.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if AbstractDocument.close() has been called for this object.
Since:
API 2.0, 2008-04-03

setProperty

public void setProperty(java.lang.String prop,
                        java.lang.Object val)
                 throws java.io.IOException
Set the value of a property in this archive document.

Specified by:
setProperty in interface WritableDocument
Parameters:
prop - The name of the document property to set.
val - The new property value.
Throws:
java.io.IOException - Thrown if an error occurred while modifying the document.
java.lang.IllegalStateException - (unchecked) Thrown if AbstractDocument.close() has been called for this object.
Since:
API 2.0, 2008-04-03

addProperty

public void addProperty(WritableProperty prop)
                 throws java.lang.UnsupportedOperationException,
                        java.io.IOException
Add a property to this archive document.

Specified by:
addProperty in interface WritableDocument
Parameters:
prop - A property to add to this document.
Throws:
java.io.IOException - Thrown if the property already exists in this document, or if an error occurred while modifying the document.
java.lang.UnsupportedOperationException - (unchecked) Thrown if this method is not supported by the implementation of this interface.
java.lang.IllegalStateException - (unchecked) Thrown if AbstractDocument.close() has been called for this object.
Since:
API 2.0, 2008-04-03