Java 类javax.activation.MimeType 实例源码

项目:OpenJSharp    文件:Util.java   
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;
    }
}
项目:openjdk-jdk10    文件:Util.java   
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;
    }
}
项目:openjdk9    文件:Util.java   
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;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Util.java   
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;
    }
}
项目:cuba    文件:LoginServiceController.java   
@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);
}
项目:Tundra.java    文件:MIMETypeHelper.java   
/**
 * 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;
}
项目:infobip-open-jdk-8    文件:Util.java   
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;
    }
}
项目:OpenJSharp    文件:XmlSchemaGenerator.java   
/**
 * 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);
}
项目:OpenJSharp    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:OpenJSharp    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:OpenJSharp    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:OpenJSharp    文件:DataSourceSource.java   
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");
    }
}
项目:OpenJSharp    文件:RawTypeSet.java   
public MimeType getExpectedMimeType() {
    for( Ref t : refs ) {
        MimeType mt = t.getExpectedMimeType();
        if(mt!=null)    return mt;
    }
    return null;
}
项目:OpenJSharp    文件:TypeUseImpl.java   
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;
}
项目:OpenJSharp    文件:TypeUseFactory.java   
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() );
}
项目:OpenJSharp    文件:CElementPropertyInfo.java   
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;
}
项目:openjdk-jdk10    文件:RawTypeSet.java   
public MimeType getExpectedMimeType() {
    for( Ref t : refs ) {
        MimeType mt = t.getExpectedMimeType();
        if(mt!=null)    return mt;
    }
    return null;
}
项目:openjdk-jdk10    文件:TypeUseImpl.java   
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;
}
项目:openjdk-jdk10    文件:TypeUseFactory.java   
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() );
}
项目:openjdk-jdk10    文件:CElementPropertyInfo.java   
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;
}
项目:openjdk-jdk10    文件:XmlSchemaGenerator.java   
/**
 * 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);
}
项目:openjdk-jdk10    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk-jdk10    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk-jdk10    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk-jdk10    文件:DataSourceSource.java   
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");
    }
}
项目:openjdk9    文件:RawTypeSet.java   
public MimeType getExpectedMimeType() {
    for( Ref t : refs ) {
        MimeType mt = t.getExpectedMimeType();
        if(mt!=null)    return mt;
    }
    return null;
}
项目:openjdk9    文件:TypeUseImpl.java   
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;
}
项目:openjdk9    文件:TypeUseFactory.java   
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() );
}
项目:openjdk9    文件:CElementPropertyInfo.java   
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;
}
项目:openjdk9    文件:XmlSchemaGenerator.java   
/**
 * 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);
}
项目:openjdk9    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk9    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk9    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:openjdk9    文件:DataSourceSource.java   
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");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:XmlSchemaGenerator.java   
/**
 * 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);
}
项目:lookaside_java-1.8.0-openjdk    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:MimeTypedTransducer.java   
@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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DataSourceSource.java   
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");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RawTypeSet.java   
public MimeType getExpectedMimeType() {
    for( Ref t : refs ) {
        MimeType mt = t.getExpectedMimeType();
        if(mt!=null)    return mt;
    }
    return null;
}