gvsig-raster / org.gvsig.raster.multifile / trunk / org.gvsig.raster.multifile / org.gvsig.raster.multifile.io / src / main / java / org / gvsig / raster / multifile / io / MultiFileFormat.java @ 2458
History | View | Annotate | Download (2.57 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.raster.multifile.io; |
23 |
|
24 |
import java.io.File; |
25 |
import java.io.IOException; |
26 |
import java.util.ArrayList; |
27 |
|
28 |
/**
|
29 |
* MultiFileFormat information
|
30 |
*
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
32 |
*/
|
33 |
public class MultiFileFormat { |
34 |
public ArrayList<File> fileList = new ArrayList<File>(); |
35 |
private String name = null; |
36 |
|
37 |
/**
|
38 |
* Gets the name of this serial
|
39 |
* @return
|
40 |
*/
|
41 |
public String getName() { |
42 |
return name;
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* Sets the name of this serie
|
47 |
* @param name
|
48 |
*/
|
49 |
public void setName(String name) { |
50 |
this.name = name;
|
51 |
} |
52 |
|
53 |
/**
|
54 |
* Gets the number of files of this serial
|
55 |
* @return
|
56 |
*/
|
57 |
public int getNumberOfFiles() { |
58 |
return fileList.size();
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* Gets the path of the file in the selected position
|
63 |
* @param file
|
64 |
* @return
|
65 |
*/
|
66 |
public String getPathToFile(int file) { |
67 |
return fileList.get(file).getAbsolutePath();
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* Adds a file to the list
|
72 |
* @param file
|
73 |
*/
|
74 |
public void addFile(File file) { |
75 |
fileList.add(file); |
76 |
} |
77 |
|
78 |
/**
|
79 |
* Cleans the list of files
|
80 |
*/
|
81 |
public void clean() { |
82 |
fileList.clear(); |
83 |
name = null;
|
84 |
} |
85 |
|
86 |
public static String saveMultiFileFormat(String fileName, String path, ArrayList<File> uriList) throws IOException { |
87 |
path = path + File.separator + fileName + ".mff"; |
88 |
|
89 |
MultiFileFormat format = new MultiFileFormat();
|
90 |
for (int i = 0; i < uriList.size(); i++) { |
91 |
format.addFile(uriList.get(i)); |
92 |
} |
93 |
format.setName(fileName); |
94 |
|
95 |
format.write(path); |
96 |
return path;
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Writes a MultiFileFormat to disk
|
101 |
* @param file
|
102 |
* @throws IOException
|
103 |
*/
|
104 |
public void write(String fileName) throws IOException { |
105 |
MultiFileFormatSerializer.write(this, fileName);
|
106 |
} |
107 |
} |