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


Java Variant.getMediaType方法代码示例

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


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

示例1: toRepresentation

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

    if (source instanceof TemplateResolution) {
        Locale locale = getLocale(resource);

        TemplateRepresentation tr = new TemplateRepresentation(
                ((TemplateResolution) source).getTemplateResource().getBaseName(), locale,
                target.getMediaType());
        tr.setDataModel(resource.getRequest(), resource.getResponse());
        return tr;
    }

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

示例2: 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

示例3: 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

示例4: getObjectClasses

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public List<Class<?>> getObjectClasses(Variant source) {
    List<Class<?>> result = null;
    result = addObjectClass(result, String.class);
    result = addObjectClass(result, InputStream.class);
    result = addObjectClass(result, Reader.class);

    if (source.getMediaType() != null) {
        MediaType mediaType = source.getMediaType();

        if ((ObjectRepresentation.VARIANT_OBJECT_BINARY_SUPPORTED && MediaType.APPLICATION_JAVA_OBJECT
                .equals(mediaType))
                || (ObjectRepresentation.VARIANT_OBJECT_XML_SUPPORTED && MediaType.APPLICATION_JAVA_OBJECT_XML
                        .equals(mediaType))) {
            result = addObjectClass(result, Object.class);
        } else if (MediaType.APPLICATION_WWW_FORM.equals(mediaType)) {
            result = addObjectClass(result, Form.class);
        }
    }

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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: getIndexRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
public Representation getIndexRepresentation(Variant variant, ReferenceList indexContent) {

        MediaType mediaType = variant.getMediaType();

        if (APPLICATION_JSON.isCompatible(mediaType)) {
            return getJsonRepresentation(indexContent);
        } else if (APPLICATION_XML.isCompatible(mediaType)) {
            return getXmlRepresentation(indexContent);
        } else if (TEXT_HTML.isCompatible(mediaType)) {
            Representation jsonRepr = getJsonRepresentation(indexContent);
            jsonRepr.setMediaType(TEXT_HTML);
            return jsonRepr;
        } else {
            return super.getIndexRepresentation(variant, indexContent);
        }
    }
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:17,代码来源:ResultsDirectory.java

示例11: checkMetadataConsistency

import org.restlet.representation.Variant; //导入方法依赖的package包/类
/**
 * Checks that the URI and the representation are compatible. The whole set
 * of metadata of the representation must be included in the set of those of
 * the URI
 * 
 * @param fileName
 *            The name of the resource
 * @param representation
 *            The provided representation.
 * @return True if the metadata of the representation are compatible with
 *         the metadata extracted from the filename
 */
private boolean checkMetadataConsistency(String fileName, Representation representation) {
    if (representation != null) {
        Variant var = new Variant();
        Entity.updateMetadata(fileName, var, false, getMetadataService());

        // "var" contains the theoretical correct metadata
        if (!var.getLanguages().isEmpty()
                && !representation.getLanguages().isEmpty()
                && !var.getLanguages().containsAll(representation.getLanguages())) {
            return false;
        }

        if ((var.getMediaType() != null)
                && (representation.getMediaType() != null)
                && !(var.getMediaType().includes(representation.getMediaType()))) {
            return false;
        }

        if (!var.getEncodings().isEmpty()
                && !representation.getEncodings().isEmpty()
                && !var.getEncodings().containsAll(representation.getEncodings())) {
            return false;
        }
    }
    return true;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:39,代码来源:FileClientHelper.java

示例12: toRepresentation

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

    if (source instanceof Template) {
        return new TemplateRepresentation((Template) source,
                new ResolverHashModel(Resolver.createResolver(
                        resource.getRequest(), resource.getResponse())),
                target.getMediaType());

    }

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

示例13: toRepresentation

import org.restlet.representation.Variant; //导入方法依赖的package包/类
@Override
public Representation toRepresentation(final Object source, final Variant target, Resource resource) throws IOException {
	return new OutputRepresentation(target.getMediaType()) {
		@Override
		public void write(OutputStream outputStream) throws IOException {
			CharacterSet characterSet = target.getCharacterSet();
			if (characterSet == null) {
				characterSet = CharacterSet.UTF_8;
			}
			writeFragment(outputStream, source, characterSet);
		}
	};
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:14,代码来源:AbstractConverter.java

示例14: toRepresentation

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

    if (source instanceof Template) {
        TemplateRepresentation tr = new TemplateRepresentation((Template) source, target.getMediaType());
        tr.setDataModel(resource.getRequest(), resource.getResponse());
        return tr;
    }
    return null;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:11,代码来源:VelocityConverter.java

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