|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl
public abstract class ContentItemImpl
A generic ContentItem implementation that takes the uri, main content part and the graph used to store the metadata as parameter.
This content item consisting initially of a single blob. Subclasses don't have to care about multi-parts aspects of content item. By inheriting from this class the ability for clients to add additional parts is ensured.
Even through this class does implement the full ContentItem interface
it is marked as abstract and has only a protected constructor because it is
not intended that users directly instantiate it. The intended usage is to
create subclasses that instantiate ContentItmes with specific combinations
of Blob nad MGraph implementations.
Examples are:
InMemoryContentItem intended for in-memory
storage of ContentItems during the stateless enhancement workflow
WebContentItem that allows to create a ContentItem from an
URI.
| Field Summary | |
|---|---|
protected static java.lang.String |
MAIN_BLOB_SUFFIX
|
protected java.util.concurrent.locks.Lock |
readLock
|
protected java.util.concurrent.locks.Lock |
writeLock
|
| Constructor Summary | |
|---|---|
protected |
ContentItemImpl(org.apache.clerezza.rdf.core.UriRef uri,
Blob main,
org.apache.clerezza.rdf.core.MGraph metadata)
|
| Method Summary | ||
|---|---|---|
java.lang.Object |
addPart(org.apache.clerezza.rdf.core.UriRef uriRef,
java.lang.Object object)
Add a new part to this ContentItem |
|
boolean |
equals(java.lang.Object o)
|
|
Blob |
getBlob()
Final getter retrieving the Blob via getPart(UriRef, Class)
with |
|
java.util.concurrent.locks.ReadWriteLock |
getLock()
Read/write lock used to synchronise access to the metadata and the content parts of this content item. |
|
org.apache.clerezza.rdf.core.access.LockableMGraph |
getMetadata()
Optional metadata |
|
java.lang.String |
getMimeType()
The MimeType. |
|
|
getPart(int index,
java.lang.Class<T> clazz)
A content item may consists of multiple parts, while the part with index 0 should always be a blob, higher position may be used by Enhancer to story arbitrary objects, such objects can be used for accessing the precomputations of EnhancementEngines previous in the chain. |
|
|
getPart(org.apache.clerezza.rdf.core.UriRef uri,
java.lang.Class<T> clazz)
Each part of the content item has a URI. |
|
org.apache.clerezza.rdf.core.UriRef |
getPartUri(int index)
Get the uri of the part at the specified index |
|
java.io.InputStream |
getStream()
The binary content stream. |
|
org.apache.clerezza.rdf.core.UriRef |
getUri()
The Uri of this ContentItem (either supplied by client or generated by Stanbol Enhancer) |
|
int |
hashCode()
|
|
void |
removePart(int index)
Removes a part - other than the main content part - from this ContentItem |
|
void |
removePart(org.apache.clerezza.rdf.core.UriRef uriRef)
Removes a part - other than the main content part - from this ContentItem |
|
java.lang.String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String MAIN_BLOB_SUFFIX
protected final java.util.concurrent.locks.Lock readLock
protected final java.util.concurrent.locks.Lock writeLock
| Constructor Detail |
|---|
protected ContentItemImpl(org.apache.clerezza.rdf.core.UriRef uri,
Blob main,
org.apache.clerezza.rdf.core.MGraph metadata)
| Method Detail |
|---|
public final java.util.concurrent.locks.ReadWriteLock getLock()
ContentItemmetadata and the content parts of this content item.
The lock used by the LockableMGraph.getLock() MUST BE the same
as the lock returned by this Instance. This is to avoid deadlocks when
using a lock while iterating over the metadata and
simultaneously accessing the content parts. In other words
calling contentItem.getLock() == contentItem.getMetadata().getLock()
MUST BE true
getLock in interface ContentItemLockableMGraph
containing the metadata of this content item.public final Blob getBlob()
getPart(UriRef, Class)
with getUri()+MAIN_BLOB_SUFFIX
getBlob in interface ContentItempublic final java.io.InputStream getStream()
ContentItemContentItem.getBlob().getStream()
getStream in interface ContentItempublic final java.lang.String getMimeType()
ContentItemContentItem.getBlob().getMimeType().
getMimeType in interface ContentItem
public <T> T getPart(org.apache.clerezza.rdf.core.UriRef uri,
java.lang.Class<T> clazz)
throws NoSuchPartException
ContentItem
getPart in interface ContentItemNoSuchPartException - if no part with the parsed uri exists
public org.apache.clerezza.rdf.core.UriRef getPartUri(int index)
throws NoSuchPartException
ContentItem
getPartUri in interface ContentItemNoSuchPartException - if no part with the parsed index exists
public <T> T getPart(int index,
java.lang.Class<T> clazz)
throws NoSuchPartException
ContentItem
getPart in interface ContentItemNoSuchPartException - if no part with the parsed index exists
public java.lang.Object addPart(org.apache.clerezza.rdf.core.UriRef uriRef,
java.lang.Object object)
ContentItem
addPart in interface ContentItemuriRef - the URI of the partobject - the part
null if
no part with the parsed URI was presentpublic void removePart(int index)
ContentItem
removePart in interface ContentItemindex - the index of the part to remove. NOTE that index '0'
- the main content part - can NOT be removed!public void removePart(org.apache.clerezza.rdf.core.UriRef uriRef)
ContentItem
removePart in interface ContentItemuriRef - the uri of the part to remove. NOTE that the part with the
uri getPartUri(0) - the main
content part - can NOT be removed!public org.apache.clerezza.rdf.core.UriRef getUri()
ContentItem
getUri in interface ContentItempublic org.apache.clerezza.rdf.core.access.LockableMGraph getMetadata()
ContentItem
getMetadata in interface ContentItempublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||