Revision 23299

View differences:

trunk/libraries/libExpressions/.settings/org.eclipse.jdt.core.prefs
1
#Wed Sep 10 09:33:03 CEST 2008
2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3
eclipse.preferences.version=1
4
org.eclipse.jdt.core.compiler.source=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.5
trunk/libraries/libExpressions/.classpath
1
<classpath>
2
  <classpathentry kind="src" path="src/main/java"/>
3
  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
4
  <classpathentry kind="output" path="target/classes"/>
5
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6
  <classpathentry kind="var" path="M2_REPO/org/gvsig/_fwAndami/2.1-SNAPSHOT/_fwAndami-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/_fwAndami/2.1-SNAPSHOT/_fwAndami-2.1-SNAPSHOT-sources.jar"/>
7
  <classpathentry kind="var" path="M2_REPO/org/gvsig/appgvSIG/2.1-SNAPSHOT/appgvSIG-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/appgvSIG/2.1-SNAPSHOT/appgvSIG-2.1-SNAPSHOT-sources.jar"/>
8
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-awt-util/gvsig/batik-awt-util-gvsig.jar"/>
9
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-bridge/gvsig/batik-bridge-gvsig.jar"/>
10
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-ext/gvsig/batik-ext-gvsig.jar"/>
11
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-gvt/gvsig/batik-gvt-gvsig.jar"/>
12
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-script/gvsig/batik-script-gvsig.jar"/>
13
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/batik/batik-util/gvsig/batik-util-gvsig.jar"/>
14
  <classpathentry kind="var" path="M2_REPO/bsf/bsf/2.3.0/bsf-2.3.0.jar"/>
15
  <classpathentry kind="var" path="M2_REPO/bsh/bsh/2.0b1/bsh-2.0b1.jar"/>
16
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/castor/gvsig/castor-gvsig.jar"/>
17
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/commons-codec/gvsig/commons-codec-gvsig.jar"/>
18
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/commons-collections/gvsig/commons-collections-gvsig.jar"/>
19
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/commons-dbcp/gvsig/commons-dbcp-gvsig.jar"/>
20
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/commons-pool/gvsig/commons-pool-gvsig.jar"/>
21
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/crimson/gvsig/crimson-gvsig.jar"/>
22
  <classpathentry kind="var" path="M2_REPO/org/gvsig/drivers/csvstring/1.0/csvstring-1.0.jar"/>
23
  <classpathentry kind="var" path="M2_REPO/org/gvsig/gdbms-0.8-SNAPSHOT/1.0/gdbms-0.8-SNAPSHOT-1.0.jar"/>
24
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/geoapi/gvsig/geoapi-gvsig.jar"/>
25
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/geojava/gvsig/geojava-gvsig.jar"/>
26
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-legacy/gvsig/gt2-legacy-gvsig.jar"/>
27
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-main/gvsig/gt2-main-gvsig.jar"/>
28
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2-postgis/gvsig/gt2-postgis-gvsig.jar"/>
29
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/gt2sidx/gvsig/gt2sidx-gvsig.jar"/>
30
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/hsqldb/gvsig/hsqldb-gvsig.jar"/>
31
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/itext/gvsig/itext-gvsig.jar"/>
32
  <classpathentry kind="var" path="M2_REPO/javax/media/jai_codec/1.1.3/jai_codec-1.1.3.jar"/>
33
  <classpathentry kind="var" path="M2_REPO/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar"/>
34
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/javaws/gvsig/javaws-gvsig.jar"/>
35
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jcalendar/gvsig/jcalendar-gvsig.jar"/>
36
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jcommon/gvsig/jcommon-gvsig.jar"/>
37
  <classpathentry kind="var" path="M2_REPO/jecw/jecw/0.0.5/jecw-0.0.5.jar"/>
38
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jfreechart/gvsig/jfreechart-gvsig.jar"/>
39
  <classpathentry kind="var" path="M2_REPO/jgdal/jgdal/0.9.1/jgdal-0.9.1.jar"/>
40
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jh/gvsig/jh-gvsig.jar"/>
41
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/JimiProClasses/gvsig/JimiProClasses-gvsig.jar"/>
42
  <classpathentry kind="var" path="M2_REPO/jmrsid/jmrsid/0.0.6/jmrsid-0.0.6.jar"/>
43
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jpedalSTD/gvsig/jpedalSTD-gvsig.jar"/>
44
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jts/gvsig/jts-gvsig.jar"/>
45
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/jtsio/gvsig/jtsio-gvsig.jar"/>
46
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/JUF/gvsig/JUF-gvsig.jar"/>
47
  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
