Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-mrsid-macosx / src / es / gva / cit / jmrsid / LTIMetadataRecord.java @ 9099

History | View | Annotate | Download (7.53 KB)

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

    
51
package es.gva.cit.jmrsid;
52

    
53

    
54

    
55
/**
56
 * Representa una entrada de LTIMetadataDatabase correspondiente a un metadato
57
 * 
58
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
59
 * @version 0.0
60
 * @link http://www.gvsig.gva.es
61
 */
62
public class LTIMetadataRecord extends JNIBase{
63
        
64
        public static final int LTI_METADATA_DATATYPE_INT = 0;
65
        public static final int LTI_METADATA_DATATYPE_FLOAT = 1;
66
        public static final int LTI_METADATA_DATATYPE_STRING = 2;
67
                
68
        private native String getTagNameNat(long cPtr);
69
        private native int isScalarNat(long cPtr);
70
        private native int isVectorNat(long cPtr);
71
        private native int isArrayNat(long cPtr);
72
        private native int getDataTypeNat(long cPtr);
73
        private native String getScalarDataNat(long cPtr);
74
        private native StringArray getVectorDataNat(long cPtr);
75
        private native StringArray getArrayDataNat(long cPtr);
76
        private native int getNumDimsNat(long cPtr);
77
        private native int[] getDimsNat(long cPtr);
78
        private native void FreeLTIMetadataRecordNat(long cPtr);
79
        
80
        
81
        /**
82
         * Destructor 
83
         */
84
        protected void finalize(){
85
                if(cPtr > 0)
86
                        FreeLTIMetadataRecordNat(cPtr);
87
        }
88
        
89
        public LTIMetadataRecord(){}
90
        
91
        /**
92
         * Constructor
93
         */
94
        public LTIMetadataRecord(long cPtr){
95
                
96
                super.cPtr=cPtr;
97
        }
98

    
99
        /**
100
         * Obtiene el nombre de la entrada
101
         * @throws MrSIDException
102
         * @return nombre de la entrada
103
         */
104
        public String getTagName()throws MrSIDException{
105
                
106
                if(cPtr <= 0)
107
                         throw new MrSIDException("Error en getTagName. La referencia al objeto no es valida.");
108

    
109
                String tagname = getTagNameNat(cPtr);
110
                                
111
                if(tagname==null)
112
                         throw new MrSIDException("No se ha devuelto un nombre de tag valido");
113
                 else return tagname;
114
        }
115
        
116
        /**
117
         * Dice si el metadato es escalar o no.
118
         * @throws MrSIDException
119
         * @return true si es escalar y false si no lo es
120
         */
121
        public boolean isScalar()throws MrSIDException{
122
                
123
                if(cPtr <= 0)
124
                         throw new MrSIDException("Error en getTagName. La referencia al objeto no es valida.");
125
                int res = isScalarNat(cPtr);
126
                
127
                if(res==1)return true;
128
                else return false;
129
                
130
        }
131
        
132
        /**
133
         * Dice si el metadato es vector o no.
134
         * @throws MrSIDException
135
         * @return true si es vector y false si no lo es
136
         */
137
        public boolean isVector()throws MrSIDException{
138
                if(cPtr <= 0)
139
                         throw new MrSIDException("Error en isVector. La referencia al objeto no es valida.");
140

    
141
                int res = isVectorNat(cPtr);
142
                
143
                if(res==1)return true;
144
                else return false;
145
                
146
        }
147
        
148
        /**
149
         * Dice si el metadato es array o no.
150
         * @throws MrSIDException
151
         * @return true si es array y false si no lo es
152
         */
153
        public boolean isArray()throws MrSIDException{
154
                if(cPtr <= 0)
155
                         throw new MrSIDException("Error en getTagName. La referencia al objeto no es valida.");
156

    
157
                int res = isArrayNat(cPtr);
158
                
159
                if(res==1)return true;
160
                else return false;
161
                
162
        }
163
        
164
        /**
165
         * Obtiene el tipo de datos
166
         * @throws MrSIDException
167
         * @return tipo de datos 
168
         *<UL>    
169
         *<LI>LTI_METADATA_DATATYPE_INVALID 0</LI> 
170
         *<LI>LTI_METADATA_DATATYPE_UINT8 1</LI>
171
         *<LI>LTI_METADATA_DATATYPE_SINT8 2</LI>
172
         *<LI>LTI_METADATA_DATATYPE_UINT16 3</LI>
173
         *<LI>LTI_METADATA_DATATYPE_SINT16 4</LI>
174
         *<LI>LTI_METADATA_DATATYPE_UINT32 5</LI>
175
         *<LI>LTI_METADATA_DATATYPE_SINT32 6</LI>
176
         *<LI>LTI_METADATA_DATATYPE_UINT64 7</LI>
177
         *<LI>LTI_METADATA_DATATYPE_SINT64 8</LI>
178
         *<LI>LTI_METADATA_DATATYPE_FLOAT32 9</LI>
179
         *<LI>LTI_METADATA_DATATYPE_FLOAT64 10</LI>
180
         *<LI>LTI_METADATA_DATATYPE_ASCII 11</LI>
181
         *</UL>
182
         * 
183
         */
184
        public int getDataType()throws MrSIDException{
185
                if(cPtr <= 0)
186
                         throw new MrSIDException("Error en getDataType. La referencia al objeto no es valida.");
187
                
188
                int res = getDataTypeNat(cPtr);
189
                
190
                if(res<0)
191
                        throw new MrSIDException("Error en getDataType. No se ha obtenido un tipo de datos valido");
192
                else return res;
193
        }
194
        
195
        /**
196
         * Obtiene el valor de un datos escalar en forma de String. La conversi?n a float, entero, ... 
197
         * si fuera necesario es a cargo del cliente  
198
         * @throws MrSIDException
199
         * @return dato escalar
200
         */
201
        public String getScalarData()throws MrSIDException{
202
                
203
                String datos=null;
204
                
205
                if(cPtr <= 0)
206
                         throw new MrSIDException("Error en getScalarData. La referencia al objeto no es valida.");
207
                
208
                datos = getScalarDataNat(cPtr);
209
                
210
                return datos;
211
        
212
        }
213
        
214
        /**
215
         * Obtiene el valor del metadato de tipo vector en forma de vector de strings
216
         * @throws MrSIDException
217
         * @return vector de strings con los valores del metadato
218
         */
219
        public String[] getVectorData()throws MrSIDException{
220
                if(cPtr <= 0)
221
                         throw new MrSIDException("Error en getVectorData. La referencia al objeto no es valida.");
222
                
223
                StringArray res = getVectorDataNat(cPtr);
224
                
225
                if(res!=null)return res.array;
226
                else return null;
227
        }
228
        
229
        /**
230
         * Obtiene el valor del metadato de tipo array en forma de vector de strings. Esta funci?n 
231
         * colocar? todas las dimensiones del array en forma de vector
232
         * @throws MrSIDException
233
         * @return vector de strings con los valores del metadato
234
         */
235
        public String[] getArrayData()throws MrSIDException{
236
                if(cPtr <= 0)
237
                         throw new MrSIDException("Error en getArrayData. La referencia al objeto no es valida.");
238

    
239
                StringArray res = getArrayDataNat(cPtr);
240
                
241
                if(res!=null)return res.array;
242
                else return null;
243
        }
244
        
245
        /**
246
         * Devuelve el n?mero de dimensiones del dataset
247
         * @throws MrSIDException
248
         * @return n?mero de dimensiones del dataset
249
         */
250
        
251
        public int getNumDims()throws MrSIDException{
252
                
253
                if(cPtr <= 0)
254
                         throw new MrSIDException("Error en getNumDims. La referencia al objeto no es valida.");
255
                
256
                int res = getNumDimsNat(cPtr);
257
                
258
                if(res < 0)
259
                         throw new MrSIDException("Error en getNumDims. El n?mero de dimensiones obtenido no es valido.");
260
                
261
                return res;
262
        }
263
        
264
        /**
265
         * Obtiene la longitud de cada dimensi?n del dataset
266
         * @throws MrSIDException
267
         * @return array de enteros con la dimension de cada longitud
268
         */
269
         public int[] getDims()throws MrSIDException{
270
                 
271
                 if(cPtr <= 0)
272
                         throw new MrSIDException("Error en getDims. La referencia al objeto no es valida.");
273
                 
274
                 int[] res =  getDimsNat(cPtr);
275
                 
276
                 if(res==null || res.length==0)
277
                         throw new MrSIDException("Error en getDims. No se ha podido obtener la longitud de las dimensiones.");
278
                 
279
                 return res;
280
         }
281

    
282
}