本文整理匯總了Java中org.apache.tika.mime.MediaType.getSubtype方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaType.getSubtype方法的具體用法?Java MediaType.getSubtype怎麽用?Java MediaType.getSubtype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tika.mime.MediaType
的用法示例。
在下文中一共展示了MediaType.getSubtype方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
import org.apache.tika.mime.MediaType; //導入方法依賴的package包/類
@Override
public void handle(String filename, MediaType mediaType,
InputStream stream) {
// Do we want it?
if(acceptTypes == null || acceptTypes.contains(mediaType))
{
// Ensure we have a filename
if(filename == null)
{
anonymousCount++;
filename = "embedded"+anonymousCount+"."+mediaType.getSubtype();
}
logger.info("Extracting embedded " + mediaType + " entry " + filename);
// Save it
Map<QName,Serializable> properties = new HashMap<QName,Serializable>();
properties.put(ContentModel.PROP_NAME, filename);
NodeRef node = nodeService.createNode(
folder,
ContentModel.ASSOC_CONTAINS,
QName.createQName(filename),
ContentModel.TYPE_CONTENT,
properties
).getChildRef();
ContentWriter writer = contentService.getWriter(
node, ContentModel.PROP_CONTENT, true
);
writer.setMimetype(mediaType.toString());
writer.putContent(stream);
}
else
{
logger.info("Skipping embedded " + mediaType + " entry " + filename);
}
}
示例2: isMediaTypeMatch
import org.apache.tika.mime.MediaType; //導入方法依賴的package包/類
/** Returns true if mediaType falls withing the given range (pattern), false otherwise */
private boolean isMediaTypeMatch(MediaType mediaType, MediaType rangePattern) {
String WILDCARD = "*";
String rangePatternType = rangePattern.getType();
String rangePatternSubtype = rangePattern.getSubtype();
return (rangePatternType.equals(WILDCARD) || rangePatternType.equals(mediaType.getType()))
&& (rangePatternSubtype.equals(WILDCARD) || rangePatternSubtype.equals(mediaType.getSubtype()));
}
示例3: getMimeTypeFromContentType
import org.apache.tika.mime.MediaType; //導入方法依賴的package包/類
protected static String getMimeTypeFromContentType(String contentType) {
String result = "";
MediaType mt = MediaType.parse(contentType);
if (mt != null) {
result = mt.getType() + "/" + mt.getSubtype();
}
return result;
}
示例4: getSuperTypeForMimeType
import org.apache.tika.mime.MediaType; //導入方法依賴的package包/類
public String getSuperTypeForMimeType(String mimeType) {
try {
MediaType mediaType = this.mimeTypes.getMediaTypeRegistry().getSupertype(this.mimeTypes.forName(mimeType).getType());
if (mediaType != null) {
return mediaType.getType() + "/" + mediaType.getSubtype();
} else {
return null;
}
}catch (Exception e) {
LOG.log(Level.WARNING, "Failed to get super-type for mimetype "
+ mimeType + " : " + e.getMessage());
return null;
}
}