//============================================================================== // AbstractDocument.java //============================================================================== package tribble.repository; import java.io.IOException; import java.io.InputStream; import java.lang.String; import java.lang.System; import java.lang.Throwable; /******************************************************************************* * 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. * * *
* Note that this method can be called multiple times with no ill effects. * *
* Note that this method does not throw any exceptions. * * @since API 2.0, 2008-04-03 */ //@Override public void close() { m_props = CLOSED; } /*************************************************************************** * Retrieve the repository folder that contains this document. * * @return * The parent folder for this document, or null if the document does not have * a parent folder. * * @throws IOException * Thrown if an error occurred while accessing the document. * * @since API 3.0, 2012-02-17 */ //@Override public Folder getFolder() { return m_folder; } /*************************************************************************** * Retrieve the ID of this repository document. * * @return * A name that identifies the document within the repository. * * @throws IOException * Thrown if an error occurred while accessing the document. * * @since API 2.0, 2008-04-03 */ //@Override public String getID() { return m_id; } /*************************************************************************** * Retrieve the size of the data for this repository document. * * @return * The size (typically in bytes) of the document data, or -1 if the size is * not known. * * @throws IllegalStateException (unchecked) * Thrown if {@link #close} has been called for this object. * * @since API 2.0, 2008-04-03 */ //@Override public long getSize() { checkOpen(); return m_size; } /*************************************************************************** * Retrieve the value of a property in this repository document. * * @param prop * The name of the document property value to retrieve. * * @return * The property value (which may be null). * * @throws IOException * Thrown if the document does not have the specified property. * * @throws IllegalStateException (unchecked) * Thrown if {@link #close} has been called for this object. * * @since API 2.0, 2008-04-03 */ //@Override public Object getProperty(String prop) throws IOException { // Sanity checks checkOpen(); if (m_propVals == null) throw new IOException("Document has no properties"); // Find the specified property for (int i = 0; i < m_props.length; i++) { if (m_props[i].getName().equals(prop)) return m_propVals[i]; } throw new IOException("No such document property: " + prop); } /*************************************************************************** * Retrieve the properties for this repository document. * * @return * The properties defined for this document. * * @throws IllegalStateException (unchecked) * Thrown if {@link #close} has been called for this object. * * @since API 2.0, 2008-04-03 */ //@Override public DocumentProperty[] getProperties() { DocumentProperty[] copy; // Build a copy of the properties checkOpen(); copy = new DocumentProperty[m_props.length]; System.arraycopy(m_props, 0, copy, 0, m_props.length); return copy; } /*************************************************************************** * Open a readable data stream to the contents of this repository document. * * @return * A readable binary data stream containing the contents of the document. * Note that the stream must be closed (by calling its close() * method) after the data is read. * * @throws IOException * Thrown if an error occurred while accessing the document. * * @since API 3.0, 2012-02-17 */ public abstract InputStream getInputStream() throws IOException; /*************************************************************************** * @deprecated * * Use {@link #getInputStream()} instead. * * @since API 2.0, 2008-04-03 */ public InputStream getDataStream() throws IOException { throw new IOException("Deprecated. Use setInputStream() instead."); } } // End AbstractDocument.java