48
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/JWizardComponent/gvsig/JWizardComponent-gvsig.jar"/>
49
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/kxml2/gvsig/kxml2-gvsig.jar"/>
50
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libDriverManager/2.1-SNAPSHOT/libDriverManager-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libDriverManager/2.1-SNAPSHOT/libDriverManager-2.1-SNAPSHOT-sources.jar"/>
51
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libDXF/2.1-SNAPSHOT/libDXF-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libDXF/2.1-SNAPSHOT/libDXF-2.1-SNAPSHOT-sources.jar"/>
52
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libExceptions/2.1-SNAPSHOT/libExceptions-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libExceptions/2.1-SNAPSHOT/libExceptions-2.1-SNAPSHOT-sources.jar"/>
53
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libFMap/2.1-SNAPSHOT/libFMap-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libFMap/2.1-SNAPSHOT/libFMap-2.1-SNAPSHOT-sources.jar"/>
54
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libInternationalization/2.1-SNAPSHOT/libInternationalization-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libInternationalization/2.1-SNAPSHOT/libInternationalization-2.1-SNAPSHOT-sources.jar"/>
55
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libIverUtiles/2.1-SNAPSHOT/libIverUtiles-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libIverUtiles/2.1-SNAPSHOT/libIverUtiles-2.1-SNAPSHOT-sources.jar"/>
56
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libProjection/2.1-SNAPSHOT/libProjection-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libProjection/2.1-SNAPSHOT/libProjection-2.1-SNAPSHOT-sources.jar"/>
57
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libRaster/2.1-SNAPSHOT/libRaster-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libRaster/2.1-SNAPSHOT/libRaster-2.1-SNAPSHOT-sources.jar"/>
58
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libRemoteServices/2.1-SNAPSHOT/libRemoteServices-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libRemoteServices/2.1-SNAPSHOT/libRemoteServices-2.1-SNAPSHOT-sources.jar"/>
59
  <classpathentry kind="var" path="M2_REPO/org/gvsig/libUIComponent/2.1-SNAPSHOT/libUIComponent-2.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/libUIComponent/2.1-SNAPSHOT/libUIComponent-2.1-SNAPSHOT-sources.jar"/>
60
  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.8/log4j-1.2.8.jar" sourcepath="M2_REPO/log4j/log4j/1.2.8/log4j-1.2.8-sources.jar"/>
61
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/looks/gvsig/looks-gvsig.jar"/>
62
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/postgis/gvsig/postgis-gvsig.jar"/>
63
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/postgresql/gvsig/postgresql-gvsig.jar"/>
64
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/spatialindex/gvsig/spatialindex-gvsig.jar"/>
65
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/tempFileManager/gvsig/tempFileManager-gvsig.jar"/>
66
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/vecmath/gvsig/vecmath-gvsig.jar"/>
67
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/xerces/gvsig/xerces-gvsig.jar"/>
68
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/xml-apis/gvsig/xml-apis-gvsig.jar"/>
69
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/xml-apis-ext/gvsig/xml-apis-ext-gvsig.jar"/>
70
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/xmlrpc/gvsig/xmlrpc-gvsig.jar"/>
71
  <classpathentry kind="var" path="M2_REPO/org/gvsig/legacy/zql/gvsig/zql-gvsig.jar"/>
72
</classpath>
trunk/libraries/libExpressions/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>libExpressions</name>
4
	<comment>Base POM for all GvSIG libraries projects. This pom knows how to
5
		build and made an libraries for GvSIG. The property
6
		&quot;gvsig-path&quot; must be set up correctly.</comment>
7
	<projects>
8
	</projects>
9
	<buildSpec>
10
		<buildCommand>
11
			<name>org.eclipse.jdt.core.javabuilder</name>
12
			<arguments>
13
			</arguments>
14
		</buildCommand>
15
	</buildSpec>
16
	<natures>
17
		<nature>org.eclipse.jdt.core.javanature</nature>
18
	</natures>
19
</projectDescription>
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Equal.java
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

  
8
/**
9
 * @author Vicente Caballero Navarro
10
 */
11
public class Equal extends AbstractOperator{
12

  
13
	public String addText(String s) {
14
		return s.concat(toString());
15
	}
16

  
17
	public void eval(BSFManager interpreter) throws BSFException {
18

  
19
	}
20
	public String toString() {
21
		return " == ";
22
	}
23
	public boolean isEnable() {
24
		return (getType()==IOperator.DATE || getType()==IOperator.NUMBER || getType()==IOperator.STRING);
25
	}
26
	public String getTooltip(){
27
		return "operator"+":  "+addText("")+"\n"+getDescription();
28
	}
29
	public String getDescription() {
30
        return  "returns" + ": " +
31
         "boolean_value" + "\n" +
32
         "description" + ": " +
33
        "Returns true if the first object value is equals than the second value.";
34
    }
35
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Replace.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Replace extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+" , \"\",\"\")";
16
	}
17
	public String toString() {
18
		return "replace";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String replace(String value1,String value2,String value3){return value1.replaceAll(value2,value3);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def replace(value1,value2,value3):\n" +
23
				"  return value1.replace(value2,value3)");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.STRING);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+"("+"parameter"+"1,"+"parameter"+"2, "+"parameter"+"3"+")"+"\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "string_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "string_value" + "\n"+
36
         "parameter" + "3"+": " +
37
         "string_value" + "\n"+
38
         "returns" + ": " +
39
         "string_value" + "\n" +
40
         "description" + ": " +
41
        "Replaces each substring(parameter2) of parameter1 string that matches the given regular expression with the given replacement parameter3";
42
    }
43
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Trim.java
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 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
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String trim(String value){return value.trim();};");
24
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def trim(value):\n" +
25
				"  return value.strip()");
26
	}
27
	public boolean isEnable() {
28
		return (getType()==IOperator.STRING);
29
	}
30
	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
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/SubString.java
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 SubString extends AbstractOperator{
15

  
16
	public String addText(String s) {
17
		return toString()+"("+s+",,)";
18
	}
19
	public String toString() {
20
		return "subString";
21
	}
22
	public void eval(BSFManager interpreter) throws BSFException {
23
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String subString(String value1,int value2,int value3){return value1.substring(value2,value3);};");
24
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def subString(value1,value2,value3):\n" +
25
				"  return value1[value2:value3]");
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, "+PluginServices.getText(this,"parameter")+"3"+")"+"\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, "numeric_value") + "\n"+
38
        PluginServices.getText(this, "parameter") + "3"+": " +
