Revision 44518

View differences:

tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <groupId>org.gvsig</groupId>
4
    <artifactId>org.gvsig.expressionevaluator.main</artifactId>
5
    <name>${project.artifactId}</name>
6
    <parent>
7
        <groupId>org.gvsig</groupId>
8
        <artifactId>org.gvsig.expressionevaluator</artifactId>
9
        <version>2.0.253</version>
10
    </parent>
11

  
12

  
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gvsig</groupId>
16
            <artifactId>org.gvsig.expressionevaluator.lib.api</artifactId>
17
            <scope>compile</scope>
18
        </dependency>
19
        <dependency>
20
            <groupId>org.gvsig</groupId>
21
            <artifactId>org.gvsig.expressionevaluator.lib.impl</artifactId>
22
            <scope>runtime</scope>
23
        </dependency>
24
        <dependency>
25
            <groupId>org.gvsig</groupId>
26
            <artifactId>org.gvsig.tools.lib</artifactId>
27
            <scope>compile</scope>
28
        </dependency>
29
        <dependency>
30
            <groupId>org.gvsig</groupId>
31
            <artifactId>org.gvsig.tools.swing.api</artifactId>
32
            <scope>compile</scope>
33
        </dependency>
34
        <dependency>
35
            <groupId>org.gvsig</groupId>
36
            <artifactId>org.gvsig.tools.swing.impl</artifactId>
37
            <scope>runtime</scope>
38
        </dependency>
39
        <dependency>
40
            <groupId>org.gvsig</groupId>
41
            <artifactId>org.gvsig.expressionevaluator.swing.api</artifactId>
42
            <scope>compile</scope>
43
        </dependency>
44
        <dependency>
45
            <groupId>org.gvsig</groupId>
46
            <artifactId>org.gvsig.expressionevaluator.swing.impl</artifactId>
47
            <scope>compile</scope>
48
        </dependency>
49
        <dependency>
50
            <groupId>org.gvsig</groupId>
51
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>org.gvsig</groupId>
56
            <artifactId>org.gvsig.fmap.dal.swing.api</artifactId>
57
            <scope>compile</scope>
58
        </dependency>
59
        
60
        
61
        <dependency>
62
            <groupId>org.gvsig</groupId>
63
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
64
            <scope>runtime</scope>
65
        </dependency>
66
        <dependency>
67
            <groupId>org.gvsig</groupId>
68
            <artifactId>org.gvsig.fmap.dal.swing.impl</artifactId>
69
            <scope>runtime</scope>
70
        </dependency>
71
        <dependency>
72
            <groupId>org.gvsig</groupId>
73
            <artifactId>org.gvsig.fmap.dal.file.csv</artifactId>
74
            <scope>runtime</scope>
75
        </dependency>
76
        <dependency>
77
            <groupId>org.gvsig</groupId>
78
            <artifactId>${org.gvsig.metadata.lib.basic.impl}</artifactId>
79
            <scope>runtime</scope>
80
        </dependency>
81
        <dependency>
82
            <groupId>org.gvsig</groupId>
83
            <artifactId>${org.gvsig.fmap.geometry.impl}</artifactId>
84
            <scope>runtime</scope>
85
        </dependency>
86
        <dependency>
87
            <groupId>org.gvsig</groupId>
88
            <artifactId>${org.gvsig.timesupport.lib.impl}</artifactId>
89
            <scope>runtime</scope>
90
        </dependency>
91
        <dependency>
92
            <groupId>org.gvsig</groupId>
93
            <artifactId>${org.gvsig.compat.impl}</artifactId>
94
            <scope>runtime</scope>
95
        </dependency>
96
        <dependency>
97
            <groupId>org.gvsig</groupId>
98
            <artifactId>${org.gvsig.proj.lib.impl}</artifactId>
99
            <scope>runtime</scope>
100
        </dependency>
101
        <dependency>
102
            <groupId>org.gvsig</groupId>
103
            <artifactId>org.gvsig.utils</artifactId>
104
            <scope>runtime</scope>
105
        </dependency>
106
        <!--
107
        <dependency>
108
            <groupId>org.gvsig</groupId>
109
            <artifactId>org.gvsig.scripting.swing.impl</artifactId>
110
            <version>2.3.67-SNAPSHOT</version>
111
            <scope>runtime</scope>
112
        </dependency>
113
        -->
114
    </dependencies>
115

  
116

  
117
    <build>
118
        <plugins>
119
            <plugin> 
120
                <!-- Build an executable JAR --> 
121
                <groupId>org.apache.maven.plugins</groupId> 
122
                <artifactId>maven-jar-plugin</artifactId> 
123
                <version>3.0.2</version> 
124
                <configuration> 
125
                    <archive> 
126
                        <manifest> 
127
                            <addClasspath>true</addClasspath> 
128
                            <classpathPrefix>./</classpathPrefix> 
129
                            <mainClass>org.gvsig.expressionevaluator.main.Main</mainClass> 
130
                        </manifest> 
131
                    </archive> 
132
                </configuration> 
133
            </plugin> 
134
            
135
            <plugin>
136
                <artifactId>maven-assembly-plugin</artifactId>
137
                <configuration>
138
                    <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
139
                    <appendAssemblyId>false</appendAssemblyId>
140
                </configuration>
141
                <executions>
142
                    <execution>
143
                        <id>gvsig-plugin-package</id>
144
                        <phase>package</phase>
145
                        <goals>
146
                            <goal>single</goal>
147
                        </goals>
148
                        <configuration>
149
                            <finalName>${project.artifactId}-${project.version}</finalName>
150
                            <descriptors>
151
                                <descriptor>src/main/assembly/gvsig-main-package.xml</descriptor>
152
                            </descriptors>
153
                        </configuration>
154
                    </execution>
155
                </executions>
156
            </plugin>
157

  
158
        </plugins>
159
    </build>
