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


Java MimeType類代碼示例

本文整理匯總了Java中javax.activation.MimeType的典型用法代碼示例。如果您正苦於以下問題:Java MimeType類的具體用法?Java MimeType怎麽用?Java MimeType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MimeType類屬於javax.activation包,在下文中一共展示了MimeType類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calcExpectedMediaType

import javax.activation.MimeType; //導入依賴的package包/類
static MimeType calcExpectedMediaType(AnnotationSource primarySource,
                    ModelBuilder builder ) {
    XmlMimeType xmt = primarySource.readAnnotation(XmlMimeType.class);
    if(xmt==null)
        return null;

    try {
        return new MimeType(xmt.value());
    } catch (MimeTypeParseException e) {
        builder.reportError(new IllegalAnnotationException(
            Messages.ILLEGAL_MIME_TYPE.format(xmt.value(),e.getMessage()),
            xmt
        ));
        return null;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:Util.java

示例2: logoutByPost

import javax.activation.MimeType; //導入依賴的package包/類
@RequestMapping(value = "/api/logout", method = RequestMethod.POST)
public void logoutByPost(@RequestBody String requestBody, @RequestHeader(value = "Content-Type") MimeType contentType,
                         HttpServletResponse response) throws IOException, JSONException {

    String sessionUUID;
    if (contentType.match(JSONConverter.MIME_TYPE_JSON)) {
        try {
            JSONObject json = new JSONObject(requestBody);
            sessionUUID = json.getString("session");
        } catch (JSONException e) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
    } else if (contentType.match(FORM_TYPE)) {
        String[] fields = requestBody.split("=");
        if (fields.length < 2) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
        sessionUUID = URLEncodeUtils.decodeUtf8(fields[1]);
    } else {
        throw new IllegalStateException("Unsupported content type: " + contentType);
    }

    doLogout(sessionUUID, response);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:27,代碼來源:LoginServiceController.java

示例3: classify

import javax.activation.MimeType; //導入依賴的package包/類
/**
 * Classifies the given mime type into one of the following classifications: xml, json, yaml, csv, tsv, psv.
 *
 * @param type  The MIME type to classify.
 * @return      The classification of the MIME type, or null if unclassifiable.
 */
public static String classify(MimeType type) {
    if (type == null) return null;

    String subType = type.getSubType();
    String classification = null;

    if (subType.equals("xml") || subType.endsWith("+xml")) {
        classification = "xml";
    } else if (subType.equals("json") || subType.endsWith("+json")) {
        classification = "json";
    } else if (subType.equals("csv") || subType.endsWith("+csv") || subType.equals("comma-separated-values") || subType.endsWith("+comma-separated-values")) {
        classification = "csv";
    } else if (subType.equals("yaml") || subType.endsWith("+yaml") || subType.equals("x-yaml") || subType.endsWith("+x-yaml")) {
        classification = "yaml";
    } else if (subType.equals("tsv") || subType.endsWith("+tsv") || subType.equals("tab-separated-values") || subType.endsWith("+tab-separated-values")) {
        classification = "tsv";
    } else if (subType.equals("psv") || subType.endsWith("+psv") || subType.equals("pipe-separated-values") || subType.endsWith("+pipe-separated-values")) {
        classification = "psv";
    }

    return classification;
}
 
開發者ID:Permafrost,項目名稱:Tundra.java,代碼行數:29,代碼來源:MIMETypeHelper.java

示例4: writeTypeRef

import javax.activation.MimeType; //導入依賴的package包/類
/**
 * Writes a type attribute (if the referenced type is a global type)
 * or writes out the definition of the anonymous type in place (if the referenced
 * type is not a global type.)
 *
 * Also provides processing for ID/IDREF, MTOM @xmime, and swa:ref
 *
 * ComplexTypeHost and SimpleTypeHost don't share an api for creating
 * and attribute in a type-safe way, so we will compromise for now and
 * use _attribute().
 */
private void writeTypeRef(TypeHost th, NonElementRef<T, C> typeRef, String refAttName) {
    // ID / IDREF handling
    switch(typeRef.getSource().id()) {
    case ID:
        th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "ID"));
        return;
    case IDREF:
        th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "IDREF"));
        return;
    case NONE:
        // no ID/IDREF, so continue on and generate the type
        break;
    default:
        throw new IllegalStateException();
    }

    // MTOM handling
    MimeType mimeType = typeRef.getSource().getExpectedMimeType();
    if( mimeType != null ) {
        th._attribute(new QName(WellKnownNamespace.XML_MIME_URI, "expectedContentTypes", "xmime"), mimeType.toString());
    }

    // ref:swaRef handling
    if(generateSwaRefAdapter(typeRef)) {
        th._attribute(refAttName, new QName(WellKnownNamespace.SWA_URI, "swaRef", "ref"));
        return;
    }

    // type name override
    if(typeRef.getSource().getSchemaType()!=null) {
        th._attribute(refAttName,typeRef.getSource().getSchemaType());
        return;
    }

    // normal type generation
    writeTypeRef(th, typeRef.getTarget(), refAttName);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:49,代碼來源:XmlSchemaGenerator.java

