本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}