160

  
161

  
162

  
163
</project>
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 2
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.construc">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/src/main/resources/Locations.csv
1
"id","name","size","confirmed","type"
2
1,"King's Landing",5,1,"City"
3
2,"Hayford Castle",3,0,"Castle"
4
3,"Rosby",3,1,"Castle"
5
4,"Old Stone Bridge Inn",1,0,"Other"
6
5,"Brindlewood",1,0,"Other"
7
6,"Sow's Horn",3,1,"Castle"
8
7,"Tumbleton",4,1,"Town"
9
8,"High Heart",2,1,"Ruin"
10
9,"Duskendale",4,1,"Town"
11
10,"Antlers",3,1,"Castle"
12
11,"Stokeworth",3,0,"Castle"
13
12,"Ivy Inn",1,0,"Other"
14
13,"Village",1,0,"Other"
15
14,"Holdfast",1,0,"Other"
16
15,"Harrenhal",3,1,"Castle"
17
16,"Rushing Falls",1,0,"Other"
18
17,"Tumblers Falls",1,0,"Other"
19
18,"Stoney Sept",4,1,"Town"
20
19,"Hollow Hill",1,0,"Other"
21
20,"Sept",1,0,"Other"
22
21,"Acorn Hall",3,1,"Castle"
23
22,"Pinkmaiden",3,1,"Castle"
24
23,"Mummer's Ford",1,0,"Other"
25
24,"Sherrer",1,0,"Other"
26
25,"Wendish Town",1,0,"Other"
27
26,"Lord Goodbrook's Village",1,0,"Other"
28
27,"Sallydance",1,0,"Other"
29
28,"Lady of the Leaves",1,0,"Other"
30
29,"Lord Lychester's Keep",1,0,"Other"
31
30,"Unnamed Village",1,0,"Other"
32
31,"Inn (They Ley with Lions)",1,0,"Other"
33
32,"Riverrun",3,1,"Castle"
34
33,"Raventree Hall",3,0,"Castle"
35
34,"Darry",3,0,"Castle"
36
35,"Inn of the Kneeling Man",1,1,"Other"
37
36,"BWB hideout",1,0,"Other"
38
37,"Lort Harroway's Town",1,0,"Other"
39
38,"Crossroads Inn",1,0,"Other"
40
39,"Saltpans",1,1,"Other"
41
40,"Quiet Isle",1,1,"Other"
42
41,"Wickenden",3,1,"Castle"
43
42,"Maidenpool",4,1,"Town"
44
43,"Rook's Rest",3,1,"Castle"
45
44,"Dyre Den",3,1,"Castle"
46
45,"The Whispers",2,1,"Ruin"
47
46,"Dragonstone",3,1,"Castle"
48
47,"Sharp Point",3,1,"Castle"
49
48,"Stonedance",3,1,"Castle"
50
49,"Haystack Hall",3,1,"Castle"
51
50,"Bronzegate",3,1,"Castle"
52
51,"Felwood",3,1,"Castle"
53
52,"Storm's End",3,1,"Castle"
54
53,"Griffin's Roost",3,1,"Castle"
55
54,"Rain House",3,1,"Castle"
56
55,"Greenstone",3,1,"Castle"
57
56,"Weeping Tower",3,1,"Castle"
58
57,"Mistwood",3,1,"Castle"
59
58,"Stonehelm",3,1,"Castle"
60
59,"Crow's Nest",3,1,"Castle"
61
60,"Grandview",4,0,"Town"
62
61,"Summerhall",2,1,"Ruin"
63
62,"Blackhaven",3,1,"Castle"
64
63,"Fawnton",4,0,"Town"
65
64,"Grassy Vale",3,1,"Castle"
66
65,"Wyl",3,1,"Castle"
67
66,"Ghaston Grey",3,1,"Castle"
68
67,"Yronwood",3,1,"Castle"
69
68,"Vulture's Roost",3,1,"Castle"
70
69,"Nightsong",3,1,"Castle"
71
70,"Ashford",3,1,"Castle"
72
71,"Cider Hall",3,1,"Castle"
73
72,"Highgarden",3,1,"Castle"
74
73,"Horn Hill",3,1,"Castle"
75
74,"Brightwater Keep",3,1,"Castle"
76
75,"Bandallon",3,1,"Castle"
77
76,"Honeyholt",3,1,"Castle"
78
77,"Oldtown",5,1,"City"
79
78,"Blackcrown",3,1,"Castle"
80
79,"Three Towers",3,1,"Castle"
81
80,"Uplands",3,1,"Castle"
82
81,"Sunflower Hall",3,1,"Castle"
83
82,"Blackmont",3,1,"Castle"
84
83,"High Hermitage",3,1,"Castle"
85
84,"Starfall",3,1,"Castle"
86
85,"Sandstone",3,1,"Castle"
87
86,"Skyreach",3,1,"Castle"
88
87,"Kingsgrave",3,1,"Castle"
89
88,"Tower of Joy",1,1,"Other"
90
89,"Hellholt",3,1,"Castle"
91
90,"Vaith",3,1,"Castle"
92
91,"Salt Shore",3,1,"Castle"
93
92,"Godsgrace",3,1,"Castle"
94
93,"The Tor",3,1,"Castle"
95
94,"Ghost Hill",3,1,"Castle"
96
95,"Lemonwood",3,1,"Castle"
97
96,"Sunspear",3,1,"Castle"
98
97,"Planky Town",4,1,"Town"
99
98,"Water Gardens",1,0,"Other"
100
99,"Shandystone",1,0,"Other"
101
100,"Tall Trees Town",4,0,"Town"
102
101,"Longtable",3,1,"Castle"
103
102,"Bitterbridge",3,1,"Castle"
104
103,"Goldengrove",3,1,"Castle"
105
104,"Red Lake",3,1,"Castle"
106
105,"Old Oak",3,1,"Castle"
107
106,"Crakehall",3,1,"Castle"
108
107,"Cornfield",3,1,"Castle"
109
108,"Silverhill",3,1,"Castle"
110
109,"Clegane Hall",3,0,"Castle"
111
110,"Tarbeck Hall",2,0,"Ruin"
112
111,"Lannisport",5,1,"City"
113
112,"Feastfires",3,1,"Castle"
114
113,"Kayce",4,1,"Town"
115
114,"Oxcross",1,0,"Other"
116
115,"Sarsfield",3,1,"Castle"
117
116,"Deep Den",3,1,"Castle"
118
117,"Hornvale",3,1,"Castle"
119
118,"Golden Tooth",1,1,"Other"
120
119,"Wayfarer's Rest",3,0,"Castle"
121
120,"Castamere",2,0,"Ruin"
122
121,"Pendric Hills",1,0,"Other"
123
122,"The Crag",3,1,"Castle"
124
123,"Banefort",3,1,"Castle"
125
124,"Ashemark",3,1,"Castle"
126
125,"Nunn's Deep",1,0,"Other"
127
126,"Stone Mill",1,0,"Other"
128
127,"Stone Hedge",3,1,"Castle"
129
128,"Fairmarket",4,1,"Town"
130
129,"Oldstones",2,1,"Ruin"
131
130,"Palisade Village",1,0,"Other"
132
131,"The Bloody Gate",3,1,"Castle"
133
132,"The Eyrie",3,1,"Castle"
134
133,"Strongsong",3,1,"Castle"
135
134,"Heart's Home",3,1,"Castle"
136
135,"Redfort",3,1,"Castle"
137
136,"Ironoaks",3,1,"Castle"
138
137,"Old Anchor",3,1,"Castle"
139
138,"Runestone",3,1,"Castle"
140
139,"Gulltown",5,1,"City"
141
140,"Longbow Hall",3,1,"Castle"
142
141,"Snakewood",3,1,"Castle"
143
142,"Baelish Keep",1,0,"Other"
144
143,"Coldwater",3,1,"Castle"
145
144,"Seagard",3,1,"Castle"
146
145,"The Twins",3,1,"Castle"
147
146,,3,1,"Castle"
148
147,"Greywater Watch",3,1,"Castle"
149
148,"Moat Cailin",2,1,"Ruin"
150
149,"Sisterton",4,1,"Town"
151
150,"Oldcastle",3,1,"Castle"
152
151,"White Harbor",5,1,"City"
153
152,"Ramsgate",3,1,"Castle"
154
153,"Widow's Watch",3,1,"Castle"
155
154,"Hornwood",3,0,"Castle"
156
155,"Tower",1,0,"Other"
157
156,"The Dreadfort",3,1,"Castle"
158
157,"Cerwyn",3,0,"Castle"
159
158,"Holdfast",1,0,"Other"
160
159,"Winterfell",3,1,"Castle"
161
160,"Crofters' Village",1,0,"Other"
162
161,"Tumbledown Tower",1,0,"Other"
163
162,"Deepwood Motte",3,1,"Castle"
164
163,"Last Hearth",3,1,"Castle"
165
164,"Karhold",3,1,"Castle"
166
165,"Queenscrown",1,1,"Other"
167
166,"Castle Black",3,1,"Castle"
168
167,"Mole's Town",1,0,"Other"
169
168,"Shadow Tower",3,1,"Castle"
170
169,"Westwatch-by-the-Bridge",1,1,"Other"
171
170,"Sentinel Stand",1,1,"Other"
172
171,"Greyguard",1,1,"Other"
173
172,"Stonedoor",1,1,"Other"
174
173,"Hoarfrost Hill",1,1,"Other"
175
174,"Icemark",1,1,"Other"
176
175,"Nightfort",1,1,"Other"
177
176,"Deep Lake",1,1,"Other"
178
177,"Queensgate",1,1,"Other"
179
178,"Oakensheild",1,1,"Other"
180
179,"Woodswatch-by-the-Pool",1,1,"Other"
181
180,"Sable Hall",1,1,"Other"
182
181,"Rimegate",1,1,"Other"
183
182,"Long Barrow",1,1,"Other"
184
183,"Torches",1,1,"Other"
185
184,"Greenguard",1,1,"Other"
186
185,"Eastwatch-by-the-Sea",3,1,"Castle"
187
186,"Whitetree",1,1,"Other"
188
187,"Craster's Keep",1,1,"Other"
189
188,"Fist of the First Men",1,1,"Other"
190
189,"Fishing Village",1,0,"Other"
191
190,"Pennytree",1,0,"Other"
192
191,"Lys",5,1,"City"
193
192,"Tyrosh",5,1,"City"
194
193,"Myr",5,1,"City"
195
194,"Pentos",5,1,"City"
196
195,"Ghoyan Drohe",2,1,"Ruin"
197
196,"Norvos",5,1,"City"
198
197,"Evenfall Hall",3,1,"Castle"
199
198,"Parchments",1,0,"Other"
200
199,"Braavos",3,1,"Castle"
201
200,"Lorath",3,1,"Castle"
202
201,"Qohor",5,1,"City"
203
202,"Ar Noy",2,1,"Ruin"
204
203,"Ny Sar",2,1,"Ruin"
205
204,"The Sorrows (Chroyane)",2,1,"Ruin"
206
205,"Selhorys",4,1,"Town"
207
206,"Valysar",4,1,"Town"
208
207,"Volon Therys",4,1,"Town"
209
208,"Sar Mell",2,1,"Ruin"
210
209,"Volantis",5,1,"City"
211
210,,1,1,"Other"
212
211,,2,1,"Ruin"
213
212,"Mantarys",5,1,"City"
214
213,,2,1,"Ruin"
215
214,"Oros",2,1,"Ruin"
216
215,"Elyria",5,1,"City"
217
216,"Tolos",5,1,"City"
218
217,"Ghozai",2,1,"Ruin"
219
218,"Velos",2,1,"Ruin"
220
219,,2,1,"Ruin"
221
220,"Astapor",5,1,"City"
222
221,"Yunkai",5,1,"City"
223
222,"Meereen",5,1,"City"
224
223,"Lhazarene Village",1,0,"Other"
225
224,"Vaes Dothrak",5,0,"City"
226
225,"Old Ghis",2,1,"Ruin"
227
226,"New Ghis",5,1,"City"
228
227,"Zamettar",2,1,"Ruin"
229
228,"Yeen",2,1,"Ruin"
230
229,"Gogossos",2,1,"Ruin"
231
230,"Flint's Finger",3,1,"Castle"
232
231,"Barrowton",4,1,"Town"
233
232,"Torrhen's Square",3,1,"Castle"
234
233,"Bhorash",2,1,"Ruin"
235
234,"Pyke",3,1,"Castle"
236
235,"Pebbleton",1,0,"Other"
237
236,"Hammerhorn",1,0,"Other"
238
237,"Nagga's Ribs",1,0,"Other"
239
238,"Castle Goodbrother",1,0,"Other"
240
239,"Ten Towers",3,1,"Castle"
241
240,"Faircastle",3,1,"Castle"
242
241,"Tyria",2,1,"Ruin"
243
242,"Valyria",2,1,"Ruin"
244
243,,2,1,"Ruin"
245
244,,2,1,"Ruin"
246
245,,2,1,"Ruin"
247
246,"Qarth",5,0,"City"
248
247,"Lord Hewett's Town",1,0,"Other"
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/src/main/assembly/gvsig-main-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-main-package</id>
28
  <formats>
