(no commit message)
[utils] / system / spring / src / main / java / org / wamblee / system / spring / StringResource.java
1 package org.wamblee.system.spring;
2
3 import java.io.ByteArrayInputStream;
4 import java.io.File;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.net.URL;
8
9 import org.springframework.core.io.Resource;
10
11 class StringResource implements Resource {
12         
13         private String _value; 
14         
15         public StringResource(String aValue) { 
16                 _value = aValue; 
17         }
18
19         @Override
20         public Resource createRelative(String aRelativePath) throws IOException {
21                 throw new IOException("No relative resource possible");
22         }
23
24         @Override
25         public boolean exists() {
26                 return false;
27         }
28
29         @Override
30         public String getDescription() {
31                 return "Properties of a spring component"; 
32         }
33
34         @Override
35         public File getFile() throws IOException {
36                 throw new IOException();
37         }
38
39         @Override
40         public String getFilename() {
41                 return "springcomponent.properties";
42         }
43
44         @Override
45         public URL getURL() throws IOException {
46                 throw new IOException();
47         }
48
49         @Override
50         public boolean isOpen() {
51                 return false;
52         }
53
54         @Override
55         public InputStream getInputStream() throws IOException {
56                 return new ByteArrayInputStream(_value.getBytes());
57         }
58
59 }