/** * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String, java.lang.String) * @since 1.6 */ public void putStringResource(final String name, final String body, final String encoding) { resources.put(name, new StringResource(body, encoding)); }
/** * convenience constructor; sets body to 'body' and sets lastModified to now * @param body */ public StringResource(final String body, final String encoding) { setBody(body); setEncoding(encoding); }
/** * Get an InputStream so that the Runtime can build a template with it. * * @param name name of template to get. * @return InputStream containing the template. * @throws ResourceNotFoundException Ff template not found in the RepositoryFactory. */ public InputStream getResourceStream(final String name) throws ResourceNotFoundException { if (StringUtils.isEmpty(name)) { throw new ResourceNotFoundException("No template name provided"); } StringResource resource = this.repository.getStringResource(name); if (resource == null) { throw new ResourceNotFoundException("Could not locate resource '" + name + "'"); } byte[] byteArray = null; try { byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); } catch (UnsupportedEncodingException ue) { throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue); } }
/** * @see ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource) */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
repo.putStringResource("alert_template", templateString); Assert.assertEquals(templateString, repo.getStringResource("alert_template").getBody());
byteArray = resource.getBody().getBytes(resource.getEncoding()); rawStream = new ByteArrayInputStream(byteArray); return new InputStreamReader(rawStream, resource.getEncoding()); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
/** * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource) */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
/** {@inheritDoc} */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
/** * convenience constructor; sets body to 'body' and sets lastModified to now * @param body */ public StringResource(final String body, final String encoding) { setBody(body); setEncoding(encoding); }
/** * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String, java.lang.String) * @since 1.6 */ public void putStringResource(final String name, final String body, final String encoding) { resources.put(name, new StringResource(body, encoding)); }
byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
/** * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource) */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
/** * convenience constructor; sets body to 'body' and sets lastModified to now * @param body */ public StringResource(final String body, final String encoding) { setBody(body); setEncoding(encoding); }
/** * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String, java.lang.String) * @since 1.6 */ public void putStringResource(final String name, final String body, final String encoding) { resources.put(name, new StringResource(body, encoding)); }
/** {@inheritDoc} */ public boolean isSourceModified(final Resource resource) { StringResource original = null; boolean result = true; original = this.repository.getStringResource(resource.getName()); if (original != null) { result = original.getLastModified() != resource.getLastModified(); } return result; }
/** * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String) */ public void putStringResource(final String name, final String body) { resources.put(name, new StringResource(body, getEncoding())); }
/** * @see ResourceLoader#isSourceModified(org.apache.velocity.runtime.resource.Resource) */ public boolean isSourceModified(final Resource resource) { StringResource original = null; boolean result = true; original = this.repository.getStringResource(resource.getName()); if (original != null) { result = original.getLastModified() != resource.getLastModified(); } return result; }
/** * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String) */ public void putStringResource(final String name, final String body) { resources.put(name, new StringResource(body, getEncoding())); }
/** * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#isSourceModified(org.apache.velocity.runtime.resource.Resource) */ public boolean isSourceModified(final Resource resource) { StringResource original = null; boolean result = true; original = this.repository.getStringResource(resource.getName()); if (original != null) { result = original.getLastModified() != resource.getLastModified(); } return result; }