29
    <format>dir</format>
30
  </formats>
31
  <baseDirectory>.</baseDirectory>
32
  <!-- 
33
  <includeBaseDirectory>true</includeBaseDirectory>
34
   -->
35
  <files>
36
    <file>
37
      <source>target/${project.artifactId}-${project.version}.jar</source>
38
      <outputDirectory>lib</outputDirectory>
39
    </file>
40
  </files>
41
  <fileSets>
42
    <fileSet>
43
      <directory>src/main/resources-main</directory>
44
      <outputDirectory>.</outputDirectory>
45
    </fileSet>
46
  </fileSets>
47
  
48
  <dependencySets>
49
    <dependencySet>
50
      <useProjectArtifact>false</useProjectArtifact>
51
      <useTransitiveDependencies>true</useTransitiveDependencies>
52
      <outputDirectory>lib</outputDirectory>
53
    </dependencySet>
54
  </dependencySets>
55

  
56
</assembly>
57

  
0 58

  
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/src/main/java/org/gvsig/expressionevaluator/main/MainPicker.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.expressionevaluator.main;
7

  
8
import java.awt.Dimension;
9
import java.io.File;
10
import java.net.URL;
11
import javax.swing.JFrame;
12
import javax.swing.WindowConstants;
13
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
14
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
15
import org.gvsig.expressionevaluator.SymbolTable;
16
import org.gvsig.expressionevaluator.swing.Element;
17
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
18
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
19
import org.gvsig.expressionevaluator.swing.JExpressionPicker;
20
import org.gvsig.fmap.dal.DALLocator;
21
import org.gvsig.fmap.dal.DataManager;
22
import org.gvsig.fmap.dal.DataStore;
23
import org.gvsig.fmap.dal.feature.FeatureStore;
24
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
25

  
26
/**
27
 *
28
 * @author jjdelcerro
29
 */
