Revision 19456
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/filter/FeatureFilterParser.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.Map.Entry; |
4 | 4 |
|
5 |
import javax.swing.text.html.parser.Entity;
|
|
6 |
|
|
5 |
import org.gvsig.data.exception.ParseException;
|
|
6 |
import org.gvsig.data.exception.ReadException; |
|
7 | 7 |
import org.gvsig.data.vectorial.IFeature; |
8 | 8 |
import org.gvsig.data.vectorial.IFeatureType; |
9 | 9 |
import org.medfoster.sqljep.BaseJEP; |
10 |
import org.medfoster.sqljep.ParseException; |
|
11 | 10 |
|
12 |
import com.sun.org.apache.bcel.internal.generic.NEW; |
|
13 | 11 |
|
14 | 12 |
public class FeatureFilterParser extends BaseJEP { |
15 | 13 |
private IFeatureType featureType; |
16 | 14 |
private IFeature feature; |
17 | 15 |
private boolean parsed = false; |
16 |
private String expresion; |
|
18 | 17 |
|
19 | 18 |
public FeatureFilterParser(String expression,IFeatureType featureType) { |
20 | 19 |
super(expression); |
20 |
this.expresion=expression; |
|
21 | 21 |
this.featureType = featureType; |
22 | 22 |
} |
23 | 23 |
|
... | ... | |
25 | 25 |
return featureType.indexOf(fieldName); |
26 | 26 |
} |
27 | 27 |
|
28 |
public Comparable getColumnObject(int fieldPos) throws ParseException {
|
|
28 |
public Comparable getColumnObject(int fieldPos){ |
|
29 | 29 |
return (Comparable)this.feature.get(fieldPos); |
30 | 30 |
} |
31 | 31 |
|
32 |
public Entry getVariable(String arg0) throws ParseException {
|
|
32 |
public Entry getVariable(String arg0){ |
|
33 | 33 |
return new FeatureEntry(arg0); |
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
|
37 |
public boolean match(IFeature feature) throws ParseException { |
|
38 |
this.feature = feature; |
|
39 |
if (!parsed){ |
|
40 |
this.parseExpression(); |
|
41 |
parsed=true; |
|
37 |
public boolean match(IFeature feature) throws ReadException{ |
|
38 |
try{ |
|
39 |
this.feature = feature; |
|
40 |
if (!parsed){ |
|
41 |
this.parseExpression(); |
|
42 |
parsed=true; |
|
43 |
} |
|
44 |
Comparable value = super.getValue(); |
|
45 |
return value.compareTo(Boolean.TRUE) == 0; |
|
46 |
} catch (org.medfoster.sqljep.ParseException e) { |
|
47 |
throw new ParseException("FeatureFilterParser",this.expresion,e); |
|
42 | 48 |
} |
43 |
Comparable value = super.getValue(); |
|
44 |
return value.compareTo(Boolean.TRUE) == 0; |
|
45 | 49 |
} |
46 | 50 |
|
47 | 51 |
private class FeatureEntry implements Entry{ |
trunk/libraries/libDataSource/src/org/gvsig/data/exception/package.html | ||
---|---|---|
26 | 26 |
<td> |
27 | 27 |
</td> |
28 | 28 |
<td> |
29 |
ParseException |
|
30 |
</td> |
|
31 |
</tr> |
|
32 |
|
|
33 |
<tr> |
|
34 |
<td> |
|
35 |
</td> |
|
36 |
<td> |
|
29 | 37 |
CloseException |
30 | 38 |
</td> |
31 | 39 |
</tr> |
trunk/libraries/libDataSource/src/org/gvsig/data/exception/ParseException.java | ||
---|---|---|
1 |
package org.gvsig.data.exception; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.gvsig.exceptions.IExceptionTranslator; |
|
8 |
|
|
9 |
public class ParseException extends ReadException { |
|
10 |
private String expression = null; |
|
11 |
|
|
12 |
public ParseException(String name, String expression,Throwable exception) { |
|
13 |
super(name,exception); |
|
14 |
this.expression = expression; |
|
15 |
init(); |
|
16 |
initCause(exception); |
|
17 |
} |
|
18 |
|
|
19 |
private void init() { |
|
20 |
messageKey = "error_parsing_expression"; |
|
21 |
formatString = "Error parsing expression: %(expression)"; |
|
22 |
} |
|
23 |
|
|
24 |
protected Map values() { |
|
25 |
Map params = super.values(); |
|
26 |
params.put("expression",expression); |
|
27 |
return params; |
|
28 |
} |
|
29 |
|
|
30 |
} |
|
0 | 31 |
trunk/libraries/libDataSource/.classpath | ||
---|---|---|
3 | 3 |
<classpathentry kind="src" path="src"/> |
4 | 4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
5 | 5 |
<classpathentry kind="lib" path="/libFMap/lib/org.cresques.cts.jar" sourcepath="/libProjection"/> |
6 |
<classpathentry kind="lib" path="lib/sqljep-0.2.jar" sourcepath="/SQLJEP"/> |
|
7 | 6 |
<classpathentry kind="lib" path="lib/org.gvsig.exceptions.jar" sourcepath="/libExceptions"/> |
8 | 7 |
<classpathentry kind="src" path="src-test"/> |
9 | 8 |
<classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.1/src/org.junit_3.8.1/junitsrc.zip"/> |
9 |
<classpathentry combineaccessrules="false" kind="src" path="/libMetadata"/> |
|
10 |
<classpathentry combineaccessrules="false" kind="src" path="/SQLJEP"/> |
|
10 | 11 |
<classpathentry kind="output" path="bin"/> |
11 | 12 |
</classpath> |
Also available in: Unified diff