svn-gvsig-desktop / trunk / libraries / libIverUtiles / src / com / iver / utiles / JEPUtilities.java @ 731
History | View | Annotate | Download (2.11 KB)
1 |
package com.iver.utiles; |
---|---|
2 |
|
3 |
/**
|
4 |
* DOCUMENT ME!
|
5 |
*
|
6 |
* @author Fernando Gonz?lez Cort?s
|
7 |
*/
|
8 |
public class JEPUtilities { |
9 |
/**
|
10 |
* Transforma una expresion en funcion de variables con nombre de la forma
|
11 |
* xix (donde i es un n?mero cualquiera) en una expresi?n donde dichas
|
12 |
* variables han sido sustituidas por los valores que se pasan como
|
13 |
* par?metros.
|
14 |
*
|
15 |
* @param expression Expresion en funcion de xi
|
16 |
* @param values Valores que toman las distintas variables x
|
17 |
* @param cadena cadena[i] = true si xi es alfanum?rica y false en caso
|
18 |
* contrario
|
19 |
*
|
20 |
* @return La nueva expresion
|
21 |
*/
|
22 |
public static String fillExpression(String expression, String[] values, |
23 |
boolean[] cadena) { |
24 |
String expresionReal = expression;
|
25 |
|
26 |
for (int i = 0; i < values.length; i++) { |
27 |
if (cadena[i]) {
|
28 |
expresionReal = expresionReal.replaceAll("x" + i + "x", |
29 |
"\"" + values[i] + "\""); |
30 |
} else {
|
31 |
expresionReal = expresionReal.replaceAll("x" + i + "x", |
32 |
values[i]); |
33 |
} |
34 |
} |
35 |
|
36 |
return expresionReal;
|
37 |
} |
38 |
|
39 |
/*
|
40 |
* DOCUMENT ME!
|
41 |
*
|
42 |
* @param o DOCUMENT ME!
|
43 |
* @param type DOCUMENT ME!
|
44 |
*
|
45 |
* @return DOCUMENT ME!
|
46 |
*
|
47 |
* @throws IllegalStateException DOCUMENT ME!
|
48 |
*
|
49 |
public static String getOrdinalValue(Object o, int type) {
|
50 |
switch (type) {
|
51 |
case FRecordset.STRING:
|
52 |
return (String) o;
|
53 |
case FRecordset.DECIMAL:
|
54 |
case FRecordset.INTEGER:
|
55 |
return ((Number) o).toString();
|
56 |
case FRecordset.DATE:
|
57 |
return new Long(((Date) o).getTime()).toString();
|
58 |
case FRecordset.BOOLEAN:
|
59 |
if (((Boolean) o).booleanValue()) {
|
60 |
return "1";
|
61 |
} else {
|
62 |
return "0";
|
63 |
}
|
64 |
}
|
65 |
throw new IllegalStateException("No se conoce el tipo del campo");
|
66 |
}
|
67 |
*/
|
68 |
} |