3f9a7919aeaadf6135d148374669b62dcfa5132c
[utils] / system / spring / src / main / java / org / wamblee / system / spring / StringResource.java
1 /*
2  * Copyright 2007 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */ 
16 package org.wamblee.system.spring;
17
18 import java.io.ByteArrayInputStream;
19 import java.io.File;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.net.URL;
23
24 import org.springframework.core.io.Resource;
25
26 class StringResource implements Resource {
27         
28         private String _value; 
29         
30         public StringResource(String aValue) { 
31                 _value = aValue; 
32         }
33
34         @Override
35         public Resource createRelative(String aRelativePath) throws IOException {
36                 throw new IOException("No relative resource possible");
37         }
38
39         @Override
40         public boolean exists() {
41                 return false;
42         }
43
44         @Override
45         public String getDescription() {
46                 return "Properties of a spring component"; 
47         }
48
49         @Override
50         public File getFile() throws IOException {
51                 throw new IOException();
52         }
53
54         @Override
55         public String getFilename() {
56                 return "springcomponent.properties";
57         }
58
59         @Override
60         public URL getURL() throws IOException {
61                 throw new IOException();
62         }
63
64         @Override
65         public boolean isOpen() {
66                 return false;
67         }
68
69         @Override
70         public InputStream getInputStream() throws IOException {
71                 return new ByteArrayInputStream(_value.getBytes());
72         }
73
74 }