Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.api / src / main / java / org / gvsig / fmap / dal / coverage / util / FileUtils.java @ 1859

History | View | Annotate | Download (6.31 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.fmap.dal.coverage.util;
23

    
24
import java.awt.geom.AffineTransform;
25
import java.io.File;
26
import java.io.FileNotFoundException;
27
import java.io.IOException;
28
import java.security.NoSuchAlgorithmException;
29

    
30
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
31

    
32

    
33
/**
34
 * Utilities for files, directories and file names 
35
 *
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public interface FileUtils {
39
        /**
40
         * Copia de ficheros
41
         * @param pathOrig Ruta de origen
42
         * @param pathDst Ruta de destino.
43
         */
44
        public void copyFile(String pathOrig, String pathDst) throws FileNotFoundException, IOException;
45

    
46
        /**
47
         * Crea un fichero de georeferenciaci?n (world file) para un dataset
48
         * determinado
49
         * @param fileName Nombre completo del fichero de raster
50
         * @param Extent
51
         * @param pxWidth Ancho en p?xeles
52
         * @param pxHeight Alto en p?xeles
53
         * @return
54
         * @throws IOException
55
         */
56
        public void createWorldFile(String fileName, Extent ext, int pxWidth, int pxHeight) throws IOException;
57

    
58
        /**
59
         * Crea un fichero de georeferenciaci?n (world file) para un dataset
60
         * determinado
61
         * @param fileName Nombre completo del fichero de raster
62
         * @param AffineTransform
63
         * @param pxWidth Ancho en p?xeles
64
         * @param pxHeight Alto en p?xeles
65
         * @return
66
         * @throws IOException
67
         */
68
        public void createWorldFile(String fileName, AffineTransform at, int pxWidth, int pxHeight) throws IOException;
69

    
70
        /**
71
         * Formatea en forma de cadena un tama?o dado en bytes. El resultado ser? una
72
         * cadena con GB, MB, KB y B
73
         * @param size tama?o a formatear
74
         * @return cadena con la cantidad formateada
75
         */
76
        public String formatFileSize(long size);
77

    
78
        /**
79
         * Obtiene la extensi?n del fichero a partir de su nombre.
80
         * @param file Nombre o ruta del fichero
81
         * @return Cadena con la extensi?n que representa el tipo de fichero. Devuelve
82
         *         null si no tiene extension.
83
         */
84
        public String getExtensionFromFileName(String file);
85

    
86
        /**
87
         * Obtiene el nombre de fichero sin la extensi?n.
88
         * @param file Nombre o ruta del fichero
89
         * @return Cadena con la extensi?n que representa el tipo de fichero. Si no
90
         *         tiene extensi?n devuelve el mismo fichero de entrada
91
         */
92
        public String getNameWithoutExtension(String file);
93

    
94
        /**
95
         * Obtiene el nombre de fichero sin la extensi?n ni la ruta.
96
         * @param file Ruta del fichero
97
         * @return Cadena que representa el nombre del fichero sin extensi?n ni path de directorios
98
         */
99
        public String getFileNameFromCanonical(String file);
100
        
101
        /**
102
         * Obtiene el ?ltimo trozo de la cadena a partir de los caracteres que
103
         * coincidan con el patr?n. En caso de que el patr?n no exista en la cadena
104
         * devuelve esta completa
105
         * @param string
106
         * @param pattern
107
         * @return
108
         */
109
        public String getLastPart(String string, String pattern);
110

    
111
        /**
112
         * Obtiene la codificaci?n de un fichero XML
113
         * @param file Nombre del fichero XML
114
         * @return Codificaci?n
115
         */
116
        public String readFileEncoding(String file);
117

    
118
        /**
119
         * Obtiene el nombre del fichero RMF a partir del nombre del fichero. Si el
120
         * nombre del fichero tiene una extensi?n esta llamada sustituir? la extensi?n
121
         * existente por .rmf. Si el fichero pasado no tiene extensi?n esta llamada
122
         * a?adir? .rm al final.
123
         * @param fileName Nombre del fichero raster de origen
124
         * @return Nombre del fichero rmf asociado al raster.
125
         */
126
        public String getRMFNameFromFileName(String fileName);
127
        
128
        
129
        //******* Servicio de directorios temporales **************
130
        
131
        /**
132
         * Elimina los ficheros del directorio temporal. Realizamos esta acci?n al
133
         * levantar la librer?a.
134
         */
135
        public void cleanUpTempFiles();
136

    
137
        /**
138
         * Esta funci?n crea el directorio para temporales y devuelve el manejador
139
         * del directorio
140
         * @return
141
         */
142
        public File getTemporalFile();
143
        
144
        /**
145
         * Esta funci?n crea el directorio para temporales y devuelve la ruta de este
146
         * @return
147
         */
148
        public String getTemporalPath();
149
        
150
        /**
151
         * Gets the name of a raster file
152
         */
153
        public String getFormatedRasterFileName(String name);
154
        
155
        /**
156
         * Converts a string to MD5
157
         * @param path
158
         * @return
159
         * @throws NoSuchAlgorithmException
160
         */
161
        public String convertPathToMD5(String path) throws NoSuchAlgorithmException;
162

    
163
        
164
        //******* Servicio de nombres de capas ?nicos **************
165
        
166
        /**
167
         * La gesti?n de nombres ?nicos en la generaci?n de capas se lleva de forma
168
         * autom?tica. Cuando alguien crea una capa nueva, si esta no tiene nombre especifico,
169
         * obtiene su nombre mediante este m?todo. La siguiente vez que se llame dar? un nombre
170
         * distinto. El nombre de la capa ser? NewLayer_ seguido de un contador de actualizaci?n
171
         * autom?tica cada vez que se usa.
172
         * @return Nombre ?nico para la capa.
173
         */
174
        public String usesOnlyLayerName();
175

    
176
        /**
177
         * Obtiene el nombre ?nico de la siguiente capa sin actualizar el contador. Es
178
         * solo para consulta. La siguiente vez que se llama a getOnlyLayerName o usesOnlyLayerName
179
         * devolver? el mismo nomnbre.
180
         * @return Nombre ?nico para la capa.
181
         */
182
        public String getOnlyLayerName();
183

    
184
        /**
185
         * A?adir un listener a la lista de eventos
186
         * @param listener
187
         */
188
        public void addOnlyLayerNameListener(PropertyListener listener);
189

    
190
        /**
191
         * Elimina un listener de la lista de eventos
192
         * @param listener
193
         */
194
        public void removeOnlyLayerNameListener(PropertyListener listener);
195

    
196
        //******* End: Servicio de nombres de capas ?nicos **************
197
}