Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.utils / src / main / java / org / gvsig / utils / JEPUtilities.java @ 40561

History | View | Annotate | Download (3.05 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.utils;
25

    
26
/**
27
 * DOCUMENT ME!
28
 *
29
 * @author Fernando Gonz?lez Cort?s
30
 */
31
public class JEPUtilities {
32
    /**
33
     * Transforma una expresion en funcion de variables con nombre de la forma
34
     * xix  (donde i es un n?mero cualquiera) en una expresi?n donde dichas
35
     * variables han sido sustituidas por los valores que se pasan como
36
     * par?metros.
37
     *
38
     * @param expression Expresion en funcion de xi
39
     * @param values Valores que toman las distintas variables x
40
     * @param cadena cadena[i] = true si xi es alfanum?rica y false en caso
41
     *        contrario
42
     *
43
     * @return La nueva expresion
44
     */
45
    public static String fillExpression(String expression, String[] values,
46
        boolean[] cadena) {
47
        String expresionReal = expression;
48

    
49
        for (int i = 0; i < values.length; i++) {
50
            if (cadena[i]) {
51
                expresionReal = expresionReal.replaceAll("x" + i + "x",
52
                        "\"" + values[i] + "\"");
53
            } else {
54
                expresionReal = expresionReal.replaceAll("x" + i + "x",
55
                        values[i]);
56
            }
57
        }
58

    
59
        return expresionReal;
60
    }
61

    
62
    /*
63
     * DOCUMENT ME!
64
     *
65
     * @param o DOCUMENT ME!
66
     * @param type DOCUMENT ME!
67
     *
68
     * @return DOCUMENT ME!
69
     *
70
     * @throws IllegalStateException DOCUMENT ME!
71
     *
72
       public static String getOrdinalValue(Object o, int type) {
73
               switch (type) {
74
               case FRecordset.STRING:
75
                       return (String) o;
76
               case FRecordset.DECIMAL:
77
               case FRecordset.INTEGER:
78
                       return ((Number) o).toString();
79
               case FRecordset.DATE:
80
                       return new Long(((Date) o).getTime()).toString();
81
               case FRecordset.BOOLEAN:
82
                       if (((Boolean) o).booleanValue()) {
83
                               return "1";
84
                       } else {
85
                               return "0";
86
                       }
87
               }
88
               throw new IllegalStateException("No se conoce el tipo del campo");
89
       }
90
     */
91
}