Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.daltransform.app / org.gvsig.daltransform.app.join / src / main / java / org / gvsig / app / join / utils / TransformUtils.java @ 40558

History | View | Annotate | Download (2.32 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.join.utils;
25

    
26
import java.util.ArrayList;
27

    
28
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
29
import org.gvsig.fmap.dal.feature.FeatureType;
30
import org.gvsig.tools.dataTypes.DataTypes;
31

    
32

    
33
/**
34
 * {@link DataTypes}-related utility methods
35
 * 
36
 * @author jldominguez
37
 *
38
 */
39
public class TransformUtils {
40

    
41
    public static boolean isNumericType(int t) {
42
        return (t == DataTypes.DOUBLE
43
            || t == DataTypes.FLOAT
44
            || t == DataTypes.INT
45
            || t == DataTypes.LONG
46
            || t == DataTypes.BYTE);
47
    }
48
    
49
    public static boolean comparableTypes(int a, int b) {
50
        
51
        if (a == b) {
52
            return true;
53
        } else {
54
            return isNumericType(a) && isNumericType(b);
55
        }
56
        
57
    }
58
    /**
59
     * @param ft
60
     * @param the_type
61
     * @return
62
     */
63
    public static ArrayList<Integer> getComparableDataTypes(
64
        FeatureType ft,
65
        int the_type) {
66

    
67
        ArrayList<Integer> resp = new ArrayList<Integer>();
68
        
69
        FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors();
70
        int len = atts.length;
71
        for (int i=0; i<len; i++) {
72
            if (comparableTypes(the_type, atts[i].getType())) {
73
                resp.add(atts[i].getType());
74
            }
75
        }
76
        return resp;
77
    }
78

    
79
}