30
public class MainPicker {
31
    public static void main(String[] args) {
32
        new MainPicker().run(args);
33
    }
34
    
35
    public void run(String[] args) {
36
        new DefaultLibrariesInitializer().fullInitialize();
37
        
38
        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
39
        ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager();
40
        
41
        JExpressionPicker panel = swingManager.createJExpressionPicker();
42
//        SymbolTable symbolTable = manager.getSymbolTable("DAL.FeatureSymbolTable");
43
//        if( symbolTable!=null ) {
44
//            panel.addSymbolTable(symbolTable);
45
//        }
46
        Element element = swingManager.createElement("DAL.FeatureStoreElement", panel, openStore());
47
        if( element != null ) {
48
            panel.getElements().add(element);
49
        }
50

  
51
        JFrame frame = new JFrame("My JFrame Example");
52
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
53
        frame.setPreferredSize(new Dimension(400, 60));
54
        frame.add(panel.asJComponent());
55
        frame.pack();
56
        frame.setVisible(true);        
57
    }
58
   
59
    private FeatureStore openStore() {
60
        try {
61
            DataManager dataManager = DALLocator.getDataManager();
62
            URL url = this.getClass().getResource("/Locations.csv");
63
            DataStore store = dataManager.openStore(
64
                    "CSV", 
65
                    "file",new File(url.toURI()),
66
                    "firstLineHeader", true,
67
                    "delimiter",","
68
            );
69
            return (FeatureStore) store;
70
        } catch (Exception ex) {
71
            throw new RuntimeException(ex);
72
        }
73
    }
74
}
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.main/src/main/java/org/gvsig/expressionevaluator/main/MainDialog.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.expressionevaluator.main;
7

  
8
import java.io.File;
9
import java.net.URL;
10
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
11
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
12
import org.gvsig.expressionevaluator.SymbolTable;
13
import org.gvsig.expressionevaluator.swing.Element;
14
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
15
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
16
import org.gvsig.expressionevaluator.swing.JExpressionBuilder;
17
import org.gvsig.fmap.dal.DALLocator;
18
import org.gvsig.fmap.dal.DataManager;
19
import org.gvsig.fmap.dal.DataStore;
20
import org.gvsig.fmap.dal.feature.FeatureStore;
21
import org.gvsig.fmap.dal.swing.DataSwingManager;
22
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
23
import org.gvsig.tools.swing.api.ToolsSwingLocator;
24
import org.gvsig.tools.swing.api.windowmanager.Dialog;
25
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
26
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
27

  
28
/**
29
 *
30
 * @author jjdelcerro
31
 */
