01: /*
02: * Created on Nov 27, 2004
03: */
04: package net.sourceforge.orbroker.velocity;
05:
06: import java.io.ByteArrayInputStream;
07: import java.io.InputStream;
08:
09: import org.apache.commons.collections.ExtendedProperties;
10: import org.apache.velocity.exception.ResourceNotFoundException;
11: import org.apache.velocity.runtime.resource.Resource;
12: import org.apache.velocity.runtime.resource.loader.ResourceLoader;
13:
14: /**
15: * Resource loader that uses a String.
16: * @author Nils Kilden-Pedersen
17: */
18: public final class StringResourceLoader extends ResourceLoader {
19:
20: /**
21: * @inheritDoc
22: * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
23: */
24: public void init(ExtendedProperties configuration) {
25: return;
26: }
27:
28: /**
29: * @inheritDoc
30: * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#getResourceStream(java.lang.String)
31: */
32: public InputStream getResourceStream(String source)
33: throws ResourceNotFoundException {
34: return new ByteArrayInputStream(source.getBytes());
35: }
36:
37: /**
38: * @inheritDoc
39: * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#isSourceModified(org.apache.velocity.runtime.resource.Resource)
40: */
41: public boolean isSourceModified(Resource resource) {
42: return false;
43: }
44:
45: /**
46: * @inheritDoc
47: * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource)
48: */
49: public long getLastModified(Resource resource) {
50: return resource.getLastModified();
51: }
52:
53: }
|