Statistics
| Revision:

root / trunk / libraries / libjni-mrsid / src / es / gva / cit / jmrsid / JNIBase.java @ 837

History | View | Annotate | Download (2.94 KB)

1
/**********************************************************************
2
 * $Id: JNIBase.java 837 2005-01-10 07:30:28Z igbrotru $
3
 *
4
 * Name:     JNIBase.java
5
 * Project:  JMRSID. Interfaz java to MrSID (Lizardtech).
6
 * Purpose:  Base class for classes that use JNI.
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/*Copyright (C) 2004  Nacho Brodin <brodin_ign@gva.es>
11

12
 This program is free software; you can redistribute it and/or
13
 modify it under the terms of the GNU General Public License
14
 as published by the Free Software Foundation; either version 2
15
 of the License, or (at your option) any later version.
16

17
 This program is distributed in the hope that it will be useful,
18
 but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 GNU General Public License for more details.
21

22
 You should have received a copy of the GNU General Public License
23
 along with this program; if not, write to the Free Software
24
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
 */
26

    
27

    
28
/**
29
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
30
 * @version 0.0
31
 * @link http://www.gvsig.gva.es
32
 */
33

    
34
package es.gva.cit.jmrsid;
35

    
36

    
37

    
38
public class JNIBase{
39
        
40
        protected long cPtr;
41
        
42
        private native int getIndexCountNat(long cPtr);
43
        private native int initializeNat(long cPtr);
44
        private native int getNumLevelsNat(long cPtr);
45
        private native int getWidthNat(long cPtr);
46
        private native int getHeightNat(long cPtr);
47
        private native int getStripHeightNat(long cPtr);
48
        private native int getNumBandsNat(long cPtr);
49
        private native int getColorSpaceNat(long cPtr);
50
        private native int getDataTypeNat(long cPtr);
51
        
52
        /**
53
         * Funci?n que sirve como base para funcionalidades de mrsid que admiten como par?metro un entero y devuelven un entero.
54
         * 
55
         * @throws MrSIDException.
56
         * @param msg1        Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio.
57
         * @param msg2        Mensaje de error que se muestra cuando el resultado de la llamada a la funci?n de gdal es menor o igual que 0.
58
         */
59
        
60
        protected int baseSimpleFunction(int n,String msg1,String msg2)throws MrSIDException{
61
                
62
                int res = 0;
63
                
64
                if(cPtr <= 0)
65
                         throw new MrSIDException(msg1);
66
                
67
                switch(n){
68
                        case 0: res = getIndexCountNat(cPtr);break;
69
                        case 1: res = initializeNat(cPtr);break;
70
                        case 2: res = getNumLevelsNat(cPtr);break;
71
                        case 3: res = getWidthNat(cPtr);break;
72
                        case 4: res = getHeightNat(cPtr);break;
73
                        case 5: res = getStripHeightNat(cPtr);break;
74
                        case 6: res = getNumBandsNat(cPtr);break;
75
                        case 7: res = getColorSpaceNat(cPtr);break;
76
                        case 8: res = getDataTypeNat(cPtr);break;
77
                }
78
                
79
                if(res<0)
80
                         throw new MrSIDException(msg2);
81
                 else return res;
82
        }
83
        
84
        /**
85
         * Devuelve el puntero a memoria del objeto en C.
86
         */
87

    
88
        public long getPtr(){
89
                return cPtr;
90
        }
91

    
92
                
93
        /**
94
         * Carga de la libreria jmrsid  
95
         */ 
96
        
97
        static{
98
                
99
                System.loadLibrary("jmrsid");
100
                
101
        }
102
                
103
}