32
public class MainDialog {
33
    public static void main(String[] args) {
34
        new MainDialog().run(args);
35
    }
36
    
37
    public void run(String[] args) {
38
        new DefaultLibrariesInitializer().fullInitialize();
39
        
40
        WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
41
        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
42
        ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager();
43
        
44
        JExpressionBuilder panel = swingManager.createJExpressionBuilder();
45
        panel.addSymbolTable(DataManager.DAL_SYMBOL_TABLE_FEATURE);
46
        Element element = swingManager.createElement(
47
                DataSwingManager.FEATURE_STORE_EXPRESSION_ELEMENT, 
48
                panel, 
49
                openStore()
50
        );
51
        if( element != null ) {
52
            panel.addElement(element);
53
        }
54
        Dialog dialog = windowManager.createDialog(
55
                panel.asJComponent(),
56
                "Test eexpression builder",
57
                null, 
58
                WindowManager_v2.BUTTONS_OK_CANCEL
59
        );
60
        dialog.show(WindowManager.MODE.WINDOW);
61
    }
62
   
63
    private FeatureStore openStore() {
64
        try {
65
            DataManager dataManager = DALLocator.getDataManager();
66
            URL url = this.getClass().getResource("/Locations.csv");
67
            DataStore store = dataManager.openStore(
68
                    "CSV", 
69
                    "file",new File(url.toURI()),
70
                    "firstLineHeader", true,
71
                    "delimiter",","
72
            );
73
            return (FeatureStore) store;
74
        } catch (Exception ex) {
75
            throw new RuntimeException(ex);
76
        }
77
    }
78
}
0 79

  
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <artifactId>org.gvsig.expressionevaluator</artifactId>
4
  <packaging>pom</packaging>
5
  <description>Evaluador de expresiones. Usa una sintaxis similar a las condiciones de SQL.</description>
6
  <parent>
7
    <groupId>org.gvsig</groupId>
8
    <artifactId>org.gvsig.desktop.library</artifactId>
9
    <version>2.0.253</version>
10
  </parent>
11
  <modules>
12
    <module>org.gvsig.expressionevaluator.lib</module>
13
    <module>org.gvsig.expressionevaluator.swing</module>
14
    <module>org.gvsig.expressionevaluator.main</module>
15
  </modules>
16
</project>
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Compiler.java
1
package org.gvsig.expressionevaluator;
2

  
3
import java.util.List;
4
import org.gvsig.tools.lang.Cloneable;
5

  
6
public interface Compiler extends Cloneable {
7
    
8
    public void setLexicalAnalyzer(LexicalAnalyzer lex);
9

  
10
    public LexicalAnalyzer getLexicalAnalyzer();
11
    
12
    public void setCodeBuilder(CodeBuilder codeBuilder);
13
    
14
    public CodeBuilder getCodeBuilder();
15
    
16
    public Code compileExpression(String expression);
17

  
18
    @Override
19
    public Compiler clone() throws CloneNotSupportedException;
20

  
21
    public boolean isObjectAccessSupported();
22

  
23
    public void setObjectAccessSupported(boolean objectAccessSupported);
24
    
25
    public GrammarSet getGrammars();
26
}
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Code.java
1
package org.gvsig.expressionevaluator;
2

  
3
import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
4
import org.gvsig.tools.visitor.Visitable;
5

  
6
public interface Code extends Visitable {
7

  
8
    public static final int UNDEFINED = -1;
9
    public static final int CONSTANT = 0;
10
    public static final int IDENTIFIER = 1;
11
    public static final int CALLER = 2;
12
    public static final int METHOD = 3;
13
    public static final int CODES = 4;
14
    
15
    public interface Constant extends Code {
16

  
17
        public Object value();
18

  
19
    }
20

  
21
    public interface Identifier extends Code {
22

  
23
        public String name();
24

  
25
    }
26

  
27
    public interface Caller extends Code {
28

  
29
        public static final int FUNCTION = 0;
30
        public static final int BINARY_OPERATOR = 1;
31
        public static final int UNARY_OPERATOR = 2;
32

  
33

  
34
        public String name();
35

  
36
        public Object call(Interpreter interpreter, Object[] args) throws Exception;
37

  
38
        public Function function();
39

  
40
        public Function function(Function function);
41

  
42
        public Codes parameters();
43

  
44
        public int type();
45

  
46
    }
47
    
48
    public interface Method extends Code {
49
        public Code instance();
50
        
51
        public String methodname();
52

  
53
        public Codes parameters();
54

  
55
        public Object call(Interpreter interpreter, Object[] args) throws Exception;
56
    }
57

  
58
    public static final Formatter<Code> EMPTY_FORMATTER = new Formatter<Code>() {
59
        @Override
60
        public boolean canApply(Code value) {
61
            return false;
62
        }
63

  
64
        @Override
65
        public String format(Code value) {
66
            return "";
67
        }
68
    };
69

  
70
    public int code();
71

  
72
    public Value toValue();
73

  
74
    public Value toValue(ExpressionBuilder builder);
75
    
76
    public String toString(Formatter<Code> formatter);
77
    
78
    public void link(SymbolTable symbolTable);
79
    
80
}
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractSymbolTable.java
1
package org.gvsig.expressionevaluator.spi;
2

  
3
import java.util.ArrayList;
4
import java.util.Collection;
5
import java.util.Collections;
6
import java.util.HashMap;
7
import java.util.HashSet;
8
import java.util.Iterator;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12
import org.apache.commons.lang3.Range;
13
import org.apache.commons.lang3.StringUtils;
14
import org.gvsig.expressionevaluator.Function;
15
import org.gvsig.expressionevaluator.Interpreter;
16
import org.gvsig.expressionevaluator.SymbolTable;
17
import org.gvsig.tools.script.Script;
18

  
19
/**
20
 *
21
 * @author jjdelcerro
22
 */
