當前位置: 首頁>>代碼示例>>Java>>正文


Java Representation.setCharacterSet方法代碼示例

本文整理匯總了Java中org.restlet.representation.Representation.setCharacterSet方法的典型用法代碼示例。如果您正苦於以下問題:Java Representation.setCharacterSet方法的具體用法?Java Representation.setCharacterSet怎麽用?Java Representation.setCharacterSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.restlet.representation.Representation的用法示例。


在下文中一共展示了Representation.setCharacterSet方法的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.setCharacterSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。