39
        PluginServices.getText(this, "numeric_value") + "\n"+
40
        PluginServices.getText(this, "returns") + ": " +
41
        PluginServices.getText(this, "string_value") + "\n" +
42
        PluginServices.getText(this, "description") + ": " +
43
        "Returns a new string that is a substring of parameter1.\n" +
44
        "The substring begins at the specified parameter2 and extends to the character at index parameter3 - 1.\n" +
45
        "Thus the length of the substring is endIndex-beginIndex.";
46
    }
47
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/LastIndexOf.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class LastIndexOf extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+", \"\")";
16
	}
17
	public String toString() {
18
		return "lastIndexOf";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"int lastIndexOf(String value1,String value2){return value1.lastIndexOf(value2);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def lastIndexOf(value1,value2):\n" +
23
				"  return value1.rfind(value2)");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.STRING);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+"("+"parameter"+"1,"+"parameter"+"2"+")"+"\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "string_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "string_value" + "\n"+
36
         "returns" + ": " +
37
         "boolean_value" + "\n" +
38
         "description" + ": " +
39
        "Returns the index within parameter1 of the last occurrence of the parameter2 character.";
40
    }
41
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Times.java
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

  
8
import com.iver.andami.PluginServices;
9

  
10
/**
11
 * @author Vicente Caballero Navarro
12
 */
13
public class Times extends AbstractOperator{
14

  
15
	public String addText(String s) {
16
		return s.concat(toString());
17
	}
18

  
19
	public void eval(BSFManager interpreter) throws BSFException {
20
	}
21
	public String toString() {
22
		return "*";
23
	}
24
	public boolean isEnable() {
25
		return (getType()==IOperator.NUMBER);
26
	}
27
	public String getTooltip(){
28
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
29
	}
30
	public String getDescription() {
31
        return PluginServices.getText(this, "returns") + ": " +
32
        PluginServices.getText(this, "numeric_value") + "\n" +
33
        PluginServices.getText(this, "description") + ": " +
34
        "Returns the result of times.";
35
    }
36
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Log.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Log extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+")";
16
	}
17
	public String toString() {
18
		return "log";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double log(double value){return java.lang.Math.log(value);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def log(value):\n" +
23
				"  import java.lang.Math\n" +
24
				"  return java.lang.Math.log(value)");
25
	}
26
	public boolean isEnable() {
27
		return (getType()==IOperator.NUMBER);
28
	}
29
	public String getDescription() {
30
        return  "parameter" + ": " +
31
         "numeric_value" + "\n" +
32
         "returns" + ": " +
33
         "numeric_value" + "\n" +
34
         "description" + ": " +
35
        "Returns the natural logarithm (base e) of a double  value. Special cases:\n" +
36
        "* If the argument is NaN or less than zero, then the result is NaN.\n" +
37
        "* If the argument is positive infinity, then the result is positive infinity.\n" +
38
        "* If the argument is positive zero or negative zero, then the result is negative infinity.";
39
    }
40
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/PointX.java
1
package org.gvsig.operators;
2

  
3
import java.util.ArrayList;
4

  
5
import org.apache.bsf.BSFException;
6
import org.apache.bsf.BSFManager;
7
import org.gvsig.baseclasses.GraphicOperator;
8
import org.gvsig.baseclasses.IOperator;
9
import org.gvsig.baseclasses.Index;
10
import org.gvsig.expresions.EvalOperatorsTask;
11

  
12
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
13
import com.iver.andami.messages.NotificationManager;
14
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
15
import com.iver.cit.gvsig.fmap.core.FShape;
16
import com.iver.cit.gvsig.fmap.core.IGeometry;
17
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
18
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
19
/**
20
 * @author Vicente Caballero Navarro
21
 */
22
public class PointX extends GraphicOperator{
23

  
24
	public String addText(String s) {
25
		return s.concat(toString()+"()");
26
	}
27
	public double process(Index index) throws DriverIOException {
28
		ReadableVectorial adapter = getLayer().getSource();
29
		IGeometry geom=null;
30
		try {
31
			geom = adapter.getShape(index.get());
32
		} catch (ExpansionFileReadException e) {
33
			throw new DriverIOException(e);
34
		} catch (ReadDriverException e) {
35
			throw new DriverIOException(e);
36
		}
37
		ArrayList parts=getXY(geom);
38
		Double[][] xsys=(Double[][])parts.get(0);//getXY(geom);
39
		return xsys[0][0].doubleValue();
40
	}
41
	public void eval(BSFManager interpreter) throws BSFException {
42
		interpreter.declareBean("pointX",this,PointX.class);
43
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double x(){return pointX.process(indexRow);};");
44
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def x():\n" +
45
				"  return pointX.process(indexRow)");
46
	}
47
	public String toString() {
48
		return "x";
49
	}
50
	public boolean isEnable() {
51
		if (getLayer()==null)
52
			return false;
53
		ReadableVectorial adapter = getLayer().getSource();
54
		int type=FShape.POINT;
55
		try {
56
			type=adapter.getShapeType();
57
		} catch (ReadDriverException e) {
58
			NotificationManager.addError(e);
59
		}
60
		return (getType()==IOperator.NUMBER && type==FShape.POINT);
61
	}