23
public abstract class AbstractSymbolTable implements SymbolTable {
24

  
25
    private final String name;
26

  
27
    public class ScriptFunction extends AbstractFunction {
28

  
29
        public ScriptFunction(String funcName) {
30
            super("Script", funcName, Range.between(1, Integer.MAX_VALUE));
31
        }
32

  
33
        @Override
34
        public Object call(Interpreter interpreter, Object[] args) throws Exception {
35
            for (Script script : scripts()) {
36
                try {
37
                    return script.invokeFunction(this.name(), args);
38
                } catch (NoSuchMethodException ex) {
39
                    // Si la funcion no existe en el script pasamos al siguiente
40
                    // script.
41
                }
42
            }
43
            throw new NoSuchMethodException("Can't locate funcion '" + this.name() + "'.");
44
        }
45

  
46
    }
47

  
48
    protected final List<SymbolTable> symbolTables;
49
    protected Map<String, Object> vars;
50
    protected Map<String, Function> functions;
51
    protected Map<String, Function> functionAlias;
52
    protected List<Script> scripts;
53

  
54
    public AbstractSymbolTable() {
55
        this(null);
56
    }
57
    
58
    public AbstractSymbolTable(String name) {
59
        this.name = name;
60
        this.symbolTables = new ArrayList<>();
61
        this.vars = null;
62
        this.functions = null;
63
        this.functionAlias = null;
64
        this.scripts = null;
65
    }
66

  
67
    @Override
68
    public String getName() {
69
        return name;
70
    }
71

  
72
    protected void addFunction(Function function) {
73
        if (function == null) {
74
            throw new IllegalArgumentException("function can't be null");
75
        }
76
        this.getFunctions().put(function.name().toUpperCase(), function);
77
        List<String> aliases = function.aliases();
78
        if( aliases == null || aliases.isEmpty() ) {
79
            return;
80
        }
81
        Map<String, Function> theFunctionAlias = this.getFunctionAlias();
82
        for (String alias : aliases) {
83
            if( alias!=null ) {
84
                theFunctionAlias.put(alias, function);
85
            }
86
        }
87
    }
88
    
89
    @Override
90
    public boolean addSymbolTable(SymbolTable symbolTable) {
91
        if (this.symbolTables.contains(symbolTable)) {
92
            return false;
93
        }
94
        this.symbolTables.add(symbolTable);
95
        return true;
96
    }
97

  
98
    @Override
99
    public boolean containsSymbolTable(SymbolTable symbolTable) {
100
        return this.symbolTables.contains(symbolTable);
101
    }
102
    
103
    @Override
104
    public boolean removeSymbolTable(SymbolTable symbolTable) {
105
        boolean n = this.symbolTables.remove(symbolTable);
106
        return n;
107
    }
108
    
109
    protected Map<String, Object> getVars() {
110
        if (this.vars == null) {
111
            this.vars = new HashMap<>();
112
        }
113
        return this.vars;
114
    }
115

  
116
    protected Map<String, Function> getFunctions() {
117
        if (this.functions == null) {
118
            this.functions = new HashMap<>();
119
        }
120
        return this.functions;
121
    }
122

  
123
    protected Map<String, Function> getFunctionAlias() {
124
        if (this.functionAlias == null) {
125
            this.functionAlias = new HashMap<>();
126
        }
127
        return this.functionAlias;
128
    }
129

  
130
    protected List<Script> getScripts() {
131
        if (this.scripts == null) {
132
            this.scripts = new ArrayList<>();
133
        }
134
        return this.scripts;
135
    }
136

  
137
    @Override
138
    public boolean exists(String name) {
139
        if (StringUtils.isEmpty(name)) {
140
            return false;
141
        }
142
        if (this.vars != null) {
143
            if (this.vars.containsKey(name.toUpperCase())) {
144
                return true;
145
            }
146
        }
147
        for (SymbolTable other : this.symbolTables) {
148
            if (other.exists(name)) {
149
                return true;
150
            }
151
        }
152
        return false;
153
    }
154

  
155
    @Override
156
    public Object value(String name) {
157
        if (StringUtils.isEmpty(name)) {
158
            return null;
159
        }
160
        if (this.vars != null) {
161
            name = name.toUpperCase();
162
            if (this.vars.containsKey(name)) {
163
                return this.vars.get(name);
164
            }
165
        }
166
        for (SymbolTable other : this.symbolTables) {
167
            if (other.exists(name)) {
168
                return other.value(name);
169
            }
170
        }
171
        return null;
172
    }
173

  
174
    @Override
175
    public Function function(String name) {
176
        if (StringUtils.isEmpty(name)) {
177
            return null;
178
        }
179
        if (this.functions != null) {
180
            name = name.toUpperCase();
181
            if (this.functions.containsKey(name)) {
182
                return this.functions.get(name);
183
            }
184
        }
185
        if (this.functionAlias != null) {
186
            name = name.toUpperCase();
187
            if (this.functionAlias.containsKey(name)) {
188
                return this.functionAlias.get(name);
189
            }
190
        }
191
        for (SymbolTable other : this.symbolTables) {
192
            Function fn = other.function(name);
193
            if (fn != null) {
194
                if (fn instanceof ScriptFunction) {
195
                    continue;
196
                }
197
                return fn;
198
            }
199
        }
200
        if (this.scripts == null || this.scripts.isEmpty()) {
201
            return null;
202
        }
203
        return new ScriptFunction(name);
204
    }
205

  
206
    @Override
207
    public Collection<String> variables() {
208
        Set<String> theVars = new HashSet<>();
209
        for (SymbolTable symbolTable : this.symbolTables) {
210
            theVars.addAll(symbolTable.variables());
211
        }
212
        theVars.addAll(this.localvariables());
213
        return Collections.unmodifiableCollection(theVars);
214
    }
215

  
216
    @Override
217
    public Collection<Function> functions() {
218
        Set<Function> theFunctions = new HashSet<>();
219
        for (SymbolTable symbolTable : this.symbolTables) {
220
            theFunctions.addAll(symbolTable.functions());
221
        }
222
        if (this.functions != null) {
223
            theFunctions.addAll(this.functions.values());
224
        }
225
        return Collections.unmodifiableCollection(theFunctions);
226
    }
227

  
228
    @Override
229
    public Collection<Function> localfunctions() {
230
        if( this.functions == null ) {
231
            return Collections.EMPTY_LIST;
232
        }
233
        return Collections.unmodifiableCollection(this.functions.values());
234
    }
235

  
236
    @Override
237
    public Collection<String> localvariables() {
238
        if( this.vars == null ) {
239
            return Collections.EMPTY_LIST;
240
        }
241
        return Collections.unmodifiableCollection(this.vars.keySet());
242
    }
243

  
244
    @Override
245
    public Collection<Script> scripts() {
246
        Set<Script> theScripts = new HashSet<>();
247
        for (SymbolTable symbolTable : this.symbolTables) {
248
            theScripts.addAll(symbolTable.scripts());
249
        }
250
        if (this.scripts != null) {
251
            theScripts.addAll(this.scripts);
252
        }
253
        return Collections.unmodifiableCollection(theScripts);
254
    }
255

  
256
    @Override
257
    public Iterator<Function> iterator() {
258
        return this.functions().iterator();
259
    }
260

  
261
    @Override
262
    public SymbolTable clone() throws CloneNotSupportedException {
263
        SymbolTable other = (SymbolTable) super.clone();
264
        return other;
265
    }
266

  
267
    @Override
268
    public boolean isSQLCompatible(String name) {
269
        Function f = function(name);
270
        if( f!=null ) {
271
            return f.isSQLCompatible();
272
        }
273
        return true;
274
    }
275

  
276
}
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractGrammarFactory.java
1
package org.gvsig.expressionevaluator.spi;
2

  
3
import org.gvsig.expressionevaluator.GrammarFactory;
4

  
5
/**
6
 *
7
 * @author jjdelcerro
8
 */
