本文整理汇总了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;
}
示例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;
}