gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / resourcesstorage / ResourcesStorage.java @ 1993
History | View | Annotate | Download (2.16 KB)
1 |
package org.gvsig.tools.resourcesstorage; |
---|---|
2 |
|
3 |
import java.io.Closeable; |
4 |
import java.io.IOException; |
5 |
import java.io.InputStream; |
6 |
import java.io.OutputStream; |
7 |
import java.net.URI; |
8 |
import java.net.URL; |
9 |
import java.util.List; |
10 |
|
11 |
/**
|
12 |
*
|
13 |
* @author jjdelcerro
|
14 |
*/
|
15 |
@SuppressWarnings("UseSpecificCatch") |
16 |
public interface ResourcesStorage { |
17 |
|
18 |
public interface Resource extends Closeable { |
19 |
/**
|
20 |
* El recurso es de solo lectura, normalmente por que el tipo de recurso
|
21 |
* no permite escribir sobre el.
|
22 |
*
|
23 |
* Podria devolver false, y a pesar de ello no poder escribir, normalmente
|
24 |
* por carecer de permisos para ello.
|
25 |
*
|
26 |
* @return
|
27 |
*/
|
28 |
public boolean isReadOnly(); |
29 |
|
30 |
public URL getURL(); |
31 |
|
32 |
public boolean exists(); |
33 |
|
34 |
public InputStream asInputStream() throws IOException; |
35 |
|
36 |
public OutputStream asOutputStream() throws IOException; |
37 |
|
38 |
@Override
|
39 |
public void close(); |
40 |
} |
41 |
|
42 |
public static final ResourcesStorage EMPTY_RESOURCESSTORAGE = new EmptyResourcesStorage(); |
43 |
|
44 |
public static ResourcesStorage createFilesResourcesStorage(String pathName) { |
45 |
return new FilesResourcesStorage(pathName); |
46 |
} |
47 |
|
48 |
public static MultiResourcesStorage createMultiResourcesStorage() { |
49 |
return new BaseMultiResourcesStorage(); |
50 |
} |
51 |
|
52 |
public static Resource createResource(URL url) { |
53 |
try {
|
54 |
return new URLResource(url); |
55 |
} catch (Exception ex) { |
56 |
return null; |
57 |
} |
58 |
} |
59 |
|
60 |
public static Resource createResource(URI uri) { |
61 |
try {
|
62 |
return new URLResource(uri.toURL()); |
63 |
} catch (Exception ex) { |
64 |
return null; |
65 |
} |
66 |
} |
67 |
|
68 |
public String getSeparator(); |
69 |
|
70 |
public Resource getResource(String resourceName); |
71 |
|
72 |
public List<Resource> getResources(String resourceName); |
73 |
|
74 |
public Resource getLocalizedResource(String resourceName); |
75 |
|
76 |
public List<Resource> getLocalizedResources(String resourceName); |
77 |
|
78 |
public boolean isEmpty(); |
79 |
|
80 |
public boolean isReadOnly(); |
81 |
|
82 |
public boolean exists(String resourceName); |
83 |
} |