Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1014 / extensions / extRasterTools / src / org / gvsig / rasterTools / saveRaster / util / DriverProperties.java @ 13593

History | View | Annotate | Download (3.67 KB)

1
/*
2
 * Created on 17-feb-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package org.gvsig.rasterTools.saveRaster.util;
48

    
49
import org.cresques.io.GeoRasterWriter;
50

    
51
/**
52
 * Clase que representa a las propiedades que se seleccionan de cada driver.
53
 * Inicialmente se resetea el array driversProps a null. Cada elemento de este
54
 * array representa una extensi?n de fichero soportada. Cuando se modifica
55
 * las propiedades para una determinada extensi?n de un driver estas se asignan
56
 * a su entrada del vector driversExtensionProps y desde aqu? son leidas para
57
 * ser restauradas en caso de volver el cuadro de dialogo de propiedades.
58
 *  
59
 * @author Nacho Brodin (brodin_ign@gva.es)
60
 *
61
 */
62
public class DriverProperties{
63
                
64
        private String[][]                                driversExtensionProps = null;
65
        private String[]                                driversExtension = null;
66
                
67
        public DriverProperties(){
68
                        
69
                driversExtensionProps = new String[GeoRasterWriter.getNDrivers()][];
70
                for(int i=0;i<GeoRasterWriter.getNDrivers();i++)
71
                        driversExtensionProps[i] = null;
72
                driversExtension = GeoRasterWriter.getDriversExtensions();
73
                        
74
        }
75
                
76
        /**
77
         * Asigna un vector de propiedades de driver de escritura.
78
         * @param ext        extensi?n del driver.
79
         * @param props        propiedades.
80
         */
81
        public void setProperties(String ext, String[] props){
82
                for(int i=0;i<driversExtension.length;i++){
83
                        if(ext.equals(driversExtension[i])){
84
                                driversExtensionProps[i] = props;
85
                        }
86
                }
87
        }
88
                
89
        /**
90
         * Obtiene un vector de propiedades de driver de escritura.
91
         * @param ext        extensi?n del driver.
92
         * @return        propiedades.
93
         */
94
        public String[] getProperties(String ext){
95
                for(int i=0;i<driversExtension.length;i++){
96
                        if(ext.equals(driversExtension[i])){
97
                                return driversExtensionProps[i];
98
                        }
99
                }
100
                return null;
101
        }
102
        
103
        /**
104
         * Para una extensi?n de fichero determinada obtiene el valor de una propiedad si existe este.
105
         * La extensi?n solicitadad deber? estar registrada
106
         * @param extension Extensi?n del fichero.
107
         * @param property Propiedad a recuperar.
108
         * @return Valor de la propiedad o null en caso de que la extensi?n de fichero no exista o la propiedad
109
         * no se encuentre.
110
         */
111
        public String getValue(String extension, String property) {
112
                String[] props = getProperties(extension);
113
                if(props != null){
114
                        for (int i = 0; i < props.length; i++) {
115
                                if(props[i].startsWith(property + "="))
116
                                        return props[i].substring(props[i].lastIndexOf("=") + 1, props[i].length());
117
                        }
118
                }
119
                return null;
120
        }
121
                
122
}