本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例4: ContentType
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param representation
* The representation.
*/
public ContentType(Representation representation) {
this(representation.getMediaType(), representation.getCharacterSet());
}