//============================================================================== // ArchiveReader.java //============================================================================== package tribble.archive; import java.io.Closeable; import java.io.IOException; import java.lang.Exception; import java.lang.String; import java.util.Properties; import java.util.Set; /******************************************************************************* * Generic document archive storage reader. * *

* This interface contains the basic methods for implementing a * document archive reader application. Such an application is * responsible for managing a document storage system (or archive) that * allows clients to retrieve documents from it. How the archive system * is implemented and what exactly constitutes a document is determined by each * particular subclass that implements this interface. * *

* A document consists of content data (such as an image, text, or other * kind of user data) and one or more properties. Typically, the * properties comprise the indices used to store the document in the archive * system. * *

* To retrieve an existing document within an archive system, first an archive * reader object is created. The type of this object is a subclass which extends * the {@link ArchiveReader} class: *

*    class MyArchiveReader
*        extends ArchiveReader<MyDocument>
*    { ... }
* *

* Likewise, the documents that are retrieved from this archive system are of a * subclass which extends the {@link ArchiveDocument} class: *

*    class MyDocument
*        extends {@link ArchiveDocument}
*    { ...}
* *

* An archive reader is created and its {@link #initialize initialize()} method * is called to initialize it: *

*    MyArchiveReader     arch;
*    Properties          props;
*
*    arch = new MyArchiveReader(...);
*    props = ...;
*    arch.initialize(props);
* *

* Next, a connection to the archive system must be established and attached to * the archive reader: *

*    try
*    {
*        arch.{@link #open open}();
*    }
*    catch (IOException ex)
*    { ... }
* *

* If the document ID is known, it can be used to directly retrieve a specific * document from the archive: *

*    try
*    {
*        String      id;
*        MyDocument  doc;
*
*        id = ...;
*        doc = arch.{@link #getDocument getDocument}(id);
*        ...process the document...
*        doc.{@link ArchiveDocument#close close}();
*    }
*    catch (IOException ex)
*    { ... }
* *

* Alternatively, a set of zero or more documents can be retrieved, based on some * kind of query criteria: *

*    try
*    {
*        MyQueryType     query;
*        {@link Set}<MyDocument> docs;
*
*        query = ...;
*        docs = arch.{@link #findDocuments findDocuments}(query);
*    }
*    catch (IOException ex)
*    { ... }
* *

* If the query is successful, the individual documents matching the search * criteria can be retrieved: *

*    Iterator<MyDocument>    list;
*
*    list = docs.iterator();
*    while (list.hasNext())
*    {
*        MyDocument  doc;
*
*        doc = list.next();
*        ...process the document...
*        doc.{@link ArchiveDocument#close close}();
*    }
* *

* The {@link ArchiveDocument#getProperty getProperty()} method can be called * to retrieve the values for specific properties associated with the document. * The {@link ArchiveDocument#getProperties getProperties()} method can be called * to retrieve an array containing all of the properties associated with the * document. * *

* Once the archive reader is no longer needed, it must be closed, breaking the * connection and detaching it from the archive system: *

*    arch.{@link #close close}();
* *

* Exceptions (IOException) are thrown if any errors occur during * processing. * *

* Note: This requires Java 1.5 or later. * * *

*
Source code:
*
* http://david.tribble.com/src/java/tribble/archive/ArchiveReader.java *
*
Documentation:
*
* http://david.tribble.com/docs/tribble/archive/ArchiveReader.html *
*
* * * @version API 2.0, $Revision: 1.1 $ $Date: 2008/04/03 22:16:22 $ * @since 2008-04-03 * @author David R. Tribble (david@tribble.com) * Copyright ©2004 by David R. Tribble, all rights reserved. * * @see ArchiveDocument * @see DocumentProperty * @see ArchiveWriter */ public interface ArchiveReader extends Archive, java.io.Closeable { static final String REV = "@(#)tribble/archive/ArchiveReader.java $Revision: 1.1 $ $Date: 2008/04/03 22:16:22 $\n"; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Methods /*************************************************************************** * Retrieve a specific document from the archive attached to this archive * reader. * * @param id * ID of the document to retrieve from the archive. * * @throws IOException * Thrown if an error occurs while retrieving the document from the archive * system. * * @throws IllegalStateException (unchecked) * Thrown if {@link #initialize initialize()} has not been called yet. * * @since API 2.0, 2008-04-03 */ public abstract DocType getDocument(String id) throws IOException; /*************************************************************************** * Find matching documents within the archive attached to this archive * reader. * * @param query * A query for searching for multiple matching documents within the archive. * The actual form of this object (string, expression tree, etc.) is * dependent upon the implementation of the archive system. * * @return * A set of zero or more matching documents. * * @throws IOException * Thrown if an error occurs while querying the archive system. * * @throws IllegalStateException (unchecked) * Thrown if {@link #initialize initialize()} has not been called yet. * * @since API 2.0, 2008-04-03 */ public abstract Set findDocuments(Object query) throws IOException; } // End ArchiveReader.java