Use an adapter pattern in ContentItem
-------------------------------------
Key: STANBOL-44
URL: https://issues.apache.org/jira/browse/STANBOL-44
Project: Stanbol
Issue Type: Improvement
Components: FISE
Reporter: Fabian Christ
Reported by project member bdelacretaz, May 26, 2010
The ContentItem can currently only provide an InputStream for its data, but in
some cases other
data types (String, RDF graph, etc.) might be convenient.
As discussed at the hackathon, using an adapter pattern allows us to do this in
a flexible way, the
ContentItem interface would then look like this:
public interface ContentItem {
/** Unique ID, either supplied by client or generated by FISE */
String getId();
/** The binary content stream
* @deprecated use adaptTo(InputStream.class) */
InputStream getStream();
/** Adapt to specified class, for example InputStream, String,
* RDF graph or future raw/formatted content types.
* @return null if not adaptable
*/
<AdapterType> AdapterType adaptTo(Class<AdapterType> type);
/** Mime-type of the input stream */
String getMimeType();
/** Optional metadata */
MGraph getMetadata();
}
At first adaptTo would only work for InputStream, so it's a minor code change.
Later we can add an AdapterFactory service interface to provide more adapters.
The Sling codebase uses that pattern, see examples there.
The adaptTo method needs a second parameter for options, probably a Map.
Use case: adapt to an InputStream with mime type image/jpeg
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.