Revision 24544
trunk/extensions/extExpressionField/config/text_en.properties | ||
---|---|---|
31 | 31 |
numeric=Numeric |
32 | 32 |
numeric_value=Numeric value |
33 | 33 |
operator= |
34 |
optional=Optional |
|
34 | 35 |
parameter=Parameter |
35 | 36 |
python= |
36 | 37 |
returns=Returns |
trunk/extensions/extExpressionField/config/text.properties | ||
---|---|---|
31 | 31 |
numeric=Num\u00e9rico |
32 | 32 |
numeric_value=Valor num\u00e9rico |
33 | 33 |
operator= |
34 |
optional=Opcional |
|
34 | 35 |
parameter=Par\u00e1metro |
35 | 36 |
python= |
36 | 37 |
returns=Devuelve |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/ExpressionFieldExtension.java | ||
---|---|---|
28 | 28 |
import com.iver.cit.gvsig.project.documents.table.operators.Before; |
29 | 29 |
import com.iver.cit.gvsig.project.documents.table.operators.Ceil; |
30 | 30 |
import com.iver.cit.gvsig.project.documents.table.operators.Cos; |
31 |
import com.iver.cit.gvsig.project.documents.table.operators.DateToString; |
|
31 | 32 |
import com.iver.cit.gvsig.project.documents.table.operators.Distinct; |
32 | 33 |
import com.iver.cit.gvsig.project.documents.table.operators.Division; |
33 | 34 |
import com.iver.cit.gvsig.project.documents.table.operators.E; |
... | ... | |
35 | 36 |
import com.iver.cit.gvsig.project.documents.table.operators.Equal; |
36 | 37 |
import com.iver.cit.gvsig.project.documents.table.operators.Equals; |
37 | 38 |
import com.iver.cit.gvsig.project.documents.table.operators.Exp; |
39 |
import com.iver.cit.gvsig.project.documents.table.operators.Floor; |
|
38 | 40 |
import com.iver.cit.gvsig.project.documents.table.operators.Geometry; |
39 | 41 |
import com.iver.cit.gvsig.project.documents.table.operators.GetTimeDate; |
40 | 42 |
import com.iver.cit.gvsig.project.documents.table.operators.IndexOf; |
... | ... | |
139 | 141 |
extensionPoints.add("ColumnOperators",Before.class.toString(),Before.class); |
140 | 142 |
extensionPoints.add("ColumnOperators",Ceil.class.toString(),Ceil.class); |
141 | 143 |
extensionPoints.add("ColumnOperators",Cos.class.toString(),Cos.class); |
144 |
extensionPoints.add("ColumnOperators",DateToString.class.toString(),DateToString.class); |
|
142 | 145 |
extensionPoints.add("ColumnOperators",Distinct.class.toString(),Distinct.class); |
143 | 146 |
extensionPoints.add("ColumnOperators",Division.class.toString(),Division.class); |
144 | 147 |
extensionPoints.add("ColumnOperators",E.class.toString(),E.class); |
... | ... | |
146 | 149 |
extensionPoints.add("ColumnOperators",Equal.class.toString(),Equal.class); |
147 | 150 |
extensionPoints.add("ColumnOperators",Equals.class.toString(),Equals.class); |
148 | 151 |
extensionPoints.add("ColumnOperators",Exp.class.toString(),Exp.class); |
152 |
extensionPoints.add("ColumnOperators",Floor.class.toString(),Floor.class); |
|
149 | 153 |
extensionPoints.add("ColumnOperators",Geometry.class.toString(),Geometry.class); |
150 | 154 |
extensionPoints.add("ColumnOperators",GetTimeDate.class.toString(),GetTimeDate.class); |
151 | 155 |
extensionPoints.add("ColumnOperators",IndexOf.class.toString(),IndexOf.class); |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/GetTimeDate.java | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 | 23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double getTimeDate(java.lang.Object value){return value.getTime();};"); |
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def getTimeDate(value):\n" + |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"def getTimeDate(value):\n" + |
|
25 | 26 |
" return value.getTime()"); |
26 | 27 |
} |
27 | 28 |
public boolean isEnable() { |
28 | 29 |
return (getType()==IOperator.DATE); |
29 | 30 |
} |
30 |
public String getTooltip(){ |
|
31 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")"+"\n"+getDescription(); |
|
32 |
} |
|
31 |
|
|
33 | 32 |
public String getDescription() { |
34 | 33 |
return PluginServices.getText(this, "parameter") +": " + |
35 | 34 |
PluginServices.getText(this, "date_value") + "\n"+ |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/After.java | ||
---|---|---|
14 | 14 |
public class After extends AbstractOperator{ |
15 | 15 |
|
16 | 16 |
public String addText(String s) { |
17 |
return toString()+"("+s+",\"\")";
|
|
17 |
return toString()+"("+s+",)"; |
|
18 | 18 |
} |
19 | 19 |
public String toString() { |
20 | 20 |
return "after"; |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/Before.java | ||
---|---|---|
14 | 14 |
public class Before extends AbstractOperator{ |
15 | 15 |
|
16 | 16 |
public String addText(String s) { |
17 |
return toString()+"("+s+",\"\")";
|
|
17 |
return toString()+"("+s+",)"; |
|
18 | 18 |
} |
19 | 19 |
public String toString() { |
20 | 20 |
return "before"; |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/SetTimeDate.java | ||
---|---|---|
14 | 14 |
public class SetTimeDate extends AbstractOperator{ |
15 | 15 |
|
16 | 16 |
public String addText(String s) { |
17 |
return toString()+"("+s+",\"\")";
|
|
17 |
return toString()+"("+s+")"; |
|
18 | 18 |
} |
19 | 19 |
public String toString() { |
20 | 20 |
return "setTimeDate"; |
21 | 21 |
} |
22 | 22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 | 23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date setTimeDate(java.lang.Object value1,double value2){value1.setTime((long)value2);return value1;};"); |
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def setTimeDate(value1,value2):\n" + |
|
25 |
" value1.setTime(value2)\n" + |
|
26 |
" return value1"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"import java.util.Date as jDate\n"+ |
|
26 |
"def mySetTime(value):\n"+ |
|
27 |
" aux = jDate()\n"+ |
|
28 |
" aux.setTime(long(value))\n"+ |
|
29 |
" return aux"); |
|
27 | 30 |
} |
28 | 31 |
public boolean isEnable() { |
29 | 32 |
return (getType()==IOperator.DATE); |
30 | 33 |
} |
31 |
public String getTooltip(){ |
|
32 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")"+"\n"+getDescription(); |
|
33 |
} |
|
34 |
|
|
34 | 35 |
public String getDescription() { |
35 |
return PluginServices.getText(this, "parameter") + "1"+": " + |
|
36 |
PluginServices.getText(this, "date_value") + "\n"+ |
|
37 |
PluginServices.getText(this, "parameter") + "2"+": " + |
|
38 |
PluginServices.getText(this, "numeric_value") + "\n"+ |
|
39 |
PluginServices.getText(this, "returns") + ": " + |
|
40 |
PluginServices.getText(this, "date_value") + "\n" + |
|
41 |
PluginServices.getText(this, "description") + ": " + |
|
42 |
"Returns the parameter1 date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT."; |
|
36 |
return PluginServices.getText(this, "parameter") + ": " + |
|
37 |
PluginServices.getText(this, "numeric_value") + "\n"+ |
|
38 |
PluginServices.getText(this, "returns") + ": " + |
|
39 |
PluginServices.getText(this, "date_value") + "\n" + |
|
40 |
PluginServices.getText(this, "description") + ": " + |
|
41 |
"Returns a date object to represent a point in time that is 'parameter' milliseconds after January 1, 1970 00:00:00 GMT."; |
|
43 | 42 |
} |
44 | 43 |
} |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/Floor.java | ||
---|---|---|
1 |
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 Floor extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "floor"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def floor(value):\n" + |
|
24 |
" import java.lang.Math\n" + |
|
25 |
" return java.lang.Math.floor(value)"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.NUMBER); |
|
29 |
} |
|
30 |
public String getDescription() { |
|
31 |
return PluginServices.getText(this, "parameter") + ": " + |
|
32 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
33 |
PluginServices.getText(this, "returns") + ": " + |
|
34 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
35 |
PluginServices.getText(this, "description") + ": " + |
|
36 |
"Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. Special cases:\n" + |
|
37 |
"* If the argument value is already equal to a mathematical integer, then the result is the same as the argument.\n" + |
|
38 |
"* If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.\n"; |
|
39 |
} |
|
40 |
|
|
41 |
} |
|
0 | 42 |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/Equals.java | ||
---|---|---|
14 | 14 |
public class Equals extends AbstractOperator{ |
15 | 15 |
|
16 | 16 |
public String addText(String s) { |
17 |
return toString()+"("+s+", \"\")";
|
|
17 |
return toString()+"("+s+")"; |
|
18 | 18 |
} |
19 | 19 |
public String toString() { |
20 | 20 |
return "equals"; |
21 | 21 |
} |
22 | 22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 | 23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean equals(java.lang.Object value1,java.lang.Object value2){return value1.equals(value2);};"); |
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def equals(value1,value2):\n" + |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"def equals(value1,value2):\n" + |
|
25 | 26 |
" return value1 == value2"); |
26 | 27 |
} |
27 | 28 |
public boolean isEnable() { |
... | ... | |
32 | 33 |
} |
33 | 34 |
public String getDescription() { |
34 | 35 |
return PluginServices.getText(this, "parameter") + "1"+": " + |
35 |
PluginServices.getText(this, "string_value") + "\n"+ |
|
36 |
// PluginServices.getText(this, "string_value") + "\n"+
|
|
36 | 37 |
PluginServices.getText(this, "parameter") + "2"+": " + |
37 |
PluginServices.getText(this, "string_value") + "\n"+ |
|
38 |
// PluginServices.getText(this, "string_value") + "\n"+
|
|
38 | 39 |
PluginServices.getText(this, "returns") + ": " + |
39 | 40 |
PluginServices.getText(this, "boolean_value") + "\n" + |
40 | 41 |
PluginServices.getText(this, "description") + ": " + |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/DateToString.java | ||
---|---|---|
1 |
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 fdiaz |
|
13 |
*/ |
|
14 |
public class DateToString extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "dateToString"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String toString(java.lang.Object value){" + |
|
24 |
// "if (value instanceof java.util.Date)" + |
|
25 |
// "return ((java.util.Date)value).toString();" + |
|
26 |
// "return String.valueOf(value);};"); |
|
27 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
28 |
"import java.util.Date as Date\n"+ |
|
29 |
"import java.text.DateFormat as DateFormat\n"+ |
|
30 |
"import java.text.SimpleDateFormat as SimpleDateFormat\n" + |
|
31 |
"import java.text.NumberFormat as NumberFormat\n"+ |
|
32 |
"dateFormat = DateFormat.getInstance()\n"+ |
|
33 |
"myDateFormat = SimpleDateFormat()\n" + |
|
34 |
"def dateToString(value, format=None):\n" + |
|
35 |
" if value == None:\n"+ |
|
36 |
" return None\n"+ |
|
37 |
" if value == '':\n"+ |
|
38 |
" return ''\n"+ |
|
39 |
" if isinstance(value,Date):\n"+ |
|
40 |
" if format != None:\n"+ |
|
41 |
" myDateFormat.applyPattern(format)\n"+ |
|
42 |
" return myDateFormat.format(value)\n"+ |
|
43 |
" else:\n"+ |
|
44 |
" return dateFormat.format(value)\n"+ |
|
45 |
" else:\n"+ |
|
46 |
" raise InputError\n"+ |
|
47 |
" return str(value)"); |
|
48 |
} |
|
49 |
public boolean isEnable() { |
|
50 |
return (getType()==IOperator.DATE); |
|
51 |
} |
|
52 |
|
|
53 |
public String getTooltip(){ |
|
54 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"[,"+PluginServices.getText(this,"format")+"])"+"\n"+getDescription(); |
|
55 |
} |
|
56 |
|
|
57 |
public String getDescription() { |
|
58 |
return PluginServices.getText(this, "parameter") + ": " + |
|
59 |
PluginServices.getText(this, "date_value") + "\n" + |
|
60 |
PluginServices.getText(this, "format") + " ("+PluginServices.getText(this, "optional")+"): " + |
|
61 |
PluginServices.getText(this, "string_value") + "\n" + |
|
62 |
PluginServices.getText(this, "returns") + ": " + |
|
63 |
PluginServices.getText(this, "string_value") + "\n" + |
|
64 |
PluginServices.getText(this, "description") + ": " + |
|
65 |
"Returns the string representation of the Object date parameter\n" + |
|
66 |
"formatted according to the parameter format, if it is supplied.\n\n"+ |
|
67 |
"The format should follow the specifications of\n" + |
|
68 |
"'http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html'.\n\n"+ |
|
69 |
"Examples: (for the date of December 23, 2008)\n"+ |
|
70 |
" 'dd/MM/yy' 23/12/08\n"+ |
|
71 |
" 'dd/MM/yyyy' 23/12/2008\n"+ |
|
72 |
" 'dd/MMM/yyyy' 23/dec/2008\n"+ |
|
73 |
" 'dd/MMMM/yyyy' 23/december/2008\n"; |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/ToString.java | ||
---|---|---|
28 | 28 |
" return str(value)"); |
29 | 29 |
} |
30 | 30 |
public boolean isEnable() { |
31 |
return (getType()==IOperator.NUMBER || getType()==IOperator.DATE); |
|
31 |
return (getType()==IOperator.NUMBER);// || getType()==IOperator.DATE);
|
|
32 | 32 |
} |
33 | 33 |
public String getDescription() { |
34 | 34 |
return PluginServices.getText(this, "parameter") + ": " + |
trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/ToDate.java | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 | 23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date toDate(String value){return new java.text.SimpleDateFormat().parse(value);};"); |
24 |
interpreter.exec(ExpressionFieldExtension.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)"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"import java.text.DateFormat as DateFormat\n" + |
|
26 |
"import java.text.SimpleDateFormat as SimpleDateFormat\n" + |
|
27 |
"dateFormat = DateFormat.getInstance()\n" + |
|
28 |
"myDateFormat = SimpleDateFormat()\n" + |
|
29 |
"def toDate(value, format=None):\n" + |
|
30 |
" if format != None:\n"+ |
|
31 |
" myDateFormat.applyPattern(format)\n"+ |
|
32 |
" return myDateFormat.parse(value)\n"+ |
|
33 |
" return dateFormat.parse(value)"); |
|
28 | 34 |
} |
29 | 35 |
public boolean isEnable() { |
30 | 36 |
return (getType()==IOperator.DATE); |
31 | 37 |
} |
38 |
|
|
39 |
public String getTooltip(){ |
|
40 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"[,"+PluginServices.getText(this,"format")+"])"+"\n"+getDescription(); |
|
41 |
} |
|
42 |
|
|
32 | 43 |
public String getDescription() { |
33 |
return PluginServices.getText(this, "parameter") + ": " + |
|
44 |
return PluginServices.getText(this, "parameter") + "1: " +
|
|
34 | 45 |
PluginServices.getText(this, "string_value") + "\n" + |
46 |
PluginServices.getText(this, "format") + " ("+PluginServices.getText(this, "optional")+"): " + |
|
47 |
PluginServices.getText(this, "string_value") + "\n" + |
|
35 | 48 |
PluginServices.getText(this, "returns") + ": " + |
36 | 49 |
PluginServices.getText(this, "date_value") + "\n" + |
37 | 50 |
PluginServices.getText(this, "description") + ": " + |
38 |
"Returns a date object from string parameter."; |
|
51 |
"Returns a date object from string parameter formatted according to\nthe parameter format if it is supplied.\n\n"+ |
|
52 |
"The format should follow the specifications of\n" + |
|
53 |
"'http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html'.\n\n"+ |
|
54 |
"Examples: (for the date of December 23, 2008)\n"+ |
|
55 |
" 'dd/MM/yy' 23/12/08\n"+ |
|
56 |
" 'dd/MM/yyyy' 23/12/2008\n"+ |
|
57 |
" 'dd/MMM/yyyy' 23/dec/2008\n"+ |
|
58 |
" 'dd/MMMM/yyyy' 23/december/2008\n"; |
|
59 |
|
|
39 | 60 |
} |
40 | 61 |
} |
Also available in: Unified diff