root / trunk / libraries / libExpressions / src / main / java / org / gvsig / operators / ToDate.java @ 23299
History | View | Annotate | Download (1.39 KB)
1 |
package org.gvsig.operators; |
---|---|
2 |
|
3 |
import org.apache.bsf.BSFException; |
4 |
import org.apache.bsf.BSFManager; |
5 |
import org.gvsig.baseclasses.AbstractOperator; |
6 |
import org.gvsig.baseclasses.IOperator; |
7 |
import org.gvsig.expresions.EvalOperatorsTask; |
8 |
|
9 |
import com.iver.andami.PluginServices; |
10 |
|
11 |
/**
|
12 |
* @author Vicente Caballero Navarro
|
13 |
*/
|
14 |
public class ToDate extends AbstractOperator{ |
15 |
|
16 |
public String addText(String s) { |
17 |
return toString()+"("+s+")"; |
18 |
} |
19 |
public String toString() { |
20 |
return "toDate"; |
21 |
} |
22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date toDate(String value){return new java.text.SimpleDateFormat().parse(value);};");
|
24 |
interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def toDate(value):\n" + |
25 |
" import java.text.SimpleDateFormat\n" +
|
26 |
" sdf=instance(java.text.SimpleDateFormat)\n" +
|
27 |
" return sdf.parse(value)");
|
28 |
} |
29 |
public boolean isEnable() { |
30 |
return (getType()==IOperator.DATE);
|
31 |
} |
32 |
public String getDescription() { |
33 |
return PluginServices.getText(this, "parameter") + ": " + |
34 |
PluginServices.getText(this, "string_value") + "\n" + |
35 |
PluginServices.getText(this, "returns") + ": " + |
36 |
PluginServices.getText(this, "date_value") + "\n" + |
37 |
PluginServices.getText(this, "description") + ": " + |
38 |
"Returns a date object from string parameter.";
|
39 |
} |
40 |
} |