9
public abstract class AbstractGrammarFactory implements GrammarFactory {
10

  
11
    private final String name;
12
    private final boolean autoload;
13

  
14
    protected AbstractGrammarFactory(String name, boolean autoload) {
15
        this.name = name;
16
        this.autoload = autoload;
17
    }
18
    
19
    @Override
20
    public String getName() {
21
        return this.name;
22
    }
23

  
24
    @Override
25
    public boolean isAutoload() {
26
        return autoload;
27
    }
28
    
29
}
tags/org.gvsig.desktop-2.0.253/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractFunction.java
1
package org.gvsig.expressionevaluator.spi;
2

  
3
import java.io.File;
4
import java.io.InputStream;
5
import java.net.URI;
6
import java.net.URISyntaxException;
7
import java.net.URL;
8
import java.time.LocalDateTime;
9
import java.time.ZoneId;
10
import java.time.temporal.TemporalAccessor;
11
import java.util.ArrayList;
12
import java.util.Date;
13
import java.util.List;
14
import java.util.Locale;
15
import java.util.Objects;
16
import org.apache.commons.io.IOUtils;
17
import org.apache.commons.lang3.BooleanUtils;
18
import org.apache.commons.lang3.Range;
19
import org.apache.commons.lang3.StringUtils;
20
import org.apache.commons.math.util.MathUtils;
21
import org.gvsig.expressionevaluator.Code;
22
import org.gvsig.expressionevaluator.Codes;
23
import org.gvsig.expressionevaluator.Function;
24
import org.gvsig.expressionevaluator.I18N;
25
import org.gvsig.expressionevaluator.Interpreter;
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.primitive.Point;
28
import org.json.JSONArray;
29
import org.json.JSONObject;
30

  
31
@SuppressWarnings("UseSpecificCatch")
32
public abstract class AbstractFunction implements Function {
33
 
34
    private final String name;
35
    private String group;
36
    private Range argc;
37
    private String description;
38
    private String[] descriptionArgs;
39
    private List<String> alias;
40
    private String template;
41
    private String returnType;
42
    private boolean sqlCompatible;
43

  
44
    protected AbstractFunction(String group, String name, Range argc, String description, String template, String[] descriptionArgs, String returnType, boolean sqlCompatible) {
45
        this.name = name;
46
        this.group = group;
47
        this.argc = argc;
48
        this.description = description;
49
        this.template = template;
50
        this.descriptionArgs = descriptionArgs;
51
        this.returnType = returnType;
52
        this.sqlCompatible = sqlCompatible;
53
        load_from_resource();
54
    }
55
    protected AbstractFunction(String group, String name, Range argc, String description, String template, String[] descriptionArgs, String returnType) {
56
        this(group, name, argc, description, template, descriptionArgs, returnType, false);
57
    }
58
    
59
    protected AbstractFunction(String group, String name, Range argc, String description, String template, String[] descriptionArgs) {
60
        this(group, name, argc, description, template, null, null);
61
    }
62

  
63
    protected AbstractFunction(String group, String name, Range argc, String description, String template) {
64
        this(group, name, argc, description, template, null, null);
65
    }
66

  
67
    protected AbstractFunction(String group, String name, Range argc) {
68
        this(group, name, argc, null, null, null, null);
69
    }
70

  
71
    @Override
72
    public String name() {
73
        return this.name;
74
    }
75

  
76
    @Override
77
    public String returnType() {
78
        return this.returnType;
79
    }
80

  
81
    @Override
82
    public String group() {
83
        return this.group;
84
    }
85

  
86
    @Override
87
    public Range argc() {
88
        return argc;
89
    }
90

  
91
    @Override
92
    public String description() {
93
        return description;
94
    }
95

  
96
    @Override
97
    public String[] descriptionArgs() {
98
        return descriptionArgs;
99
    }
100

  
101
    @Override
102
    public void addAlias(String name) {
103
        if( StringUtils.isBlank(name) ) {
104
            return;
105
        }
106
        if( this.alias == null ) {
107
            this.alias = new ArrayList<>();
108
        }
109
        if( this.alias.contains(name) ) {
110
            return;
111
        }
112
        this.alias.add(name);
113
    }
114

  
115
    @Override
116
    public List<String> aliases() {
117
        return this.alias;
118
    }
119

  
120
    @Override
121
    public String template() {
122
        return this.template;
123
    }
124

  
125
    @Override
126
    public boolean isOperator() {
127
        return false;
128
    }
129

  
130
    @Override
131
    public boolean useArgumentsInsteadObjects() {
132
        return false;
133
    }
134

  
135
    @Override
136
    public boolean isSQLCompatible() {
137
        return sqlCompatible;
138
    }
139

  
140
    @Override
141
    public boolean allowConstantFolding() {
142
        return false;
143
    }
144
    
145
    @Override
146
    public Object call(Interpreter interpreter, Codes args) throws Exception {
147
        return null;
148
    }
149
    
150
    protected int getInt(Object args[], int n) {
151
        if( args.length < n  ) {
152
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
153
        }
154
        Object value = args[n];
155
        if( value == null ) {
156
            throw new IllegalArgumentException(I18N.Illegal_null_value_for_argument_XargnX_of_XIdentifierX_function(name(), n));
157
        }
158
        if( !(value instanceof Number) ) {
159
            String type = value.getClass().getCanonicalName();
160
            throw new IllegalArgumentException(
161
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
162
                    I18N.Expected_XexpectedX_and_found_XfoundX("Number",type)
163
            );
164
        }
165
        return ((Number)value).intValue();
166
    }
167

  
168
    protected long getLong(Object args[], int n) {
169
        if( args.length < n  ) {
170
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
171
        }
172
        Object value = args[n];
173
        if( value == null ) {
174
            throw new IllegalArgumentException(I18N.Illegal_null_value_for_argument_XargnX_of_XIdentifierX_function(name(), n));
175
        }
176
        if( !(value instanceof Number) ) {
177
            String type = value.getClass().getCanonicalName();
178
            throw new IllegalArgumentException(
179
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
180
                    I18N.Expected_XexpectedX_and_found_XfoundX("Number",type)
181
            );
182
        }
183
        return ((Number)value).longValue();
184
    }
185

  
186
    protected double getDouble(Object args[], int n) {
187
        if( args.length < n  ) {
188
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
189
        }
190
        Object value = args[n];
191
        if( value == null ) {
192
            throw new IllegalArgumentException(I18N.Illegal_null_value_for_argument_XargnX_of_XIdentifierX_function(name(), n));
193
        }
194
        if( !(value instanceof Number) ) {
195
            String type = value.getClass().getCanonicalName();
196
            throw new IllegalArgumentException(
197
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
198
                    I18N.Expected_XexpectedX_and_found_XfoundX("Number",type)
199
            );
200
        }
201
        return ((Number)value).doubleValue();
202
    }
203
    
204
    protected String getStr(Object args[], int n) {
205
        if( args.length < n  ) {
206
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
207
        }
208
        return Objects.toString(args[n], "");
209
    }
210
    
211
    protected File getFile(Object args[], int n) {
212
        if( args.length < n  ) {
213
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
214
        }
215
        Object arg = args[n];
216
        if( arg == null ) {
217
            return null;
218
        }
219
        if( arg instanceof File ) {
220
            return (File)arg;
221
        }
222
        if( arg instanceof URL ) {
223
            try {
224
                return new File(((URL)arg).toURI());
225
            } catch (URISyntaxException ex) {
226
                return null;
227
            }
228
        }
229
        if( arg instanceof URI ) {
230
            return new File(((URI)arg));
231
        }
232
        String s = Objects.toString(arg, null);
233
        if( s == null ) {
234
            return null;
235
        }
236
        File f = new File(s);
237
        return f;
238
    }
239
    
240
    protected Object getObject(Object args[], int n) {
241
        if( args.length < n  ) {
242
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
243
        }
244
        return args[n];
245
    }
246
    
247
    protected Object getObject(Interpreter interpreter, Codes args, int n) {
248
        if( args.size() < n  ) {
249
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.size(), n));
250
        }
