| 1 | = DataObject = |
| 2 | |
| 3 | == Java Interface == |
| 4 | |
| 5 | /** |
| 6 | * A general interface for data objects. A data object consists of an identifier, |
| 7 | * binary content and metadata. |
| 8 | */ |
| 9 | public interface DataObject { |
| 10 | |
| 11 | /** |
| 12 | * Gets the data object's primary identifier. |
| 13 | * |
| 14 | * @return An identifier for this data object. |
| 15 | */ |
| 16 | public URI getID(); |
| 17 | |
| 18 | /** |
| 19 | * Returns the byte size of the represented resource. This has been defined at |
| 20 | * this global level due to the importance of this attribute for performance reasons. |
| 21 | * @return the size of the binary resource in bytes, or a negative value when the |
| 22 | * size is unknown or does not make sense for this particular DataObject implementation. |
| 23 | */ |
| 24 | public long getSize(); |
| 25 | |
| 26 | /** |
| 27 | * Gets the DataSource from which this DataObject conceptually originated. |
| 28 | * |
| 29 | * @return The DataSource from which this DataObject conceptually originated. |
| 30 | */ |
| 31 | public DataSource getDataSource(); |
| 32 | |
| 33 | /** |
| 34 | * Gets the data object's parent, if any. |
| 35 | * |
| 36 | * @return the parent DataObject, or null when this DataObject has no parent. |
| 37 | */ |
| 38 | public DataObject getParent(); |
| 39 | |
| 40 | /** |
| 41 | * Gets the data object's children, if any. This may be null to indicate that there |
| 42 | * are no children. |
| 43 | */ |
| 44 | public Iterator<DataObject> getChildren(); |
| 45 | |
| 46 | /** |
| 47 | * Gets an InputStream containing the content represented by the DataObject. |
| 48 | * The returned InputStream is required to support marking (markSupported() |
| 49 | * returns true). Calling this method multiple times may references to |
| 50 | * one-and-the-same InputStream instance. Care should therefore be taken to mark |
| 51 | * and reset the stream when the stream's content is to be read again later. |
| 52 | * |
| 53 | * @return An InputStream from which the content of the data object can be read. |
| 54 | * @throws IOException If an I/O error occurred. |
| 55 | */ |
| 56 | public InputStream getContent() throws IOException; |
| 57 | |
| 58 | /** |
| 59 | * Instructs the DataObject that its content stream will most likely be used multiple |
| 60 | * times in its entirety, making the mark-and-reset procedure difficult to work, |
| 61 | * and that it better should cache the entire contents. |
| 62 | * @throws IOException when an IOException occured during caching of the content. |
| 63 | */ |
| 64 | ´ public void cacheContent() throws IOException; |
| 65 | |
| 66 | /** |
| 67 | * Get the source-specific metadata. |
| 68 | * The used keys and values and implementation-dependent. |
| 69 | * |
| 70 | * @return The scheme-specific metadata. |
| 71 | */ |
| 72 | public Map<Object, Object> getMetaData(); |
| 73 | } |