本文整理匯總了Java中javax.activation.MimeType.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java MimeType.toString方法的具體用法?Java MimeType.toString怎麽用?Java MimeType.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.activation.MimeType
的用法示例。
在下文中一共展示了MimeType.toString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: emit
import javax.activation.MimeType; //導入方法依賴的package包/類
/**
* Returns a MIME type string comprised of the components specified in the given IData document.
*
* @param document The IData document to be converted to a MIME type string.
* @return A MIME type string representing the components specified in the given IData document.
* @throws MimeTypeParseException If the given MIME type string is malformed.
*/
public static String emit(IData document) throws MimeTypeParseException {
if (document == null) return null;
IDataCursor cursor = document.getCursor();
String type = IDataUtil.getString(cursor, "type");
String subtype = IDataUtil.getString(cursor, "subtype");
IData parameters = IDataUtil.getIData(cursor, "parameters");
cursor.destroy();
if (type == null) throw new IllegalArgumentException("type must not be null");
if (subtype == null) throw new IllegalArgumentException("subtype must not be null");
MimeType mimeType = new MimeType(type, subtype);
if (parameters != null) {
parameters = IDataHelper.sort(parameters, false, true);
cursor = parameters.getCursor();
while (cursor.next()) {
String key = cursor.getKey();
Object value = cursor.getValue();
if (value instanceof String) {
mimeType.setParameter(key, (String)value);
}
}
cursor.destroy();
}
return mimeType.toString();
}
示例2: override
import javax.activation.MimeType; //導入方法依賴的package包/類
private MimeType override(MimeType mimeType) throws MimeTypeDetectionException {
String original = mimeType.toString();
String replaced = replacer.replace(original);
if (!replaced.equals(original)) {
LOG.debug("Detected mime type {} overriden by: {}", original, replaced);
return toMimetype(original, replaced);
}
return mimeType;
}
示例3: getContentType
import javax.activation.MimeType; //導入方法依賴的package包/類
public String getContentType() {
try {
MimeType mt = new MimeType( super.getContentType() );
mt.setParameter( "type", "text/html" );
return mt.toString();
} catch( MimeTypeParseException e ) {
log.warn( e.toString(), e );
return super.getContentType();
}
}
示例4: ImmutableMimeType
import javax.activation.MimeType; //導入方法依賴的package包/類
/**
* Constructor that builds an ImmutableMimeType given an existing MimeType object.
*
* @param mimeType The MimeType object to clone.
* @throws MimeTypeParseException If the MimeType object returns an incorrectly formatted MIME type string.
*/
public ImmutableMimeType(MimeType mimeType) throws MimeTypeParseException {
super(mimeType.toString());
}