tribble.archive
Class AbstractDocument

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

public abstract class AbstractDocument
extends java.lang.Object
implements ArchiveDocument

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 class do not throw any checked exceptions.

Note: This requires Java 1.5 or later.

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

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

Field Summary
protected  java.lang.String m_id
          Document ID.
protected  DocumentProperty[] m_props
          Properties.
protected  java.lang.Object[] m_propVals
          Property values.
protected  long m_size
          Document size (typically in bytes).
 
Constructor Summary
protected AbstractDocument(DocumentProperty[] props)
          Constructor.
 
Method Summary
protected  void checkOpen()
          Check that this archive document has not been closed.
 void close()
          Close this archive document.
protected  void finalize()
          Finalization.
 java.lang.String getID()
          Retrieve the ID of this archive document.
 DocumentProperty[] getProperties()
          Retrieve the properties for this archive document.
 java.lang.Object getProperty(java.lang.String prop)
          Retrieve the value of a property in this archive document.
 long getSize()
          Retrieve the size of the data for this archive document.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tribble.archive.ArchiveDocument
getDataStream
 

Field Detail

m_id

protected java.lang.String m_id
Document ID.


m_size

protected long m_size
Document size (typically in bytes).


m_props

protected DocumentProperty[] m_props
Properties.


m_propVals

protected java.lang.Object[] m_propVals
Property values.

Constructor Detail

AbstractDocument

protected AbstractDocument(DocumentProperty[] props)
Constructor.

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

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalization.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable
Since:
API 2.0, 2008-04-03

checkOpen

protected void checkOpen()
                  throws java.lang.IllegalStateException
Check that this archive document has not been closed.

Throws:
java.lang.IllegalStateException - (unchecked) Thrown if close() has been called for this object.
Since:
API 2.0, 2008-04-03

close

public void close()
Close this archive document. Deallocates all resources associated with the document. Any further use of the document will result in exceptions.

Note that this method can be called multiple times with no ill effects.

Note that this method does not throw any exceptions.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface ArchiveDocument
Since:
API 2.0, 2008-04-03

getID

public java.lang.String getID()
Retrieve the ID of this archive document.

Specified by:
getID in interface ArchiveDocument
Returns:
A name that identifies the document within the archive.
Throws:
java.io.IOException - Thrown if an error occurred while accessing the document.
Since:
API 2.0, 2008-04-03

getSize

public long getSize()
Retrieve the size of the data for this archive document.

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

getProperties

public DocumentProperty[] getProperties()
Retrieve the properties for this archive document.

Specified by:
getProperties in interface ArchiveDocument
Returns:
The properties defined for this document.
Throws:
java.lang.IllegalStateException - (unchecked) Thrown if close() has been called for this object.
Since:
API 2.0, 2008-04-03

getProperty

public java.lang.Object getProperty(java.lang.String prop)
                             throws java.io.IOException
Retrieve the value of a property in this archive document.

Specified by:
getProperty in interface ArchiveDocument
Parameters:
prop - The name of the document property value to retrieve.
Returns:
The property value (which may be null).
Throws:
java.io.IOException - Thrown if the document does not have the specified property.
java.lang.IllegalStateException - (unchecked) Thrown if close() has been called for this object.
Since:
API 2.0, 2008-04-03