62
	public String getTooltip(){
63
		return "operator"+":  "+addText("")+"\n"+getDescription();
64
	}
65
	public String getDescription() {
66
        return  "returns" + ": " +
67
         "numeric_value" + "\n" +
68
         "description" + ": " +
69
        "Returns the X coordenate of point geometry of this row.";
70
    }
71
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Min.java
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
 * @author Vicente Caballero Navarro
10
 */
11
public class Min extends AbstractOperator{
12

  
13
	public String addText(String s) {
14
		return toString()+"("+s+")";
15
	}
16
	public String toString() {
17
		return "min";
18
	}
19
	public void eval(BSFManager interpreter) throws BSFException {
20
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double min(double value1,double value2){return java.lang.Math.min(value1,value2);};");
21
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def min(value1, value2):\n" +
22
				"  import java.lang.Math\n" +
23
				"  return java.lang.Math.min(value1,value2)");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.NUMBER);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+ "("+ "parameter"+"1,"+"parameter"+"2"+")\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "numeric_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "numeric_value" + "\n"+
36
         "returns" + ": " +
37
         "numeric_value" + "\n" +
38
         "description" + ": " +
39
        "Returns the smaller of two int values. That is, the result the argument closer to the value of Integer.MIN_VALUE.\n" +
40
        "If the arguments have the same value, the result is that same value.";
41
    }
42
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Atan.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Atan extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+")";
16
	}
17
	public String toString() {
18
		return "atan";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double atan(double value){return java.lang.Math.atan(value);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def atan(value):\n" +
23
				"  import java.lang.Math\n" +
24
				"  return java.lang.Math.atan(value)");
25
	}
26
	public boolean isEnable() {
27
		return (getType()==IOperator.NUMBER);
28
	}
29
	public String getDescription() {
30
        return "parameter" + ": " +
31
        "numeric_value" + "\n" +
32
        "returns" + ": " +
33
        "numeric_value" + "\n" +
34
        "description" + ": " +
35
        "Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. Special cases:\n" +
36
        "* If the argument is NaN, then the result is NaN.\n" +
37
        "* If the argument is zero, then the result is a zero with the same sign as the argument.\n";
38
    }
39
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Plus.java
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
/**
8
 * @author Vicente Caballero Navarro
9
 */
10
public class Plus extends AbstractOperator{
11

  
12
	public String addText(String s) {
13
		return s.concat(toString());
14
	}
15
	public String toString() {
16
		return "+";
17
	}
18
	public void eval(BSFManager interpreter) throws BSFException {
19
	}
20
	public boolean isEnable() {
21
		return (getType()==IOperator.NUMBER || getType()==IOperator.STRING);
22
	}
23
	public String getTooltip(){
24
		return "operator"+":  "+addText("")+"\n"+getDescription();
25
	}
26
	public String getDescription() {
27
        return  "returns"+ ": " +
28
         "numeric_value" + "\n" +
29
         "description" + ": " +
30
        "Returns the result of sum.";
31
    }
32
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Field.java
1
package org.gvsig.operators;
2

  
3
import java.sql.Types;
4

  
5
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
6
/**
7
 * @author Vicente Caballero Navarro
8
 */
9
public class Field extends AbstractField{
10
	private FieldDescription fd;
11
	private String typeField;
12
	public Field() {
13
	}
14
	public void setFieldDescription(FieldDescription fd) {
15
		this.fd=fd;
16
		switch (fd.getFieldType()) {
17
		case Types.INTEGER:
18
		case Types.BIGINT:
19
		case Types.DECIMAL:
20
		case Types.DOUBLE:
21
		case Types.FLOAT:
22
		case Types.NUMERIC:
23
			typeField =  "numeric_value";
24
			break;
25
		case Types.LONGVARCHAR:
26
		case Types.VARCHAR:
27
			typeField="string_value";
28
			break;
29
		case Types.BOOLEAN:
30
			typeField="boolean_value";
31
			break;
32
		case Types.DATE:
33
			typeField="date_value";
34
			break;
35
		}
36

  
37
	}
38
	public String addText(String s) {
39
		return s.concat(toString());
40
	}
41
	public String toString() {
42
		return "["+fd.getFieldAlias()+"]";
43
	}
44
	public boolean isEnable() {
45
		return true;
46
	}
47
	public String getTooltip(){
48
		return "field"+":  "+fd.getFieldAlias()+"\n"+getDescription();
49
	}
50
	public String getDescription() {
51
        return  "type" + ": " +
52
        typeField;
53
    }
54
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/ToRadians.java
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 ToRadians extends AbstractOperator{
15

  
16
	public String addText(String s) {
17
		return toString()+"("+s+")";
18
	}
19
	public String toString() {
20
		return "toRadians";
21
	}
22
	public void eval(BSFManager interpreter) throws BSFException {
23
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double toRadians(double value){return java.lang.Math.toRadians(value);};");
24
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def toRadians(value):\n" +
25
				"  import java.lang.Math\n" +
26
				"  return java.lang.Math.toRadians(value)");
27
	}
28
	public boolean isEnable() {
29
		return (getType()==IOperator.NUMBER);
30
	}
31
	public String getDescription() {
32
        return PluginServices.getText(this, "parameter") + ": " +
33
        PluginServices.getText(this, "numeric_value") + "\n" +
34
        PluginServices.getText(this, "returns") + ": " +
35
        PluginServices.getText(this, "numeric_value") + "\n" +
36
        PluginServices.getText(this, "description") + ": " +
37
        "Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact.";
38
    }
39
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Acos.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Acos extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+")";
16
	}
17
	public String toString() {
18
		return "acos";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
		interpreter.exec(EvalOperatorsTask.JYTHON, null, -1, -1,
22
	            "def acos(value):\n" +
23
	            "  import java.lang.Math\n"+
24
	            "  return java.lang.Math.acos(value)\n");
25
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double acos(double value){return java.lang.Math.acos(value);};");
26
	}
27
	public boolean isEnable() {
28
		return (getType()==IOperator.NUMBER);
29
	}
30
	public String getDescription() {
31
        return  "parameter" + ": " +
32
        "numeric_value" + "\n" +
33
        "returns" + ": " +
34
        "numeric_value" + "\n" +
35
        "description" + ": " +
36
        "Returns the arc cosine of an angle, in the range of 0.0 through pi. Special case:\n" +
37
        "* If the argument is NaN or its absolute value is greater than 1, then the result is NaN.";
38
    }
39
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Max.java
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
 * @author Vicente Caballero Navarro
10
 */
11
public class Max extends AbstractOperator{
12

  
13
	public String addText(String s) {
14
		return toString()+"("+s+")";
15
	}
16
	public String toString() {
17
		return "max";
18
	}
19
	public void eval(BSFManager interpreter) throws BSFException {
20
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double max(double value1,double value2){return java.lang.Math.max(value1,value2);};");
21
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def max(value1,value2):\n" +
22
				"  import java.lang.Math\n" +
23
				"  return java.lang.Math.max(value1,value2)");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.NUMBER);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+ "("+ "parameter"+"1,"+"parameter"+"2"+")\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "numeric_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "numeric_value" + "\n"+
36
         "returns" + ": " +
37
         "numeric_value" + "\n" +
38
         "description" + ": " +
39
        "Returns the greater of two double values. That is, the result is the argument closer to positive infinity. \n" +
40
        "If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN.\n" +
41
        "Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero.\n" +
42
        "If one argument is positive zero and the other negative zero, the result is positive zero.";
43
    }
