Statistics
| Revision:

gvsig-educa / org.gvsig.educa.portableview / trunk / org.gvsig.educa.portableview / org.gvsig.educa.portableview.lib / org.gvsig.educa.portableview.lib.api / src / main / java / org / gvsig / educa / portableview / PortableViewManager.java @ 256

History | View | Annotate | Download (6.69 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22
package org.gvsig.educa.portableview;
23

    
24
import java.io.File;
25
import java.io.IOException;
26
import java.util.List;
27

    
28
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
29
import org.gvsig.educa.portableview.compilation.PortableViewCompiler;
30
import org.gvsig.educa.portableview.map.CantLoadContextException;
31
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException;
32
import org.gvsig.educa.portableview.map.PortableView;
33
import org.gvsig.educa.portableview.map.PortableViewInformation;
34
import org.gvsig.tools.dispose.Disposable;
35

    
36
/**
37
 * Library Manager.
38
 * </p>
39
 * Expose main library's functionalities:
40
 * <ul>
41
 * <li>Set default folders configuration</li>
42
 * <li>Get installed <i>Portable View</i></li>
43
 * <li>Identify and get a <i>Portable View</i> from a file</li>
44
 * <li>Create a new {@link PortableViewCompilation} instance</li>
45
 * <li>Create a new {@link PortableViewCompiler} instance</li>
46
 * </ul>
47
 *
48
 * @author gvSIG team
49
 * @version $Id$
50
 */
51
public interface PortableViewManager extends Disposable {
52

    
53
    /**
54
     * Gets default folder to locate installed <i>Portable View</i>
55
     *
56
     * @return default installation folder
57
     */
58
    String getInstallationMapFolder();
59

    
60
    /**
61
     * Sets default folder to locate installed <i>Portable View</i>
62
     *
63
     * @param folder
64
     * @throws IllegalArgumentException
65
     *             if <code>folder</code> is a file or can't read or not exists
66
     */
67
    void setInstallationMapFolder(String folder);
68

    
69
    /**
70
     * Gets the folder to use to <i>open</i> any <i>Portable
71
     * View</i> before access to the information contained in it.
72
     *
73
     * @return temporal folder
74
     */
75
    String getTemporalFolder();
76

    
77
    /**
78
     * Sets the folder to use to <i>open</i> any <i>Portable View</i>
79
     *
80
     * @param folder
81
     * @throws IllegalArgumentException
82
     *             if <code>folder</code> is a file or can't write
83
     */
84
    void setTemporalFolder(String folder);
85

    
86
    /**
87
     * Clear all data in temporal folder
88
     */
89
    void cleanAllTemporalData();
90

    
91
    /**
92
     * Returns all <i>Portable View</i> installed
93
     * </p>
94
     * Uses installation folder to locate them
95
     *
96
     * @return All <i>Portable View></i> installed
97
     */
98
    List<PortableView> getInstalledMaps();
99

    
100
    /**
101
     * Returns all <i>Portable View</i> installed into the specified folder
102
     * </p>
103
     * Uses installation folder to locate them
104
     *
105
     * @param folder
106
     *            to analyze
107
     * @return All <i>Portable View></i> installed
108
     * @throws IllegalArgumentException
109
     *             if folder is not valid (a readable folder)
110
     */
111
    List<PortableView> getInstalledMaps(String folder);
112

    
113
    /**
114
     * Gets a {@link PortableView} from a file
115
     * </p>
116
     *
117
     * @param file
118
     * @return the <i>Portable View</i>
119
     * @throws InvalidPortableViewFormatException
120
     */
121
    PortableView getMapFromFile(File file)
122
        throws InvalidPortableViewFormatException;
123

    
124
    /**
125
     * Gets a {@link PortableView} from intalledMaps
126
     * by its id
127
     * </p>
128
     *
129
     * @param mapid
130
     *            PortableView id
131
     * @return the <i>Portable View</i>
132
     */
133
    PortableView getMapById(String mapId);
134

    
135
    /**
136
     * Informs if a file is a valid <i>Portable View</i> file
137
     *
138
     * @param file
139
     * @return
140
     */
141
    boolean isMap(File file);
142

    
143
    /**
144
     * Informs if a folder is a valid <i>Portable View</i> installed folder
145
     *
146
     * @param file
147
     * @return
148
     */
149
    boolean isAPortableViewIntalledFolder(File folder);
150

    
151
    /**
152
     * Creates a new instance of a {@link PortableViewCompilation}
153
     *
154
     * @return
155
     */
156
    PortableViewCompilation createCompilationInstance();
157

    
158
    /**
159
     * Creates a new instance of a {@link PortableViewCompilation} based on
160
     * values <code>map</code>
161
     *
162
     * @param map
163
     *            to use as template
164
     * @return
165
     * @throws IOException
166
     * @throws CantLoadContextException
167
     * @throws InvalidPortableViewFormatException
168
     */
169
    PortableViewCompilation createCompilationInstanceFromMap(PortableView map)
170
        throws InvalidPortableViewFormatException, CantLoadContextException,
171
        IOException;
172

    
173
    /**
174
     * Create a new instance of a {@link PortableViewCompiler}
175
     *
176
     * @return
177
     */
178
    PortableViewCompiler createCompilerInstance();
179

    
180
    /**
181
     * Generates the base name for a PortableView file using its info data
182
     *
183
     * @param info
184
     * @return
185
     */
186
    String getBaseFileNameFromInfo(PortableViewInformation info);
187

    
188
    /**
189
     * Generates the base name for a PortableView file
190
     *
191
     * @param info
192
     * @return
193
     */
194
    String getBaseFileNameFromInfo(String id, String name, int version,
195
        int buildNumber);
196

    
197
    /**
198
     * Create a gvSIG package file (gvspkg) from a portableView
199
     *
200
     * @param mapId
201
     *            id of map to export
202
     * @param targetFolder
203
     *            where write package file
204
     * @return
205
     * @throws PortableViewException
206
     * @throws IOException
207
     */
208
    File generatePackageFile(String mapId, File targetFolder)
209
        throws PortableViewException, IOException;
210

    
211
    /**
212
     * Create a gvSIG package file (gvspkg) from a portableView installed folder
213
     *
214
     * @param portableViewIntallFolder
215
     *            folder of a installed PortableView
216
     * @param targetFolder
217
     *            where write package file
218
     * @return
219
     * @throws PortableViewException
220
     * @throws IOException
221
     */
222
    File generatePackageFile(File portableViewIntallFolder, File targetFolder)
223
        throws PortableViewException, IOException;
224

    
225
    /**
226
     * Returns the translation of a string.
227
     *
228
     * @param key
229
     *            String to translate
230
     * @return a String with the translation of the string passed by parameter
231
     */
232
    public String getTranslation(String key);
233
}