示例5: print

import javax.activation.MimeType; //導入依賴的package包/類
@Override
public CharSequence print(V o) throws AccessorException {
    XMLSerializer w = XMLSerializer.getInstance();
    MimeType old = w.setExpectedMimeType(expectedMimeType);
    try {
        return core.print(o);
    } finally {
        w.setExpectedMimeType(old);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:MimeTypedTransducer.java

示例6: writeText

import javax.activation.MimeType; //導入依賴的package包/類
@Override
public void writeText(XMLSerializer w, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException {
    MimeType old = w.setExpectedMimeType(expectedMimeType);
    try {
        core.writeText(w, o, fieldName);
    } finally {
        w.setExpectedMimeType(old);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:MimeTypedTransducer.java

示例7: writeLeafElement

import javax.activation.MimeType; //導入依賴的package包/類
@Override
public void writeLeafElement(XMLSerializer w, Name tagName, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException {
    MimeType old = w.setExpectedMimeType(expectedMimeType);
    try {
        core.writeLeafElement(w, tagName, o, fieldName);
    } finally {
        w.setExpectedMimeType(old);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:MimeTypedTransducer.java

示例8: DataSourceSource

import javax.activation.MimeType; //導入依賴的package包/類
public DataSourceSource(DataSource source) throws MimeTypeParseException {
    this.source = source;

    String ct = source.getContentType();
    if(ct==null) {
        charset = null;
    } else {
        MimeType mimeType = new MimeType(ct);
        this.charset = mimeType.getParameter("charset");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:DataSourceSource.java

示例9: getExpectedMimeType

import javax.activation.MimeType; //導入依賴的package包/類
public MimeType getExpectedMimeType() {
    for( Ref t : refs ) {
        MimeType mt = t.getExpectedMimeType();
        if(mt!=null)    return mt;
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:RawTypeSet.java

示例10: TypeUseImpl

import javax.activation.MimeType; //導入依賴的package包/類
public TypeUseImpl(CNonElement itemType, boolean collection, ID id, MimeType expectedMimeType, CAdapter adapter) {
    this.coreType = itemType;
    this.collection = collection;
    this.id = id;
    this.expectedMimeType = expectedMimeType;
    this.adapter = adapter;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:TypeUseImpl.java

示例11: makeMimeTyped

import javax.activation.MimeType; //導入依賴的package包/類
public static TypeUse makeMimeTyped( TypeUse t, MimeType mt ) {
    if(t.getExpectedMimeType()!=null)
        // I don't think we let users tweak the idness, so
        // this error must indicate an inconsistency within the RI/spec.
        throw new IllegalStateException();
    return new TypeUseImpl( t.getInfo(), t.isCollection(), t.idUse(), mt, t.getAdapterUse() );
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:TypeUseFactory.java

示例12: CElementPropertyInfo

import javax.activation.MimeType; //導入依賴的package包/類
public CElementPropertyInfo(String name, CollectionMode collection, ID id, MimeType expectedMimeType, XSComponent source,
                            CCustomizations customizations, Locator locator, boolean required) {
    super(name, collection.col, source, customizations, locator);
    this.required = required;
    this.id = id;
    this.expectedMimeType = expectedMimeType;
    this.isValueList = collection.val;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:CElementPropertyInfo.java


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