当前位置: 首页>>代码示例>>Java>>正文


Java Variant.setMediaType方法代码示例

本文整理汇总了Java中org.restlet.representation.Variant.setMediaType方法的典型用法代码示例。如果您正苦于以下问题:Java Variant.setMediaType方法的具体用法?Java Variant.setMediaType怎么用?Java Variant.setMediaType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.representation.Variant的用法示例。


在下文中一共展示了Variant.setMediaType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
        Resource resource) throws IOException {
    Representation result = null;

    if (source instanceof GsonRepresentation) {
        result = (GsonRepresentation<?>) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.APPLICATION_JSON);
        }

        if (VARIANT_JSON.isCompatible(target)) {
            GsonRepresentation<Object> gsonRepresentation = create(source);
            result = gsonRepresentation;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:GsonConverter.java

示例2: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
        Resource resource) {
    Representation result = null;

    if (source instanceof JacksonRepresentation) {
        result = (JacksonRepresentation<?>) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.APPLICATION_JSON);
        }
        if (isCompatible(target)) {
            result = create(target.getMediaType(), source);
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:JacksonConverter.java

示例3: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation( Object source, Variant target, Resource resource )
{
    Representation result = null;

    if( source instanceof JsonRepresentation )
    {
        result = (JsonRepresentation<?>) source;
    }
    else
    {
        if( target.getMediaType() == null )
        {
            target.setMediaType( MediaType.APPLICATION_JSON );
        }
        if( isCompatible( target ) )
        {
            result = create( target.getMediaType(), source );
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:PolygeneConverter.java

示例4: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
		Resource resource) throws IOException {
	Representation result = null;

       if (source instanceof XMLRepresentation) {
           result = (XMLRepresentation<?>) source;
       } else {
           if (target.getMediaType() == null) {
               target.setMediaType(MediaType.APPLICATION_ALL_XML);
           }

           if (VARIANT_APPLICATION_ALL_XML.isCompatible(target) || VARIANT_APPLICATION_XML.isCompatible(target) ||VARIANT_TEXT_XML.isCompatible(target) ) {
           	
           	XMLRepresentation<Object> obixRepresentation = create(
                       target.getMediaType(), source, resource);
               result = obixRepresentation;
           }
       }

       return result;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:23,代码来源:XMLConverter.java

示例5: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
   public Representation toRepresentation(Object source, Variant target, Resource resource) throws IOException {
Representation result = null;

if (source instanceof JSonRepresentation) {
    result = (JSonRepresentation<?>) source;
} else {
    if (target.getMediaType() == null) {
	target.setMediaType(MediaType.APPLICATION_JSON);
    }

    if (VARIANT_JSON.isCompatible(target)) {

	JSonRepresentation<Object> obixRepresentation = create(target.getMediaType(), source, resource);
	result = obixRepresentation;
    }
}

return result;
   }
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:21,代码来源:JSonConverter.java

示例6: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Representation toRepresentation(Object source, Variant target, UniformResource resource) {
    Representation result = null;

    if (source instanceof XstreamRepresentation) {
        result = (XstreamRepresentation) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.TEXT_XML);
        }

        if (VARIANT_JSON.isCompatible(target)) {
            XstreamRepresentation<Object> xstreamRepresentation = create(target.getMediaType(), source);
            result = xstreamRepresentation;
        } else if (VARIANT_APPLICATION_ALL_XML.isCompatible(target) || VARIANT_APPLICATION_XML.isCompatible(target)
                || VARIANT_TEXT_XML.isCompatible(target)) {
            result = create(target.getMediaType(), source);
        }
    }

    return result;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:24,代码来源:XstreamConverter.java

示例7: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Representation toRepresentation(Object source, Variant target, UniformResource resource) {
    Representation result = null;

    if (source instanceof OxmRepresentation) {
        result = (OxmRepresentation) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.TEXT_XML);
        }

        if (VARIANT_APPLICATION_ALL_XML.isCompatible(target) || VARIANT_APPLICATION_XML.isCompatible(target)
                || VARIANT_TEXT_XML.isCompatible(target)) {
            result = create(target.getMediaType(), source);
        }
    }

    return result;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:21,代码来源:OxmConverter.java

示例8: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target, UniformResource resource) {
    Representation result = null;
    if (source instanceof JsonRepresentation) {
        result = (JsonRepresentation) source;
    } else {
        if (target.getMediaType() == null)
            target.setMediaType(MediaType.APPLICATION_JSON);
        if (VARIANT_JSON.isCompatible(target)) {
            JsonRepresentation representation = create(target.getMediaType(), source);
            result = representation;
        }
    }
    return result;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:16,代码来源:JsonConverter.java


注:本文中的org.restlet.representation.Variant.setMediaType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。