svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extExpressionField / src / com / iver / cit / gvsig / project / documents / table / operators / IndexOf.java @ 27752
History | View | Annotate | Download (1.78 KB)
1 | 27752 | vcaballero | package com.iver.cit.gvsig.project.documents.table.operators; |
---|---|---|---|
2 | |||
3 | import org.apache.bsf.BSFException; |
||
4 | import org.apache.bsf.BSFManager; |
||
5 | |||
6 | import com.iver.andami.PluginServices; |
||
7 | import com.iver.cit.gvsig.ExpressionFieldExtension; |
||
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 IndexOf extends AbstractOperator{ |
||
15 | |||
16 | public String addText(String s) { |
||
17 | return toString()+"("+s+", \"\")"; |
||
18 | } |
||
19 | public String toString() { |
||
20 | return "indexOf"; |
||
21 | } |
||
22 | public void eval(BSFManager interpreter) throws BSFException { |
||
23 | // interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"int indexOf(String value1,String value2){return value1.indexOf(value2);};");
|
||
24 | interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def indexOf(value1,value2):\n" + |
||
25 | " return value1.index(value2)");
|
||
26 | } |
||
27 | public boolean isEnable() { |
||
28 | return (getType()==IOperator.STRING);
|
||
29 | } |
||
30 | public String getTooltip(){ |
||
31 | return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")"+"\n"+getDescription(); |
||
32 | } |
||
33 | public String getDescription() { |
||
34 | return PluginServices.getText(this, "parameter") + "1"+": " + |
||
35 | PluginServices.getText(this, "string_value") + "\n"+ |
||
36 | PluginServices.getText(this, "parameter") + "2"+": " + |
||
37 | PluginServices.getText(this, "string_value") + "\n"+ |
||
38 | PluginServices.getText(this, "returns") + ": " + |
||
39 | PluginServices.getText(this, "integer_value") + "\n" + |
||
40 | PluginServices.getText(this, "description") + ": " + |
||
41 | "Returns the index within parameter1 of the first occurrence of the parameter2.";
|
||
42 | } |
||
43 | } |