Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / folders / FoldersManager.java @ 1872

History | View | Annotate | Download (4.34 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.folders;
25

    
26
import java.io.File;
27
import java.io.IOException;
28
import java.util.Iterator;
29
import java.util.Map;
30

    
31

    
32
/**
33
 * This class allows to keep a registry of folders associating to each
34
 * folder a name, as well as to manage the location and access to the 
35
 * temporary files.
36
 * 
37
 * @author gvSIG association
38
 */
39
public interface FoldersManager extends Iterable<String> {
40

    
41
    /**
42
     * Return the file associated to the temporary folder.
43
     * The file can't exits.
44
     * 
45
     * @return the temporary folder. 
46
     */
47
    public File getTemporaryFolder();
48
    
49
    /**
50
     * Set the file associated to the temporary folder.
51
     * 
52
     * @param folder 
53
     */
54
    public void setTemporaryFolder(File folder);
55
    
56
    /**
57
     * Remove al files in the temporary folder.
58
     */
59
    public void cleanTemporaryFiles();
60
    
61
    /**
62
     * Force the creation of the temporary folder.
63
     * 
64
     * @return the file associated to the temporary folder
65
     */
66
    public File createTemporaryFolder();
67
    
68
    /**
69
     * Return a file with the specified relative path to the 
70
     * temporary folder.
71
     * The file will be deleted when the application exits. 
72
     * 
73
     * @param pathComponents
74
     * @return the requested absolute file in temporary folder.
75
     */
76
    public File getTemporaryFile(String... pathComponents);
77
    
78
    /**
79
     * Return a unique file with the specified relative path to the 
80
     * temporary folder. 
81
     * The base name of the file is modified to be unique.
82
     * The file will be deleted when the application exits. 
83
     * 
84
     * @param pathComponents
85
     * @return the requested absolute file in temporary folder.
86
     */
87
    public File getUniqueTemporaryFile(String... pathComponents);
88
    
89
    /**
90
     * Creates a temporary file with a the provided name and data. 
91
     * The file will be automatically deleted when the application exits. 
92
     * 
93
     * @param basename of the temporary file to create
94
     * @param data The data to store in the file
95
     * @return the File 
96
     * @throws java.io.IOException
97
     */
98
    public File createTemporaryFile(String basename, byte[] data) throws IOException ;
99

    
100
    public File createTemporaryFile(String basename, String data) throws IOException ;
101
    
102
    /**
103
     * Stores the file with the indicated identifier.
104
     * 
105
     * @param id
106
     * @param file 
107
     */
108
    public void set(String id, File file);
109
    
110
    /**
111
     * Retrieves the file associated with the indicated identifier.
112
     * If there is not a file associated with the identifier, return null.
113
     * 
114
     * @param id
115
     * @return 
116
     */
117
    public File get(String id);
118
   
119
    /**
120
     * Retrieves the file associated with the indicated identifier.
121
     * If there is no file associated with the identifier, return he default value.
122
     * 
123
     * @param id
124
     * @param defaultValue
125
     * @return 
126
     */
127
    public File get(String id, File defaultValue);
128
    
129
    public File getHome();
130
    
131
    /**
132
     * Returns an iterator over the identifiers of the stored files.
133
     * 
134
     * @return 
135
     */
136
    @Override
137
    public Iterator<String> iterator();
138
    
139
    /**
140
     * Returns true if there is no stored file.
141
     * 
142
     * @return 
143
     */
144
    public boolean isEmpty();
145

    
146
    public File getLastPath(String pathId, File defaultValue);
147
    
148
    public Iterator<Map.Entry<String,File>> lastPathsIterator();
149
    
150
    public void setLastPath(String pathId, File value);
151
}