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


Java Representation.getCharacterSet方法代码示例

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


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

示例1: getTemplate

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Returns a FreeMarker template from a representation and a configuration.
 * 
 * @param config
 *            The FreeMarker configuration.
 * @param templateRepresentation
 *            The template representation.
 * @return The template or null if not found.
 */
public static Template getTemplate(Configuration config,
        Representation templateRepresentation) {
    try {
        // Instantiate the template with the character set of the template
        // representation if it has been set, otherwise use UTF-8.
        if (templateRepresentation.getCharacterSet() != null) {
            return new Template("template",
                    templateRepresentation.getReader(), config,
                    templateRepresentation.getCharacterSet().getName());
        }

        return new Template("template", templateRepresentation.getReader(),
                config, CharacterSet.UTF_8.getName());
    } catch (IOException e) {
        Context.getCurrentLogger().warn(
                "Unable to get the template from the representation " + templateRepresentation.getLocationRef(), e);
        return null;
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:29,代码来源:TemplateRepresentation.java

示例2: FormReader

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Constructor.<br>
 * In case the representation does not define a character set, the UTF-8
 * character set is used.
 *
 * @param representation
 *            The web form content.
 * @throws IOException
 *             if the stream of the representation could not be opened.
 */
public FormReader(Representation representation) throws IOException {
    this.decoding = true;
    this.stream = representation.getStream();
    this.separator = '&';

    if (representation.getCharacterSet() != null) {
        this.characterSet = representation.getCharacterSet();
    } else {
        this.characterSet = CharacterSet.UTF_8;
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:22,代码来源:FormReader.java

示例3: FormReader

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Constructor.<br>
 * In case the representation does not define a character set, the UTF-8
 * character set is used.
 * 
 * @param representation
 *            The web form content.
 * @param decode
 *            Indicates if the parameters should be decoded using the given
 *            character set.
 * @throws IOException
 *             if the stream of the representation could not be opened.
 */
public FormReader(Representation representation, boolean decode)
        throws IOException {
    this.decode = decode;
    this.stream = representation.getStream();
    this.separator = '&';

    if (representation.getCharacterSet() != null) {
        this.characterSet = representation.getCharacterSet();
    } else {
        this.characterSet = CharacterSet.UTF_8;
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:26,代码来源:FormReader.java

示例4: ContentType

import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param representation
 *            The representation.
 */
public ContentType(Representation representation) {
    this(representation.getMediaType(), representation.getCharacterSet());
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:10,代码来源:ContentType.java


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