File tree 4 files changed +63
-2
lines changed
main/java/org/codehaus/plexus/components/io/resources
test/java/org/codehaus/plexus/components/io/filemappers
4 files changed +63
-2
lines changed Original file line number Diff line number Diff line change
1
+ package org .codehaus .plexus .components .io .resources ;
2
+
3
+ import java .nio .charset .Charset ;
4
+
5
+ /*
6
+ * Copyright 2014 The Codehaus Foundation.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ /**
22
+ * Implemented by plexus io resources that support some kind of encoding notion
23
+ */
24
+ public interface EncodingSupported
25
+ {
26
+ /**
27
+ * Supplies the encoding to be used for decoding filenames/paths
28
+ * @param charset The charset to use
29
+ */
30
+ public void setEncoding (Charset charset );
31
+ }
Original file line number Diff line number Diff line change 1
1
package org .codehaus .plexus .components .io .resources ;
2
+ /*
3
+ * Copyright 2007 The Codehaus Foundation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
2
17
3
18
/**
4
19
* @author Kristian Rosenvold
Original file line number Diff line number Diff line change 26
26
import org .codehaus .plexus .components .io .functions .ResourceAttributeSupplier ;
27
27
import org .codehaus .plexus .components .io .resources .AbstractPlexusIoResourceCollection ;
28
28
import org .codehaus .plexus .components .io .resources .AbstractPlexusIoResourceCollectionWithAttributes ;
29
+ import org .codehaus .plexus .components .io .resources .EncodingSupported ;
29
30
import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
30
31
import org .codehaus .plexus .components .io .resources .PlexusIoResourceCollection ;
31
32
import org .codehaus .plexus .components .io .resources .Stream ;
32
33
33
34
import javax .annotation .Nonnull ;
34
35
import java .io .IOException ;
36
+ import java .nio .charset .Charset ;
35
37
import java .util .Iterator ;
36
38
37
39
/**
38
40
* Implementation of {@link PlexusIoResourceCollection} for an archives contents.
39
41
*/
40
42
public class PlexusIoProxyResourceCollection
41
- extends AbstractPlexusIoResourceCollectionWithAttributes
43
+ extends AbstractPlexusIoResourceCollectionWithAttributes implements EncodingSupported
42
44
{
43
45
private PlexusIoResourceCollection src ;
44
46
@@ -203,4 +205,11 @@ public long getLastModified()
203
205
{
204
206
return src .getLastModified ();
205
207
}
208
+
209
+ public void setEncoding ( Charset charset )
210
+ {
211
+ if (src instanceof EncodingSupported ){
212
+ ((EncodingSupported )src ).setEncoding ( charset );
213
+ }
214
+ }
206
215
}
Original file line number Diff line number Diff line change 16
16
* limitations under the License.
17
17
*/
18
18
19
+ import java .io .Closeable ;
19
20
import java .io .File ;
20
21
import java .io .FileInputStream ;
21
22
import java .io .FileOutputStream ;
@@ -158,7 +159,8 @@ private void testPlexusIoResourceCollection( PlexusIoResourceCollection plexusIo
158
159
boolean yPathSeen = false ;
159
160
boolean aFileSeen = false ;
160
161
boolean bFileSeen = false ;
161
- for ( Iterator iter = plexusIoResourceCollection .getResources (); iter .hasNext (); )
162
+ Iterator iter = plexusIoResourceCollection .getResources ();
163
+ while ( iter .hasNext () )
162
164
{
163
165
PlexusIoResource res = (PlexusIoResource ) iter .next ();
164
166
final String resName = res .getName ().replace ( File .separatorChar , '/' );
@@ -208,6 +210,10 @@ else if ( B_PATH.equals( resName ) )
208
210
209
211
assertTrue ( aFileSeen );
210
212
assertTrue ( bFileSeen );
213
+ if (iter instanceof Closeable )
214
+ {
215
+ ( (Closeable ) iter ).close ();
216
+ }
211
217
}
212
218
213
219
private void testFileResourceCollection ( PlexusIoFileResourceCollection resourceCollection )
You can’t perform that action at this time.
0 commit comments