svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / using-sld-model / org.gvsig.sldsupport / org.gvsig.sldsupport.lib / org.gvsig.sldsupport.lib.api / src / main / java / org / gvsig / sldsupport / filterencoding / operations / ReplaceOperator.java @ 40758
History | View | Annotate | Download (3.49 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib��ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
42 |
|
43 |
import java.util.ArrayList; |
44 |
import java.util.Hashtable; |
45 |
|
46 |
/**
|
47 |
*
|
48 |
* Implements the funcionality of the ReplaceOperator operator which
|
49 |
* takes an string with a field name and returns its value contained in
|
50 |
* a HashTable
|
51 |
*
|
52 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es
|
53 |
*
|
54 |
*/
|
55 |
public class ReplaceOperator extends Operator { |
56 |
|
57 |
|
58 |
private String id; |
59 |
|
60 |
|
61 |
public String getName() { |
62 |
return OperationTags.REPLACE_OP;
|
63 |
} |
64 |
|
65 |
public ReplaceOperator(Hashtable<String, Object> symbol_table) { |
66 |
super(symbol_table);
|
67 |
} |
68 |
|
69 |
public void addArgument(String image) { |
70 |
id = image; |
71 |
|
72 |
} |
73 |
public void addArgument(int i, Expression arg) { |
74 |
// TODO Auto-generated method stub
|
75 |
|
76 |
} |
77 |
|
78 |
public Object evaluate() throws ExpressionException { |
79 |
|
80 |
Object v = symbol_table.get(id);
|
81 |
if (v == null && id.length() > 0) { |
82 |
return new String("["+id.toString()+"]"); |
83 |
} else {
|
84 |
return v;
|
85 |
} |
86 |
|
87 |
/*
|
88 |
if (v != null) {
|
89 |
if (v.getClass().equals(Integer.class)) {
|
90 |
Integer val = Integer.valueOf(v.toString());
|
91 |
return (val);
|
92 |
}
|
93 |
if (v.getClass().equals(Long.class) ||
|
94 |
v.getClass().equals(Byte.class) ||
|
95 |
v.getClass().equals(Short.class) ||
|
96 |
v.getClass().equals(Float.class) ||
|
97 |
v.getClass().equals(Double.class)) {
|
98 |
Double val = Double.valueOf(v.toString());
|
99 |
return (val);
|
100 |
}
|
101 |
else if (v.getClass().equals(BooleanValue.class) ||
|
102 |
v.getClass().equals(BinaryValue.class)) {
|
103 |
return (new Boolean(v.toString()));
|
104 |
}
|
105 |
else if (v.getClass().equals(StringValue.class)) {
|
106 |
return (new String(v.toString()));
|
107 |
}
|
108 |
else if (v.getClass().equals(NullValue.class)) {
|
109 |
return (null);
|
110 |
}
|
111 |
}
|
112 |
else if(v == null && id.length() > 0)
|
113 |
return (new String("["+id.toString()+"]"));
|
114 |
|
115 |
throw new ExpressionException(ExpressionException.NO_CLASSIF_NAME);
|
116 |
*/
|
117 |
} |
118 |
|
119 |
public ArrayList<Expression> getArguments() { |
120 |
// TODO Auto-generated method stub
|
121 |
return null; |
122 |
} |
123 |
|
124 |
public String getPattern() { |
125 |
return null; |
126 |
} |
127 |
|
128 |
public void setArguments(ArrayList<Expression> arguments) { |
129 |
// TODO Auto-generated method stub
|
130 |
|
131 |
} |
132 |
public void check() throws ExpressionException { |
133 |
return;
|
134 |
} |
135 |
public String getValue() { |
136 |
return id;
|
137 |
} |
138 |
|
139 |
} |