當前位置: 首頁>>代碼示例>>Java>>正文


Java MimeType.toString方法代碼示例

本文整理匯總了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();
}
 
開發者ID:Permafrost,項目名稱:Tundra.java,代碼行數:37,代碼來源:MIMETypeHelper.java

示例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;
}
 
開發者ID:groupe-sii,項目名稱:ogham,代碼行數:10,代碼來源:OverrideMimetypeProvider.java

示例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();
    }
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:11,代碼來源:DefaultMailman.java

示例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());
}
 
開發者ID:Permafrost,項目名稱:Tundra.java,代碼行數:10,代碼來源:ImmutableMimeType.java


注:本文中的javax.activation.MimeType.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。