root / branches / v2_0_0_prep / extensions / extExpressionField / src / org / gvsig / expressionfield / project / documents / table / operators / FieldCopy.java @ 29628
History | View | Annotate | Download (1.96 KB)
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
---|---|
2 |
|
3 |
import org.apache.bsf.BSFException; |
4 |
import org.apache.bsf.BSFManager; |
5 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
6 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
7 |
import org.gvsig.fmap.dal.feature.Feature; |
8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
9 |
|
10 |
/**
|
11 |
* @author Vicente Caballero Navarro
|
12 |
*/
|
13 |
public class FieldCopy extends AbstractOperator{ |
14 |
private FeatureAttributeDescriptor fd;
|
15 |
public FieldCopy() {
|
16 |
} |
17 |
public void setFieldDescription(FeatureAttributeDescriptor fd) { |
18 |
this.fd=fd;
|
19 |
} |
20 |
public String addText(String s) { |
21 |
return s.concat(toString());
|
22 |
} |
23 |
|
24 |
public void eval(BSFManager interpreter) throws BSFException { |
25 |
interpreter.declareBean(fd.getName(),this,FieldCopy.class);
|
26 |
interpreter.eval(ExpressionFieldExtension.JYTHON,null,-1,-1,"java.lang.Object "+ fd.getName()+ "(){return "+fd.getName()+".getValue(feature);};"); |
27 |
} |
28 |
public Object getValue(Feature feature){ |
29 |
return feature.get(fd.getName());
|
30 |
} |
31 |
// public Object getValue(Index indexRow,FeatureStore sds) {
|
32 |
// try {
|
33 |
// int index=sds.getFieldIndexByName(fd.getName());
|
34 |
// Value value=sds.getFieldValue(indexRow.get(),index);
|
35 |
// if (value instanceof NumericValue) {
|
36 |
// double dv=((NumericValue)value).doubleValue();
|
37 |
// return new Double(dv);
|
38 |
// }else if (value instanceof DateValue) {
|
39 |
// Date date=((DateValue)value).getValue();
|
40 |
// return date;
|
41 |
// }else if (value instanceof BooleanValue){
|
42 |
// boolean b=((BooleanValue)value).getValue();
|
43 |
// return new Boolean(b);
|
44 |
// }else {
|
45 |
// return value.toString();
|
46 |
// }
|
47 |
// } catch (ReadDriverException e) {
|
48 |
// throw new RuntimeException(e.getMessage());
|
49 |
// }
|
50 |
// }
|
51 |
public String toString() { |
52 |
return "["+fd.getName()+"]"; |
53 |
} |
54 |
public boolean isEnable() { |
55 |
return true; |
56 |
} |
57 |
public String getDescription() { |
58 |
// TODO Auto-generated method stub
|
59 |
return null; |
60 |
} |
61 |
} |