svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extExpressionField / src / com / iver / cit / gvsig / project / documents / table / operators / Trim.java @ 24545
History | View | Annotate | Download (1.32 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 | 13444 | caballero | import com.iver.andami.PluginServices; |
7 | import com.iver.cit.gvsig.ExpressionFieldExtension; |
||
8 | 10229 | caballero | 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 Trim extends AbstractOperator{ |
||
15 | |||
16 | public String addText(String s) { |
||
17 | return toString()+"("+s+")"; |
||
18 | } |
||
19 | public String toString() { |
||
20 | return "trim"; |
||
21 | } |
||
22 | public void eval(BSFManager interpreter) throws BSFException { |
||
23 | 13444 | caballero | // interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String trim(String value){return value.trim();};");
|
24 | interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def trim(value):\n" + |
||
25 | " return value.strip()");
|
||
26 | 10229 | caballero | } |
27 | public boolean isEnable() { |
||
28 | return (getType()==IOperator.STRING);
|
||
29 | } |
||
30 | 13444 | 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, "string_value") + "\n" + |
||
35 | PluginServices.getText(this, "description") + ": " + |
||
36 | "Returns a copy of the string, with leading and trailing whitespace omitted.";
|
||
37 | } |
||
38 | 10229 | caballero | } |