251
        Code arg = args.get(n);
252
        Object value = interpreter.run(arg);
253
        return value;
254
    }
255
    
256
    protected Geometry getGeom(Object[] args, int n) {
257
        return this.getGeom(args, n, false);
258
    }
259
    
260
    protected Geometry getGeom(Object[] args, int n, boolean allowNull) {
261
        if( args.length < n  ) {
262
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
263
        }
264
        Object value = args[n];
265
        if( value == null ) {
266
            if( allowNull ) {
267
                return null;
268
            }
269
            throw new IllegalArgumentException(I18N.Illegal_null_value_for_argument_XargnX_of_XIdentifierX_function(name(), n));
270
        }
271
        if( !(value instanceof Geometry) ) {
272
            String type = value.getClass().getCanonicalName();
273
            throw new IllegalArgumentException(
274
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
275
                    I18N.Expected_XexpectedX_and_found_XfoundX("Geometry",type)
276
            );
277
        }
278
        return (Geometry)value;
279
    }
280

  
281
    protected Point getPoint(Object[] args, int n) {
282
        if( args.length < n  ) {
283
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
284
        }
285
        Object value = args[n];
286
        if( value == null ) {
287
            return null;
288
        }
289
        if( !(value instanceof Point) ) {
290
            String type = value.getClass().getCanonicalName();
291
            throw new IllegalArgumentException(
292
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
293
                    I18N.Expected_XexpectedX_and_found_XfoundX("Point",type)
294
            );
295
        }
296
        return (Point)value;
297
    }
298
    
299
    protected Date getDate(Object[] args, int n) {
300
        if( args.length < n  ) {
301
            throw new IllegalArgumentException(I18N.Required_argument_XargnX_and_only_found_XargcX_in_call_to_XIdentifierX(name(), args.length, n));
302
        }
303
        Object value = args[n];
304
        if( value == null ) {
305
            return null;
306
        }
307
        if( !(value instanceof Date) ) {
308
            String type = value.getClass().getCanonicalName();
309
            throw new IllegalArgumentException(
310
                    I18N.The_type_of_the_argument_XargnX_for_the_XIdentifierX_function_is_incorrect(name(), n) + " " +
311
                    I18N.Expected_XexpectedX_and_found_XfoundX("Date",type)
312
            );
313
        }
314
        return (Date)value;
315
    }
316
    
317
    protected LocalDateTime getLocalDateTime(Object[] args, int n) {
318
        if( args.length < n  ) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff