1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jci.readers;
19
20 import java.util.Map;
21 import java.util.HashMap;
22
23
24
25
26
27
28 public class MemoryResourceReader implements ResourceReader {
29
30 private Map<String, byte[]> resources = null;
31
32 public boolean isAvailable( final String pResourceName ) {
33 if (resources == null) {
34 return false;
35 }
36
37 return resources.containsKey(pResourceName);
38 }
39
40 public void add( final String pResourceName, final byte[] pContent ) {
41 if (resources == null) {
42 resources = new HashMap<String, byte[]>();
43 }
44
45 resources.put(pResourceName, pContent);
46 }
47
48 public void remove( final String pResourceName ) {
49 if (resources != null) {
50 resources.remove(pResourceName);
51 }
52 }
53
54
55 public byte[] getBytes( final String pResourceName ) {
56 return resources.get(pResourceName);
57 }
58
59
60
61
62 @Deprecated
63 public String[] list() {
64 if (resources == null) {
65 return new String[0];
66 }
67 return resources.keySet().toArray(new String[resources.size()]);
68 }
69 }