|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper
public class ContentItemHelper
Helper class to factorize common code for ContentItem handling.
| Field Summary | |
|---|---|
static int |
MAX_BUF_SIZE
|
static int |
MIN_BUF_SIZE
|
static java.lang.String |
SHA1
|
static java.lang.String |
UTF8
|
| Constructor Summary | |
|---|---|
ContentItemHelper()
|
|
| Method Summary | ||
|---|---|---|
static org.apache.clerezza.rdf.core.UriRef |
ensureUri(ContentItem ci)
Check that ContentItem#getId returns a valid URI or make an urn out of it. |
|
static java.util.Map.Entry<org.apache.clerezza.rdf.core.UriRef,Blob> |
getBlob(ContentItem ci,
java.util.Set<java.lang.String> mimeTypes)
Searches an content part
of the type Blob with one of the the parsed mimeTypes. |
|
static
|
getContentParts(ContentItem ci,
java.lang.Class<T> clazz)
Returns a Map with the current content parts of the parsed type. |
|
static java.lang.String |
getMimeTypeWithParameters(Blob blob)
Creates the "{type}/{subtime}; [{param}={value}]+" mime type representation for the Blob.getMimeType() and Blob.getParameter() values |
|
static java.lang.String |
getText(Blob blob)
Getter for the Text of an Blob. |
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUri(java.lang.String baseUri,
Blob blob)
|
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUri(java.lang.String baseUri,
byte[] data)
|
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUri(java.lang.String baseUri,
java.io.InputStream in)
|
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUrn(Blob blob)
|
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUrn(byte[] data)
|
|
static org.apache.clerezza.rdf.core.UriRef |
makeDefaultUrn(java.io.InputStream in)
|
|
static java.util.Map<java.lang.String,java.lang.String> |
parseMimeType(java.lang.String mimeTypeString)
This parses and validates the mime-type and parameters from the parsed mimetype string based on the definition as defined in rfc2046. |
|
static java.lang.String |
streamDigest(java.io.InputStream in,
java.io.OutputStream out,
java.lang.String digestAlgorithm)
Pass the binary content from in to out (if not null) while computing the digest. |
|
static java.lang.String |
toHexString(byte[] data)
|
|
static java.lang.String |
urlEncode(java.lang.String uriPart)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SHA1
public static final int MIN_BUF_SIZE
public static final int MAX_BUF_SIZE
public static final java.lang.String UTF8
| Constructor Detail |
|---|
public ContentItemHelper()
| Method Detail |
|---|
public static org.apache.clerezza.rdf.core.UriRef ensureUri(ContentItem ci)
public static java.lang.String urlEncode(java.lang.String uriPart)
public static java.lang.String streamDigest(java.io.InputStream in,
java.io.OutputStream out,
java.lang.String digestAlgorithm)
throws java.io.IOException
in - stream to read the data fromout - optional output stream todigestAlgorithm - MD5 or SHA1 for instance
java.io.IOExceptionpublic static java.lang.String toHexString(byte[] data)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUrn(Blob blob)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUrn(java.io.InputStream in)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUrn(byte[] data)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUri(java.lang.String baseUri,
Blob blob)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUri(java.lang.String baseUri,
byte[] data)
public static org.apache.clerezza.rdf.core.UriRef makeDefaultUri(java.lang.String baseUri,
java.io.InputStream in)
public static java.util.Map<java.lang.String,java.lang.String> parseMimeType(java.lang.String mimeTypeString)
The mime-type is stored as value for the null
key. Parameter keys are converted to lower case. Values are stored as
defined in the parsed media type. Parameters with empty key, empty or no
values are ignored.
mimeTypeString - the media type formatted as defined by
rfc2046
null key and
all parameters with lower case keys and values.
java.lang.IllegalArgumentException - if the parsed mimeTypeString is
null, empty or the parsed mime-type is empty, does not define
non empty '{type}/{sub-type}' or uses a wildcard for the type or sub-type.
public static java.util.Map.Entry<org.apache.clerezza.rdf.core.UriRef,Blob> getBlob(ContentItem ci,
java.util.Set<java.lang.String> mimeTypes)
content part
of the type Blob with one of the the parsed mimeTypes. NOTE:
ContentItem is applied while
searching for a fitting Blob
In contrast to the contentPart related methods of the ContentItem
this method does NOT throw NoSuchPartException.
ci - the contentITemmimeTypes - List of possible mimeTypes
URI and the content of the content
part or null if not found
java.lang.IllegalArgumentException - If the parsed ContentItem is
null or the parsed Set with the mimeTypes is null
or empty.
public static <T> java.util.LinkedHashMap<org.apache.clerezza.rdf.core.UriRef,T> getContentParts(ContentItem ci,
java.lang.Class<T> clazz)
Iterators over the
returned map is consistent with the ordering of the contentPart within the
ContentItem. When parsing Object as class the number
of the element will be equals to the index of that content part.
In contrast to the contentPart related methods of the ContentItem
this method does NOT throw NoSuchPartException.
ci - the content itemclazz - the class of the content part
ids and the content as entries.
public static java.lang.String getText(Blob blob)
throws java.io.IOException
Blob. This method respects the
"charset" if present in the parameter of the
Blob.
blob - the Blob. MUST NOT be null.
java.io.IOException - on any exception while reading from the
InputStream provided by the Blob.
java.lang.IllegalArgumentException - if the parsed Blob is nullpublic static java.lang.String getMimeTypeWithParameters(Blob blob)
Blob.getMimeType() and Blob.getParameter() values
blob - the Blob
text/plain;charset=UTF-8)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||