44
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Sqrt.java
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 Sqrt extends AbstractOperator{
15

  
16
	public String addText(String s) {
17
		return toString()+"("+s+")";
18
	}
19
	public String toString() {
20
		return "sqrt";
21
	}
22
	public void eval(BSFManager interpreter) throws BSFException {
23
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double sqrt(double value){return java.lang.Math.sqrt(value);};");
24
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def sqrt(value):\n" +
25
				"  import java.lang.Math\n" +
26
				"  return java.lang.Math.sqrt(value)");
27
	}
28
	public boolean isEnable() {
29
		return (getType()==IOperator.NUMBER);
30
	}
31
	public String getDescription() {
32
        return PluginServices.getText(this, "parameter") + ": " +
33
        PluginServices.getText(this, "numeric_value") + "\n" +
34
        PluginServices.getText(this, "returns") + ": " +
35
        PluginServices.getText(this, "numeric_value") + "\n" +
36
        PluginServices.getText(this, "description") + ": " +
37
        "Returns the correctly rounded positive square root of a double value. Special cases:\n" +
38
        "* If the argument is NaN or less than zero, then the result is NaN.\n" +
39
        "* If the argument is positive infinity, then the result is positive infinity.\n" +
40
        "* If the argument is positive zero or negative zero, then the result is the same as the argument.";
41
    }
42
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Sin.java
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 Sin extends AbstractOperator{
15

  
16
	public String addText(String s) {
17
		return toString()+"("+s+")";
18
	}
19
	public String toString() {
20
		return "sin";
21
	}
22
	public void eval(BSFManager interpreter) throws BSFException {
23
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double sin(double value){return java.lang.Math.sin(value);};");
24
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def sin(value):\n" +
25
				"  import java.lang.Math\n" +
26
				"  return java.lang.Math.sin(value)");
27
	}
28
	public boolean isEnable() {
29
		return (getType()==IOperator.NUMBER);
30
	}
31
	public String getDescription() {
32
        return PluginServices.getText(this, "parameter") + ": " +
33
        PluginServices.getText(this, "numeric_value") + "\n" +
34
        PluginServices.getText(this, "returns") + ": " +
35
        PluginServices.getText(this, "numeric_value") + "\n" +
36
        PluginServices.getText(this, "description") + ": " +
37
        "Returns the trigonometric sine of an angle. Special cases:\n" +
38
        "* If the argument is NaN or an infinity, then the result is NaN.\n" +
39
        "* If the argument is zero, then the result is a zero with the same sign as the argument.";
40
    }
41
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Equals.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Equals extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+", \"\")";
16
	}
17
	public String toString() {
18
		return "equals";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean equals(java.lang.Object value1,java.lang.Object value2){return value1.equals(value2);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def equals(value1,value2):\n" +
23
				"  return value1 == value2");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.STRING || getType()==IOperator.DATE);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+"("+"parameter"+"1,"+"parameter"+"2"+")"+"\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "string_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "string_value" + "\n"+
36
         "returns" + ": " +
37
         "boolean_value" + "\n" +
38
         "description" + ": " +
39
        "Compares the parameter1 to the parameter2. The result is true if and only if the arguments are not null and represents the same object.";
40
    }
41
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Minus.java
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
/**
8
 * @author Vicente Caballero Navarro
9
 */
