/** * Returns a Velocity Resource which is a Template for the given SQL. */ public Resource getResource(String resourceName, int resourceType, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception { synchronized (templateCache) { Template resource = templateCache.get(resourceName); if (resource == null) { resource = new Template(); resource.setRuntimeServices(rsvc); resource.setResourceLoader(this); resource.setName(resourceName); resource.setEncoding(encoding); resource.process(); templateCache.put(resourceName, resource); } return resource; } }
/** * Returns a Velocity Resource which is a Template for the given SQL. */ public Resource getResource(String resourceName, int resourceType, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception { synchronized (templateCache) { Template resource = (Template) templateCache.get(resourceName); if (resource == null) { resource = new Template(); resource.setRuntimeServices(rsvc); resource.setResourceLoader(this); resource.setName(resourceName); resource.setEncoding(encoding); resource.process(); templateCache.put(resourceName, resource); } return resource; } }
/** * Returns a Velocity Resource which is a Template for the given SQL. */ public Resource getResource(String resourceName, int resourceType, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception { synchronized (templateCache) { Template resource = (Template) templateCache.get(resourceName); if (resource == null) { resource = new Template(); resource.setRuntimeServices(rsvc); resource.setResourceLoader(this); resource.setName(resourceName); resource.setEncoding(encoding); resource.process(); templateCache.put(resourceName, resource); } return resource; } }
/** * Gets a velocity template from the given String. * * @param templateAsString * the template as string * @return the template * @throws ParseException * the parse exception */ public static Template getTemplate(final String templateAsString) throws ParseException { final RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices(); final StringReader reader = new StringReader(templateAsString); final SimpleNode node = runtimeServices.parse(reader, "Template name"); final Template template = new Template(); template.setRuntimeServices(runtimeServices); template.setData(node); template.initDocument(); template.setEncoding("UTF-8"); return template; }
template.setEncoding("utf-8"); } catch (ResourceNotFoundException rnfe) { System.err.println(rnfe.getMessage());
this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName());
this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName());
/** * Constructor based on a Velocity 'encoded' representation. * * @param templateRepresentation * The representation to 'decode'. * @param mediaType * The representation's media type. * @throws IOException * @throws ParseErrorException * @throws ResourceNotFoundException */ public TemplateRepresentation(Representation templateRepresentation, MediaType mediaType) throws ResourceNotFoundException, ParseErrorException, IOException { super(mediaType); this.engine = null; this.template = new Template(); CharacterSet charSet = (templateRepresentation.getCharacterSet() != null) ? templateRepresentation .getCharacterSet() : CharacterSet.DEFAULT; this.template.setEncoding(charSet.getName()); this.template.setLastModified((templateRepresentation .getModificationDate() == null) ? new Date().getTime() : templateRepresentation.getModificationDate().getTime()); this.template.setName("org.restlet.resource.representation"); this.template.setRuntimeServices(RuntimeSingleton.getRuntimeServices()); this.template.setResourceLoader(new RepresentationResourceLoader( templateRepresentation)); this.template.process(); this.templateName = null; }
this.template.setEncoding(charSet.getName());