@Override public CharacterSet getCharacterSet() { return getWrappedRepresentation().getCharacterSet(); }
/** * Converts the representation to a string value. Be careful when using this * method as the conversion of large content to a string fully stored in * memory can result in OutOfMemoryErrors being thrown. * * @return The representation as a string value. */ public String getText() throws IOException { String result = null; if (isAvailable()) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); write(baos); if (getCharacterSet() != null) { result = baos.toString(getCharacterSet().getName()); } else { result = baos.toString(); } } return result; }
/** * Returns a FreeMarker template from a representation and a configuration. * * @param templateRepresentation * The template representation. * @param config * The FreeMarker configuration. * @return The template or null if not found. */ private static Template getTemplate(Representation templateRepresentation, Configuration config) { 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()); } else { return new Template("template", templateRepresentation .getReader(), config, CharacterSet.UTF_8.getName()); } } catch (IOException e) { Context.getCurrentLogger().warning( "Unable to get the template from the representation " + templateRepresentation.getIdentifier() + ". Error message: " + e.getMessage()); return null; } }
this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName()); this.template.setLastModified((templateRepresentation .getModificationDate() == null) ? new Date().getTime()
this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName()); this.template.setLastModified(templateRepresentation .getModificationDate().getTime());
} else if (variableName.equals("ecs")) { if ((this.request.getEntity() != null) && (this.request.getEntity().getCharacterSet() != null)) { result = this.request.getEntity().getCharacterSet() .getName(); if (variableName.equals("ECS")) { if ((this.response.getEntity() != null) && (this.response.getEntity().getCharacterSet() != null)) { result = this.response.getEntity() .getCharacterSet().getName();