10
public class Minus extends AbstractOperator{
11

  
12
	public String addText(String s) {
13
		return s.concat(toString());
14
	}
15
	public String toString() {
16
		return "-";
17
	}
18
	public void eval(BSFManager interpreter) throws BSFException {
19
	}
20
	public boolean isEnable() {
21
		return (getType()==IOperator.NUMBER);
22
	}
23
	public String getTooltip(){
24
		return "operator"+":  "+addText("")+"\n"+getDescription();
25
	}
26
	public String getDescription() {
27
        return  "returns" + ": " +
28
         "numeric_value" + "\n" +
29
        "description" + ": " +
30
        "Returns the result of rest.";
31
    }
32
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/IndexOf.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class IndexOf extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+", \"\")";
16
	}
17
	public String toString() {
18
		return "indexOf";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"int indexOf(String value1,String value2){return value1.indexOf(value2);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def indexOf(value1,value2):\n" +
23
				"  return value1.index(value2)");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.STRING);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+"("+"parameter"+"1,"+"parameter"+"2"+")"+"\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" + "1"+": " +
33
         "string_value" + "\n"+
34
         "parameter" + "2"+": " +
35
         "string_value" + "\n"+
36
         "returns" + ": " +
37
         "integer_value" + "\n" +
38
         "description" + ": " +
39
        "Returns the index within parameter1 of the first occurrence of the parameter2.";
40
    }
41
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/GetTimeDate.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class GetTimeDate extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+")";
16
	}
17
	public String toString() {
18
		return "getTimeDate";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double getTimeDate(java.lang.Object value){return value.getTime();};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def getTimeDate(value):\n" +
23
				"  return value.getTime()");
24
	}
25
	public boolean isEnable() {
26
		return (getType()==IOperator.DATE);
27
	}
28
	public String getTooltip(){
29
		return "operator"+":  "+toString()+"("+"parameter"+"1,"+"parameter"+"2"+")"+"\n"+getDescription();
30
	}
31
	public String getDescription() {
32
        return  "parameter" +": " +
33
         "date_value" + "\n"+
34
         "returns" + ": " +
35
         "numeric_value" + "\n" +
36
         "description" + ": " +
37
        "Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.";
38
    }
39
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Exp.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Exp extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+")";
16
	}
17
	public String toString() {
18
		return "exp";
19
	}
20
	public void eval(BSFManager interpreter) throws BSFException {
21
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double exp(double value){return java.lang.Math.exp(value);};");
22
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def exp(value):\n" +
23
				"  import java.lang.Math\n" +
24
				"  return java.lang.Math.exp(value)");
25
	}
26
	public boolean isEnable() {
27
		return (getType()==IOperator.NUMBER);
28
	}
29
	public String getDescription() {
30
        return  "parameter" + ": " +
31
         "numeric_value" + "\n" +
32
         "returns" + ": " +
33
         "numeric_value" + "\n" +
34
         "description" + ": " +
35
        "Returns Euler's number e raised to the power of a double value. Special cases:\n" +
36
        "* If the argument is NaN, the result is NaN.\n" +
37
        "* If the argument is positive infinity, then the result is positive infinity.\n" +
38
        "* If the argument is negative infinity, then the result is positive zero.";
39
    }
40
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Perimeter.java
1
package org.gvsig.operators;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.ArrayList;
5

  
6
import org.apache.bsf.BSFException;
7
import org.apache.bsf.BSFManager;
8
import org.gvsig.baseclasses.GraphicOperator;
9
import org.gvsig.baseclasses.IOperator;
10
import org.gvsig.baseclasses.Index;
11
import org.gvsig.expresions.EvalOperatorsTask;
12

  
13
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
14
import com.iver.andami.messages.NotificationManager;
15
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
16
import com.iver.cit.gvsig.fmap.MapContext;
17
import com.iver.cit.gvsig.fmap.ViewPort;
18
import com.iver.cit.gvsig.fmap.core.FShape;
19
import com.iver.cit.gvsig.fmap.core.IGeometry;
20
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
21
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
22
/**
23
 * @author Vicente Caballero Navarro
24
 */
25
public class Perimeter extends GraphicOperator{
26

  
27
	public String addText(String s) {
28
		return s.concat(toString()+"()");
29
	}
30
	public double process(Index index) throws DriverIOException {
31
		ReadableVectorial adapter = getLayer().getSource();
32
	   	IGeometry geom=null;
33
		try {
34
			geom = adapter.getShape(index.get());
35
		} catch (ExpansionFileReadException e) {
36
			throw new DriverIOException(e);
37
		} catch (ReadDriverException e) {
38
			throw new DriverIOException(e);
39
		}
40
		ArrayList parts=getXY(geom);
41
	   	double perimeter=0;
42
	   	for (int j=0;j<parts.size();j++){
43
	   	Double[][] xsys=(Double[][])parts.get(j);//getXY(geom);
44
	    double dist = 0;
45
        double distAll = 0;
46

  
47
        ViewPort vp = getLayer().getMapContext().getViewPort();
48
        for (int i = 0; i < (xsys[0].length - 1); i++) {
49
            dist = 0;
50

  
51
            Point2D p = new Point2D.Double(xsys[0][i].doubleValue(), xsys[1][i].doubleValue());//vp.toMapPoint(new Point(event.getXs()[i].intValue(), event.getYs()[i].intValue()));
52
            Point2D p2 = new Point2D.Double(xsys[0][i + 1].doubleValue(), xsys[1][i + 1].doubleValue());//vp.toMapPoint(new Point(event.getXs()[i + 1].intValue(), event.getYs()[i + 1].intValue()));
53
            dist = vp.distanceWorld(p,p2);
54
            //System.out.println("distancia parcial = "+dist);
55
            distAll += dist;
56
        }
57
        int distanceUnits=vp.getDistanceUnits();
58
		perimeter+= distAll/MapContext.CHANGEM[distanceUnits];
59
	   	}
60
	   	return perimeter;
61
	}
62
	public void eval(BSFManager interpreter) throws BSFException {
63
		interpreter.declareBean("jperimeter",this,Perimeter.class);
64
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double perimeter(){return jperimeter.process(indexRow);};");
65
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def perimeter():\n" +
66
				"  return jperimeter.process(indexRow)");
67
	}
