tribble.repository
Class AbstractDocument

java.lang.Object
  extended by tribble.repository.AbstractDocument
All Implemented Interfaces:
java.io.Closeable, Document
Direct Known Subclasses:
AbstractStorableDocument

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

Generic read-only repository document.

A repository document is composed of content data (such as an image, text, or other kind of user data) and zero 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/repository/AbstractDocument.java
Documentation:
http://david.tribble.com/docs/tribble/repository/AbstractDocument.html

Since:
2008-04-03
Version:
API 2.0, $Revision: 1.1 $ $Date: 2008/04/04 03:26:08 $
Author:
David R. Tribble (david@tribble.com)
Copyright ©2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by the United States Department of State as a terrorist or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.
See Also:
AbstractStorableDocument

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 repository document has not been closed.
 void close()
          Close this repository document.
protected  void finalize()
          Finalization.
 java.lang.String getID()
          Retrieve the ID of this repository document.
 DocumentProperty[] getProperties()
          Retrieve the properties for this repository document.
 java.lang.Object getProperty(java.lang.String prop)
          Retrieve the value of a property in this repository document.
 long getSize()
          Retrieve the size of the data for this repository document.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tribble.repository.Document
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 repository. 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 repository 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 repository 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 Document
Since:
API 2.0, 2008-04-03

getID

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

Specified by:
getID in interface Document
Returns:
A name that identifies the document within the repository.
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 repository document.

Specified by:
getSize in interface Document
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

getProperty

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

Specified by:
getProperty in interface Document
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

getProperties

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

Specified by:
getProperties in interface Document
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