svn-gvsig-desktop / branches / v10 / extensions / extExpressionField / src / com / iver / cit / gvsig / project / documents / table / operators / Length.java @ 20331
History | View | Annotate | Download (1.29 KB)
1 | 10229 | caballero | package com.iver.cit.gvsig.project.documents.table.operators; |
---|---|---|---|
2 | |||
3 | import org.apache.bsf.BSFException; |
||
4 | import org.apache.bsf.BSFManager; |
||
5 | |||
6 | 11111 | caballero | import com.iver.andami.PluginServices; |
7 | 10229 | caballero | import com.iver.cit.gvsig.ExpresionFieldExtension; |
8 | import com.iver.cit.gvsig.project.documents.table.AbstractOperator; |
||
9 | import com.iver.cit.gvsig.project.documents.table.IOperator; |
||
10 | |||
11 | /**
|
||
12 | * @author Vicente Caballero Navarro
|
||
13 | */
|
||
14 | public class Length extends AbstractOperator{ |
||
15 | |||
16 | public String addText(String s) { |
||
17 | return toString()+"("+s+")"; |
||
18 | } |
||
19 | public String toString() { |
||
20 | return "length"; |
||
21 | } |
||
22 | public void eval(BSFManager interpreter) throws BSFException { |
||
23 | 11222 | caballero | // interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"int length(String value){return value.length();};");
|
24 | interpreter.exec(ExpresionFieldExtension.JYTHON,null,-1,-1,"def length(value):\n" + |
||
25 | 11729 | jmvivo | " return len(value)");
|
26 | 10229 | caballero | } |
27 | public boolean isEnable() { |
||
28 | return (getType()==IOperator.STRING);
|
||
29 | } |
||
30 | 11111 | caballero | public String getDescription() { |
31 | return PluginServices.getText(this, "parameter") + ": " + |
||
32 | PluginServices.getText(this, "string_value") + "\n" + |
||
33 | PluginServices.getText(this, "returns") + ": " + |
||
34 | PluginServices.getText(this, "numeric_value") + "\n" + |
||
35 | PluginServices.getText(this, "description") + ": " + |
||
36 | "Returns the length of string parameter.";
|
||
37 | } |
||
38 | 10229 | caballero | } |