source code formatting.
[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 org.springframework.core.io.Resource;
19
20 import java.io.ByteArrayInputStream;
21 import java.io.File;
22 import java.io.IOException;
23 import java.io.InputStream;
24
25 import java.net.URL;
26
27
28 /**
29  * DOCUMENT ME!
30  *
31  * @author $author$
32  * @version $Revision$
33  */
34 class StringResource implements Resource {
35     /**
36      * DOCUMENT ME!
37      */
38     private String _value;
39
40 /**
41      * Creates a new StringResource object.
42      *
43      * @param aValue DOCUMENT ME!
44      */
45     public StringResource(String aValue) {
46         _value = aValue;
47     }
48
49     /**
50      * DOCUMENT ME!
51      *
52      * @param aRelativePath DOCUMENT ME!
53      *
54      * @return DOCUMENT ME!
55      *
56      * @throws IOException DOCUMENT ME!
57      */
58     @Override
59     public Resource createRelative(String aRelativePath)
60         throws IOException {
61         throw new IOException("No relative resource possible");
62     }
63
64     /**
65      * DOCUMENT ME!
66      *
67      * @return DOCUMENT ME!
68      */
69     @Override
70     public boolean exists() {
71         return false;
72     }
73
74     /**
75      * DOCUMENT ME!
76      *
77      * @return DOCUMENT ME!
78      */
79     @Override
80     public String getDescription() {
81         return "Properties of a spring component";
82     }
83
84     /**
85      * DOCUMENT ME!
86      *
87      * @return DOCUMENT ME!
88      *
89      * @throws IOException DOCUMENT ME!
90      */
91     @Override
92     public File getFile() throws IOException {
93         throw new IOException();
94     }
95
96     /**
97      * DOCUMENT ME!
98      *
99      * @return DOCUMENT ME!
100      */
101     @Override
102     public String getFilename() {
103         return "springcomponent.properties";
104     }
105
106     /**
107      * DOCUMENT ME!
108      *
109      * @return DOCUMENT ME!
110      *
111      * @throws IOException DOCUMENT ME!
112      */
113     @Override
114     public URL getURL() throws IOException {
115         throw new IOException();
116     }
117
118     /**
119      * DOCUMENT ME!
120      *
121      * @return DOCUMENT ME!
122      */
123     @Override
124     public boolean isOpen() {
125         return false;
126     }
127
128     /**
129      * DOCUMENT ME!
130      *
131      * @return DOCUMENT ME!
132      *
133      * @throws IOException DOCUMENT ME!
134      */
135     @Override
136     public InputStream getInputStream() throws IOException {
137         return new ByteArrayInputStream(_value.getBytes());
138     }
139 }