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


Java Representation.setMediaType方法代码示例

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


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

示例1: transform

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Transforms a source XML representation by applying an XSLT transform
 * sheet to it.
 * 
 * @param source
 *            The source XML representation.
 * @return The generated result representation.
 */
public Representation transform(Representation source) {
    final Representation result = new TransformRepresentation(getContext(),
            source, getTransformSheet());

    if (this.resultLanguages != null) {
        result.getLanguages().addAll(getResultLanguages());
    }

    result.setCharacterSet(getResultCharacterSet());
    if (this.resultEncodings != null) {
        result.getEncodings().addAll(getResultEncodings());
    }

    result.setMediaType(getResultMediaType());
    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:25,代码来源:Transformer.java

示例2: toObject

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Converts a Representation into a regular Java object.
 * 
 * @param <T>
 *            The expected class of the Java object.
 * @param source
 *            The source representation to convert.
 * @param target
 *            The target class of the Java object.
 * @param resource
 *            The parent resource.
 * @return The converted Java object.
 * @throws IOException
 */
public <T> T toObject(Representation source, Class<T> target,
        Resource resource) throws IOException {
    T result = null;
    boolean loggable = (resource == null) ? true : resource.isLoggable();

    if ((source != null) && source.isAvailable() && (source.getSize() != 0)) {
        ConverterHelper ch = ConverterUtils.getBestHelper(source, target,
                resource);

        if (ch != null) {
            if (loggable
                    && Context.getCurrentLogger().isDebugEnabled()) {
                Context.getCurrentLogger().debug(
                        "The following converter was selected for the "
                                + source + " representation: " + ch);
            }

            result = ch.toObject(source, target, resource);

            if (result instanceof Representation) {
                Representation resultRepresentation = (Representation) result;

                // Copy the variant metadata
                resultRepresentation.setCharacterSet(source
                        .getCharacterSet());
                resultRepresentation.setMediaType(source.getMediaType());
                resultRepresentation.getEncodings().addAll(
                        source.getEncodings());
                resultRepresentation.getLanguages().addAll(
                        source.getLanguages());
            }
        } else {
            if (loggable) {
                Context.getCurrentLogger().warn(
                        "Unable to find a converter for this representation : "
                                + source);
            }
        }
    }

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


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