當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。