68
	public String toString() {
69
		return "perimeter";
70
	}
71
	public boolean isEnable() {
72
		if (getLayer()==null)
73
			return false;
74
		ReadableVectorial adapter = getLayer().getSource();
75
		int type=FShape.POINT;
76
		try {
77
			type=adapter.getShapeType();
78
		} catch (ReadDriverException e) {
79
			NotificationManager.addError(e);
80
		}
81
		return (getType()==IOperator.NUMBER && (type==FShape.POLYGON || type==FShape.LINE));
82
	}
83
	public String getTooltip(){
84
		return "operator"+":  "+addText("")+"\n"+getDescription();
85
	}
86
	public String getDescription() {
87
        return  "returns" + ": " +
88
         "numeric_value" + "\n" +
89
         "description" + ": " +
90
        "Returns the perimeter of polygon or line geometry  of this row.";
91
    }
92
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/After.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class After extends AbstractOperator {
13

  
14
	public String addText(String s) {
15
		return toString() + "(" + s + ",\"\")";
16
	}
17

  
18
	public String toString() {
19
		return "after";
20
	}
21

  
22
	public void eval(BSFManager interpreter) throws BSFException {
23
		// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,
24
		// "boolean after(java.lang.Object value1,java.lang.Object value2){return value1.after(value2);};"
25
		// );
26
		interpreter.exec(EvalOperatorsTask.JYTHON, null, -1, -1,
27
				"def after(value1, value2):\n"
28
						+ "  return value1.after(value2)");
29
	}
30

  
31
	public boolean isEnable() {
32
		return (getType() == IOperator.DATE);
33
	}
34

  
35
	public String getTooltip() {
36
		return "operator" + ":  " + toString() + "(" + "parameter" + "1,"
37
				+ "parameter" + "2" + ")" + "\n" + getDescription();
38
	}
39

  
40
	public String getDescription() {
41
		return "parameter" + "1" + ": " + "date_value" + "\n" + "parameter"
42
				+ "2" + ": " + "date_value" + "\n" + "returns" + ": "
43
				+ "boolean_value" + "\n" + "description" + ": "
44
				+ "Tests if parameter1 date is after the parameter2 date.";
45
	}
46

  
47
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Abs.java
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
/**
10
 * 
11
 * @author Vicente Caballero Navarro
12
 */
13
public class Abs extends AbstractOperator {
14
	public String addText(String s) {
15
		return toString() + "(" + s + ")";
16
	}
17

  
18
	public String toString() {
19
		return "abs";
20
	}
21

  
22
	public void eval(BSFManager interpreter) throws BSFException {
23
		interpreter.exec(EvalOperatorsTask.JYTHON, null, -1, -1,
24
				"def abs(value):\n" + "  import java.lang.Math\n"
25
						+ "  return java.lang.Math.abs(value)\n");
26
	}
27

  
28
	public boolean isEnable() {
29
		return (getType() == IOperator.NUMBER);
30
	}
31

  
32
	public double abs(double value) {
33
		return java.lang.Math.abs(value);
34
	}
35

  
36
	public String getDescription() {
37
		return "parameter"
38
				+ ": "
39
				+ "numeric_value"
40
				+ "\n"
41
				+ "returns"
42
				+ ": "
43
				+ "numeric_value"
44
				+ "\n"
45
				+ "description"
46
				+ ": "
47
				+ "Returns the absolute value of a double value. If the argument is not negative, the argument is returned. "
48
				+ "If the argument is negative, the negation of the argument is returned.\n "
49
				+ "Special cases:\n"
50
				+ "* If the argument is positive zero or negative zero, the result is positive zero.\n"
51
				+ "* If the argument is infinite, the result is positive infinity.\n"
52
				+ "* If the argument is NaN, the result is NaN.";
53
	}
54
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Pow.java
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
/**
10
 * @author Vicente Caballero Navarro
11
 */
12
public class Pow extends AbstractOperator{
13

  
14
	public String addText(String s) {
15
		return toString()+"("+s+", )";
16
	}
17

  
18
	public void eval(BSFManager interpreter) throws BSFException {
19
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double pow(double value1,double value2){return java.lang.Math.pow(value1,value2);};");
20
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def pow(value1, value2):\n" +
21
				"  import java.lang.Math\n" +
22
				"  return java.lang.Math.pow(value1,value2)");
23
	}
24
	public String toString() {
25
		return "pow";
26
	}
27
	public boolean isEnable() {
28
		return (getType()==IOperator.NUMBER);
29
	}
30
	public String getTooltip(){
31
		return "operator"+":  "+ toString()+ "(" +"parameter"+"1,"+"parameter"+"2"+")\n"+getDescription();
32
	}
33
	public String getDescription() {
34
        return  "parameter" + "1"+": " +
35
         "numeric_value" + "\n"+
36
         "parameter" + "2"+": " +
37
         "numeric_value" + "\n"+
38
         "returns" + ": " +
39
         "numeric_value" + "\n" +
40
         "description" + ": " +
41
        "Returns the value of the first argument raised to the power of the second argument. Special cases:\n" +
42
        "* If the second argument is positive or negative zero, then the result is 1.0.\n" +
43
        "* If the second argument is 1.0, then the result is the same as the first argument.\n" +
44
        "* If the second argument is NaN, then the result is NaN.\n" +
45
        "* If the first argument is NaN and the second argument is nonzero, then the result is NaN.\n" +
46
        "* If\n" +
47
        "   - the absolute value of the first argument is greater than 1 and the second argument is positive infinity, or\n" +
48
        "   - the absolute value of the first argument is less than 1 and the second argument is negative infinity,\n" +
49
        "then the result is positive infinity.\n" +
50
        "* If\n" +
51
        "   - the absolute value of the first argument is greater than 1 and the second argument is negative infinity, or\n" +
52
        "   - the absolute value of the first argument is less than 1 and the second argument is positive infinity,\n" +
53
        "then the result is positive zero.\n" +
54
        "* If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN.\n" +
55
        "* If\n" +
56
        "   - the first argument is positive zero and the second argument is greater than zero, or\n" +
57
        "   - the first argument is positive infinity and the second argument is less than zero,\n" +
58
        "then the result is positive zero.\n" +
59
        "* If\n" +
60
        "   - the first argument is positive zero and the second argument is less than zero, or\n" +
61
        "   - the first argument is positive infinity and the second argument is greater than zero,\n" +
62
        "then the result is positive infinity.\n" +
63
        "* If\n" +
64
        "   - the first argument is negative zero and the second argument is greater than zero but not a finite odd integer, or\n" +
65
        "   - the first argument is negative infinity and the second argument is less than zero but not a finite odd integer,\n" +
66
        "then the result is positive zero.\n" +
67
        "* If\n" +
68
        "   - the first argument is negative zero and the second argument is a positive finite odd integer, or\n" +
69
        "   - the first argument is negative infinity and the second argument is a negative finite odd integer,\n" +
70
        "then the result is negative zero.\n" +
71
        "* If\n" +
72
        "   - the first argument is negative zero and the second argument is less than zero but not a finite odd integer, or\n" +
73
        "   - the first argument is negative infinity and the second argument is greater than zero but not a finite odd integer,\n" +
74
        "then the result is positive infinity.\n" +
75
        "* If\n" +
76
        "   - the first argument is negative zero and the second argument is a negative finite odd integer, or\n" +
77
        "   - the first argument is negative infinity and the second argument is a positive finite odd integer,\n" +
78
        "then the result is negative infinity.\n" +
79
        "* If the first argument is finite and less than zero\n" +
80
        "   - if the second argument is a finite even integer, the result is equal to the result of raising the absolute value of the first argument to the power of the second argument\n" +
81
        "   - if the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument\n" +
82
        "   - if the second argument is finite and not an integer, then the result is NaN.\n" +
83
        "* If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.";
84
    }
85
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/AbstractField.java
1
package org.gvsig.operators;
2

  
3
import java.util.Date;
4

  
5
import org.apache.bsf.BSFException;
6
import org.apache.bsf.BSFManager;
7
import org.gvsig.baseclasses.AbstractOperator;
8
import org.gvsig.baseclasses.Index;
9
import org.gvsig.expresions.EvalOperatorsTask;
10

  
11
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
12
import com.hardcode.gdbms.engine.values.BooleanValue;
13
import com.hardcode.gdbms.engine.values.DateValue;
14
import com.hardcode.gdbms.engine.values.NumericValue;
15
import com.hardcode.gdbms.engine.values.Value;
16
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
17

  
18
public abstract class AbstractField extends AbstractOperator{
19
	private boolean isEval=false;
20
	public Object getValue(String nameField,Index indexRow,SelectableDataSource sds) {
21
		try {
22
			int index=sds.getFieldIndexByName(nameField);
23
			Value value=sds.getFieldValue(indexRow.get(),index);
24
			if (value instanceof NumericValue) {
25
				double dv=((NumericValue)value).doubleValue();
26
				return new Double(dv);
27
			}else if (value instanceof DateValue) {
28
				Date date=((DateValue)value).getValue();
29
				return date;
30
			}else if (value instanceof BooleanValue){
31
				boolean b=((BooleanValue)value).getValue();
32
				return new Boolean(b);
33
			}else {
34
				return value.toString();
35
			}
36
		} catch (ReadDriverException e) {
37
			throw new RuntimeException(e.getMessage());
38
		}
39
	}
40
	public void eval(BSFManager interpreter) throws BSFException {
41
		if (!isEval){
42
		interpreter.declareBean("jfield",this,Field.class);
43
		interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def field(nameField):\n" +
44
				"  return jfield.getValue(nameField,indexRow,sds)");
45
		isEval=true;
46
		}
47
	}
48
}
trunk/libraries/libExpressions/src/main/java/org/gvsig/operators/Area.java
1
package org.gvsig.operators;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.ArrayList;
5

  
6
import org.apache.bsf.BSFException;
7
import org.apache.bsf.BSFManager;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff