Revision 40779
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/SLDSupportManager.java | ||
---|---|---|
1 |
package org.gvsig.sldsupport; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.io.OutputStream; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
|
9 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
10 |
import org.gvsig.sldsupport.exception.SLDReadException; |
|
11 |
import org.gvsig.sldsupport.exception.SLDWriteException; |
|
12 |
import org.gvsig.sldsupport.exception.UnsupportedSLDVersionException; |
|
13 |
import org.gvsig.sldsupport.feature.SLDExtent; |
|
14 |
import org.gvsig.sldsupport.feature.SLDFeatureTypeConstraint; |
|
15 |
import org.gvsig.sldsupport.feature.SLDLayerFeatureConstraints; |
|
16 |
import org.gvsig.sldsupport.graphic.SLDExternalGraphic; |
|
17 |
import org.gvsig.sldsupport.graphic.SLDFill; |
|
18 |
import org.gvsig.sldsupport.graphic.SLDGraphic; |
|
19 |
import org.gvsig.sldsupport.graphic.SLDLegendGraphic; |
|
20 |
import org.gvsig.sldsupport.graphic.SLDMark; |
|
21 |
import org.gvsig.sldsupport.graphic.SLDStroke; |
|
22 |
import org.gvsig.sldsupport.io.SLDLegendReader; |
|
23 |
import org.gvsig.sldsupport.io.SLDLegendWriter; |
|
24 |
import org.gvsig.sldsupport.layer.ISLDLayer; |
|
25 |
import org.gvsig.sldsupport.layer.SLDNamedLayer; |
|
26 |
import org.gvsig.sldsupport.layer.SLDUserLayer; |
|
27 |
import org.gvsig.sldsupport.rule.SLDRule; |
|
28 |
import org.gvsig.sldsupport.style.SLDFeatureTypeStyle; |
|
29 |
import org.gvsig.sldsupport.style.SLDNamedStyle; |
|
30 |
import org.gvsig.sldsupport.style.SLDUserStyle; |
|
31 |
import org.gvsig.sldsupport.symbolizer.SLDLineSymbolizer; |
|
32 |
import org.gvsig.sldsupport.symbolizer.SLDMultiLineSymbolizer; |
|
33 |
import org.gvsig.sldsupport.symbolizer.SLDMultiPointSymbolizer; |
|
34 |
import org.gvsig.sldsupport.symbolizer.SLDMultiPolygonSymbolizer; |
|
35 |
import org.gvsig.sldsupport.symbolizer.SLDMultiShapeSymbolizer; |
|
36 |
import org.gvsig.sldsupport.symbolizer.SLDPointSymbolizer; |
|
37 |
import org.gvsig.sldsupport.symbolizer.SLDPolygonSymbolizer; |
|
38 |
|
|
39 |
public interface SLDSupportManager { |
|
40 |
|
|
41 |
public List<ISLDLayer> getSLDLayers(File f, String v) throws SLDReadException; |
|
42 |
public ILegend getLegend( |
|
43 |
ISLDLayer sld_layer, |
|
44 |
VectorLayer target_layer, |
|
45 |
String v) throws SLDReadException; |
|
46 |
|
|
47 |
// ============================================ |
|
48 |
|
|
49 |
public void writeLegend( |
|
50 |
ILegend leg, |
|
51 |
String layer_name, |
|
52 |
File out_file, |
|
53 |
String version) throws IOException, SLDWriteException; |
|
54 |
|
|
55 |
// ============================================ |
|
56 |
public List<String> getSupportedVersions(); |
|
57 |
// ============================================ |
|
58 |
|
|
59 |
public void registerLegendReader(SLDLegendReader reader); |
|
60 |
public void registerLegendWriter(SLDLegendWriter writer); |
|
61 |
|
|
62 |
// ============================================= |
|
63 |
|
|
64 |
// ============= SLD object model API ====================== |
|
65 |
|
|
66 |
public SLDExtent createSLDExtent(String version) |
|
67 |
throws UnsupportedSLDVersionException; |
|
68 |
public SLDFeatureTypeConstraint createSLDFeatureTypeConstraint(String version) |
|
69 |
throws UnsupportedSLDVersionException; |
|
70 |
public SLDLayerFeatureConstraints createSLDLayerFeatureConstraints(String version) |
|
71 |
throws UnsupportedSLDVersionException; |
|
72 |
public SLDExternalGraphic createSLDExternalGraphic(String version) |
|
73 |
throws UnsupportedSLDVersionException; |
|
74 |
|
|
75 |
public SLDFill createSLDFill(String version) |
|
76 |
throws UnsupportedSLDVersionException; |
|
77 |
public SLDGraphic createSLDGraphic(String version) |
|
78 |
throws UnsupportedSLDVersionException; |
|
79 |
public SLDLegendGraphic createSLDLegendGraphic(String version) |
|
80 |
throws UnsupportedSLDVersionException; |
|
81 |
public SLDMark createSLDMark(String version) |
|
82 |
throws UnsupportedSLDVersionException; |
|
83 |
|
|
84 |
public SLDStroke createSLDStroke(String version) |
|
85 |
throws UnsupportedSLDVersionException; |
|
86 |
|
|
87 |
public SLDNamedLayer createSLDNamedLayer(String version) |
|
88 |
throws UnsupportedSLDVersionException; |
|
89 |
public SLDUserLayer createSLDUserLayer(String version) |
|
90 |
throws UnsupportedSLDVersionException; |
|
91 |
public SLDRule createSLDRule(String version) |
|
92 |
throws UnsupportedSLDVersionException; |
|
93 |
|
|
94 |
public SLDFeatureTypeStyle createSLDFeatureTypeStyle(String version) |
|
95 |
throws UnsupportedSLDVersionException; |
|
96 |
|
|
97 |
public SLDNamedStyle createSLDNamedStyle(String version) |
|
98 |
throws UnsupportedSLDVersionException; |
|
99 |
public SLDUserStyle createSLDUserStyle(String version) |
|
100 |
throws UnsupportedSLDVersionException; |
|
101 |
|
|
102 |
public SLDPointSymbolizer createSLDPointSymbolizer(String version) |
|
103 |
throws UnsupportedSLDVersionException; |
|
104 |
public SLDMultiPointSymbolizer createSLDMultiPointSymbolizer(String version) |
|
105 |
throws UnsupportedSLDVersionException; |
|
106 |
public SLDLineSymbolizer createSLDLineSymbolizer(String version) |
|
107 |
throws UnsupportedSLDVersionException; |
|
108 |
public SLDMultiLineSymbolizer createSLDMultiLineSymbolizer(String version) |
|
109 |
throws UnsupportedSLDVersionException; |
|
110 |
|
|
111 |
public SLDPolygonSymbolizer createSLDPolygonSymbolizer(String version) |
|
112 |
throws UnsupportedSLDVersionException; |
|
113 |
public SLDMultiPolygonSymbolizer createSLDMultiPolygonSymbolizer(String version) |
|
114 |
throws UnsupportedSLDVersionException; |
|
115 |
|
|
116 |
public SLDMultiShapeSymbolizer createSLDMultiShapeSymbolizer(String version) |
|
117 |
throws UnsupportedSLDVersionException; |
|
118 |
|
|
119 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/feature/ISLDFeatures.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.feature; |
|
42 |
|
|
43 |
import java.io.IOException; |
|
44 |
|
|
45 |
import org.gvsig.sldsupport.exception.SLDReadException; |
|
46 |
import org.xmlpull.v1.XmlPullParser; |
|
47 |
import org.xmlpull.v1.XmlPullParserException; |
|
48 |
|
|
49 |
/** |
|
50 |
* Interface that has to be implemented by all the SLDClases. |
|
51 |
* |
|
52 |
* |
|
53 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188 |
|
54 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
55 |
* |
|
56 |
*/ |
|
57 |
|
|
58 |
public interface ISLDFeatures { |
|
59 |
|
|
60 |
/** |
|
61 |
* Parses the contents of the SLD document to extract the |
|
62 |
* information about a specific SLD Feature |
|
63 |
* |
|
64 |
*/ |
|
65 |
public void parse(XmlPullParser parser, int cuTag, String expressionType) |
|
66 |
throws XmlPullParserException, IOException, SLDReadException; |
|
67 |
/** |
|
68 |
* Translate the object into an XML String according with |
|
69 |
* the Styled Layer Specification |
|
70 |
* |
|
71 |
* @return |
|
72 |
*/ |
|
73 |
public String toXML(); |
|
74 |
|
|
75 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/feature/SLDExtent.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.feature; |
|
42 |
/** |
|
43 |
* Implements the Extent element of an SLD implementation specification .<p> |
|
44 |
* When used in a UserLayer (<code>SLDUserDefinedLayer</code>), it defines what |
|
45 |
* features are to be included in the layer and when used in a NamedLayer (<code>SLDNamedLayer</code>) |
|
46 |
* , it filters the features that are part of the named layer. |
|
47 |
* |
|
48 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188 |
|
49 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es |
|
50 |
*/ |
|
51 |
public abstract class SLDExtent implements ISLDFeatures { |
|
52 |
|
|
53 |
protected String name; |
|
54 |
protected String value; |
|
55 |
|
|
56 |
public String getName() { |
|
57 |
return name; |
|
58 |
} |
|
59 |
public void setName(String name) { |
|
60 |
this.name = name; |
|
61 |
} |
|
62 |
public String getValue() { |
|
63 |
return value; |
|
64 |
} |
|
65 |
public void setValue(String value) { |
|
66 |
this.value = value; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/feature/SLDLayerFeatureConstraints.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.feature; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
/** |
|
45 |
* Implements the LayerFeatureConstraints element of an SLD implementation specification |
|
46 |
* .<p> |
|
47 |
* The LayerFeatureConstraints element is used to specify what features of what feature |
|
48 |
* types are to be rendered in a layer.<p> |
|
49 |
* |
|
50 |
* @see SLDFeatureTypeConstraint |
|
51 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188 |
|
52 |
* |
|
53 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es |
|
54 |
*/ |
|
55 |
|
|
56 |
public abstract class SLDLayerFeatureConstraints implements ISLDFeatures{ |
|
57 |
|
|
58 |
protected ArrayList<SLDFeatureTypeConstraint>featureTypeConstraint = new ArrayList<SLDFeatureTypeConstraint>(); |
|
59 |
|
|
60 |
public ArrayList<SLDFeatureTypeConstraint> getFeatureTypeConstraint() { |
|
61 |
return featureTypeConstraint; |
|
62 |
} |
|
63 |
|
|
64 |
public void setFeatureTypeConstraint( |
|
65 |
ArrayList<SLDFeatureTypeConstraint> featureTypeConstraint) { |
|
66 |
this.featureTypeConstraint = featureTypeConstraint; |
|
67 |
} |
|
68 |
|
|
69 |
public void addFeatureTypeConstraint(SLDFeatureTypeConstraint feat) { |
|
70 |
this.featureTypeConstraint.add(feat); |
|
71 |
} |
|
72 |
|
|
73 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/feature/SLDFeatureTypeConstraint.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.feature; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
|
|
45 |
import org.gvsig.sldsupport.filterencoding.Filter; |
|
46 |
|
|
47 |
/** |
|
48 |
* Implements the FeatureTypeConstraint element of an SLD implementation |
|
49 |
* specification.<p> |
|
50 |
* A FeatureTypeConstraint element is used to identify a feature type by a |
|
51 |
* well-known name, using the FeatureTypeName element. Any positive number of |
|
52 |
* FeatureTypeConstraints may be used to define the features of a layer, though |
|
53 |
* all FeatureTypeConstraints in a UserLayer must come from the same WFS source. |
|
54 |
* |
|
55 |
* @see SLDExtent |
|
56 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188 |
|
57 |
* |
|
58 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es |
|
59 |
*/ |
|
60 |
public abstract class SLDFeatureTypeConstraint implements ISLDFeatures { |
|
61 |
|
|
62 |
protected String featureTypeName; |
|
63 |
protected ArrayList<SLDExtent>sldExtent = new ArrayList<SLDExtent>(); |
|
64 |
protected Filter filter = new Filter(); |
|
65 |
|
|
66 |
public String getFeatureTypeName() { |
|
67 |
return featureTypeName; |
|
68 |
} |
|
69 |
public void setFeatureTypeName(String featureTypeName) { |
|
70 |
this.featureTypeName = featureTypeName; |
|
71 |
} |
|
72 |
public ArrayList<SLDExtent> getSldExtent() { |
|
73 |
return sldExtent; |
|
74 |
} |
|
75 |
public void setSldExtent(ArrayList<SLDExtent> sldExtent) { |
|
76 |
this.sldExtent = sldExtent; |
|
77 |
} |
|
78 |
|
|
79 |
public void addSldExtent(SLDExtent extent) { |
|
80 |
this.sldExtent.add(extent); |
|
81 |
} |
|
82 |
public Filter getFilter() { |
|
83 |
return filter; |
|
84 |
} |
|
85 |
public void setFilter(Filter filter) { |
|
86 |
this.filter = filter; |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/FIsLikeOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding; |
|
42 |
|
|
43 |
import java.io.IOException; |
|
44 |
|
|
45 |
import org.xmlpull.v1.XmlPullParser; |
|
46 |
import org.xmlpull.v1.XmlPullParserException; |
|
47 |
/** |
|
48 |
* Implements the main functionalities to parse an ProperyIsLike element |
|
49 |
* of a Filter Encoding expression<br> |
|
50 |
* |
|
51 |
* The PropertyIsLike element is intended to encode a character string comparison |
|
52 |
* operator with pattern matching. |
|
53 |
* |
|
54 |
* @see http://www.opengeospatial.org/standards/filter |
|
55 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es |
|
56 |
*/ |
|
57 |
public class FIsLikeOperator { |
|
58 |
|
|
59 |
protected String propName; |
|
60 |
protected String literal; |
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
public void parse(XmlPullParser parser, int Tag2, String expressionType) |
|
66 |
throws XmlPullParserException, IOException { |
|
67 |
|
|
68 |
int currentTag; |
|
69 |
boolean end = false; |
|
70 |
currentTag = Tag2; |
|
71 |
|
|
72 |
parser.require(XmlPullParser.START_TAG, null, FilterTags.PROPERTYISLIKE); |
|
73 |
|
|
74 |
while (!end) |
|
75 |
{ |
|
76 |
switch(currentTag) |
|
77 |
{ |
|
78 |
case XmlPullParser.START_TAG: |
|
79 |
if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYNAME))==0) { |
|
80 |
this.propName = parser.nextText(); |
|
81 |
|
|
82 |
} |
|
83 |
else if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.LITERAL))==0) { |
|
84 |
this.literal = parser.nextText(); |
|
85 |
|
|
86 |
} |
|
87 |
break; |
|
88 |
case XmlPullParser.END_TAG: |
|
89 |
if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISLIKE)) == 0) |
|
90 |
end = true; |
|
91 |
break; |
|
92 |
case XmlPullParser.TEXT: |
|
93 |
break; |
|
94 |
} |
|
95 |
if (!end) |
|
96 |
currentTag = parser.next(); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
public String getPropName() { return propName; } |
|
101 |
public String getLiteral() {return literal;} |
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/LabelExpressionOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
public class LabelExpressionOperator extends Operator{ |
|
47 |
|
|
48 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
49 |
|
|
50 |
public LabelExpressionOperator(Hashtable<String, Object> symbol_table) { |
|
51 |
super(symbol_table); |
|
52 |
} |
|
53 |
|
|
54 |
public void addArgument(int i, Expression arg) { |
|
55 |
arguments.add(i, arg); |
|
56 |
} |
|
57 |
|
|
58 |
public void check() |
|
59 |
throws ExpressionException { |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
public Object evaluate() |
|
64 |
throws ExpressionException { |
|
65 |
|
|
66 |
ArrayList<String> result = new ArrayList<String>(); |
|
67 |
|
|
68 |
if(arguments != null) { |
|
69 |
|
|
70 |
for (int i = 0; i < arguments.size(); i++) { |
|
71 |
Expression function = (Expression)arguments.get(i); |
|
72 |
if(function instanceof LabelExpressionOperator) { |
|
73 |
Object[] labResult = (Object[]) function.evaluate(); |
|
74 |
if(labResult != null) { |
|
75 |
for (int j = labResult.length-1; j >= 0; j--) { |
|
76 |
result.add(0,(String)labResult[j]); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
else result.add(0, (String) (function.evaluate().toString())); |
|
81 |
} |
|
82 |
return result.toArray(new String[0]); |
|
83 |
} |
|
84 |
|
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
88 |
public ArrayList<Expression> getArguments() { |
|
89 |
return arguments; |
|
90 |
} |
|
91 |
|
|
92 |
public String getName() { |
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
96 |
public String getPattern() { |
|
97 |
throw new Error ("Not yet implemented"); |
|
98 |
} |
|
99 |
|
|
100 |
public void setArguments(ArrayList<Expression> arguments) { |
|
101 |
this.arguments = arguments; |
|
102 |
} |
|
103 |
|
|
104 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/NotOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
import org.gvsig.i18n.Messages; |
|
47 |
|
|
48 |
/** |
|
49 |
* Implements the funcionality of the negation operator which only can |
|
50 |
* be used in boolean expressions |
|
51 |
* |
|
52 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
53 |
* |
|
54 |
*/ |
|
55 |
public class NotOperator extends Operator { |
|
56 |
|
|
57 |
|
|
58 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
59 |
|
|
60 |
public String getName() { |
|
61 |
return OperationTags.NOT_OP; |
|
62 |
} |
|
63 |
|
|
64 |
public NotOperator(Hashtable<String, Object> symbol_table) { |
|
65 |
super(symbol_table); |
|
66 |
} |
|
67 |
|
|
68 |
public Object evaluate()throws ExpressionException { |
|
69 |
|
|
70 |
if(arguments.size() > 1) |
|
71 |
throw new ExpressionException(ExpressionException.INCORRECT_NUMBER_OF_ARGUMENTS); |
|
72 |
Object eval=((Expression)arguments.get(0)).evaluate(); |
|
73 |
if (eval==null) |
|
74 |
return false; |
|
75 |
boolean result = ((Boolean)eval).booleanValue(); |
|
76 |
if (result) |
|
77 |
return false; |
|
78 |
else |
|
79 |
return true; |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
public Class getResultType() |
|
84 |
{ |
|
85 |
return Boolean.class; |
|
86 |
} |
|
87 |
|
|
88 |
public void addArgument(int i, Expression arg) { |
|
89 |
|
|
90 |
arguments.add(i, arg); |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
|
|
95 |
public String getPattern() { |
|
96 |
return OperationTags.NOT_OP +"("+ |
|
97 |
Messages.getText(OperationTags.OPERAND)+")\n"+ |
|
98 |
Messages.getText(OperationTags.OPERAND)+" = "+ |
|
99 |
Messages.getText(OperationTags.BOOLEAN_VALUE); |
|
100 |
} |
|
101 |
|
|
102 |
public ArrayList<Expression> getArguments() { |
|
103 |
return arguments; |
|
104 |
} |
|
105 |
|
|
106 |
public void setArguments(ArrayList<Expression> arguments) { |
|
107 |
this.arguments = arguments; |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
public void check() throws ExpressionException { |
|
112 |
if (arguments.size() != 1) |
|
113 |
throw new ExpressionException(ExpressionException.INCORRECT_NUMBER_OF_ARGUMENTS); |
|
114 |
|
|
115 |
if(! (arguments.get(0).evaluate() instanceof Boolean)) |
|
116 |
throw new ExpressionException(ExpressionException.CLASS_CASTING_EXCEPTION); |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/ExpressionException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
/** |
|
43 |
* Exception that can be caused by the incorrect creation of an Expression |
|
44 |
* |
|
45 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class ExpressionException extends Exception { |
|
49 |
|
|
50 |
public static final int CLASS_CASTING_EXCEPTION = 1; |
|
51 |
public static final int INCORRECT_NUMBER_OF_ARGUMENTS = 2; |
|
52 |
public static final int ARGUMENT_ADDED_TO_CONSTANT = 4; |
|
53 |
public static final int DIVIDED_BY_CERO = 8; |
|
54 |
public static final int NO_CLASSIF_NAME = 16; |
|
55 |
|
|
56 |
private int type; |
|
57 |
|
|
58 |
public ExpressionException(int type) { |
|
59 |
super(); |
|
60 |
this.type = type; |
|
61 |
} |
|
62 |
|
|
63 |
public int getType() { |
|
64 |
return type; |
|
65 |
} |
|
66 |
|
|
67 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/AndOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
import org.gvsig.i18n.Messages; |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* Implements the funcionality of an AND operator |
|
53 |
* |
|
54 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
55 |
* |
|
56 |
*/ |
|
57 |
public class AndOperator extends Operator{ |
|
58 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
59 |
|
|
60 |
public String getName() { |
|
61 |
return OperationTags.AND_OP; |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
public AndOperator(Hashtable<String, Object> symbol_table) { |
|
66 |
super(symbol_table); |
|
67 |
} |
|
68 |
|
|
69 |
public Object evaluate()throws ExpressionException { |
|
70 |
Object value1=((Expression)arguments.get(0)).evaluate(); |
|
71 |
if (value1 ==null) |
|
72 |
return false; |
|
73 |
Boolean result = ((Boolean)value1).booleanValue(); |
|
74 |
|
|
75 |
for (int i = 1; i < arguments.size(); i++){ |
|
76 |
Expression function = (Expression)arguments.get(i); |
|
77 |
Object value2=function.evaluate(); |
|
78 |
if (value2 ==null) |
|
79 |
return false; |
|
80 |
result = result && ((Boolean)value2).booleanValue(); |
|
81 |
} |
|
82 |
return result; |
|
83 |
} |
|
84 |
|
|
85 |
public void addArgument(int i, Expression arg) { |
|
86 |
arguments.add(i, arg); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
public String getPattern() { |
|
91 |
return "("+Messages.getText(OperationTags.OPERAND) |
|
92 |
+ OperationTags.AND_OP +Messages.getText(OperationTags.OPERAND)+ ")\n"+ |
|
93 |
Messages.getText(OperationTags.OPERAND) +" = "+ |
|
94 |
Messages.getText(OperationTags.BOOLEAN_VALUE); } |
|
95 |
|
|
96 |
public ArrayList<Expression> getArguments() { |
|
97 |
return arguments; |
|
98 |
} |
|
99 |
|
|
100 |
public void setArguments(ArrayList<Expression> arguments) { |
|
101 |
this.arguments = arguments; |
|
102 |
} |
|
103 |
|
|
104 |
public void check() throws ExpressionException { |
|
105 |
|
|
106 |
|
|
107 |
for (int i = 0; i < arguments.size(); i++) { |
|
108 |
if(!(arguments.get(i).evaluate()instanceof Boolean)) |
|
109 |
throw new ExpressionException(ExpressionException.CLASS_CASTING_EXCEPTION); |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/NeOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
import org.gvsig.i18n.Messages; |
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* Implements the funcionality of the not equals operation which can |
|
51 |
* be used with numerical or boolean values |
|
52 |
* |
|
53 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
54 |
* |
|
55 |
*/ |
|
56 |
|
|
57 |
public class NeOperator extends Operator{ |
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
62 |
|
|
63 |
public String getName() { |
|
64 |
return OperationTags.NEQ_OP; |
|
65 |
} |
|
66 |
|
|
67 |
public NeOperator(Hashtable<String, Object> symbol_table) { |
|
68 |
super(symbol_table); |
|
69 |
} |
|
70 |
|
|
71 |
public Object evaluate() throws ExpressionException{ |
|
72 |
Object value1 = ((Expression)arguments.get(0)).evaluate(); |
|
73 |
Object value2 = ((Expression)arguments.get(1)).evaluate(); |
|
74 |
|
|
75 |
if (value1==null || value2==null){ |
|
76 |
return false; |
|
77 |
} |
|
78 |
if (value1.equals(value2)) |
|
79 |
return false; |
|
80 |
else |
|
81 |
return true; |
|
82 |
} |
|
83 |
|
|
84 |
public void addArgument(int i, Expression arg) { |
|
85 |
arguments.add(i, arg); |
|
86 |
|
|
87 |
} |
|
88 |
|
|
89 |
public String getPattern() { |
|
90 |
return "("+Messages.getText(OperationTags.OPERAND) |
|
91 |
+ OperationTags.NEQ_OP +Messages.getText(OperationTags.OPERAND)+ ")\n"+ |
|
92 |
Messages.getText(OperationTags.OPERAND) +" = "+ |
|
93 |
Messages.getText(OperationTags.NUMERIC_OR_BOOLEAN_CONSTANT); |
|
94 |
} |
|
95 |
|
|
96 |
public ArrayList<Expression> getArguments() { |
|
97 |
return arguments; |
|
98 |
} |
|
99 |
|
|
100 |
public void setArguments(ArrayList<Expression> arguments) { |
|
101 |
this.arguments = arguments; |
|
102 |
} |
|
103 |
|
|
104 |
public void check() throws ExpressionException { |
|
105 |
if (arguments.size() != 2) |
|
106 |
throw new ExpressionException(ExpressionException.INCORRECT_NUMBER_OF_ARGUMENTS); |
|
107 |
|
|
108 |
for (int i = 1; i < arguments.size(); i++) { |
|
109 |
if((arguments.get(i).evaluate().getClass())!=(arguments.get(0).evaluate().getClass())) |
|
110 |
throw new ExpressionException(ExpressionException.CLASS_CASTING_EXCEPTION); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/FieldExpressionOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
public class FieldExpressionOperator extends Operator { |
|
47 |
|
|
48 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
49 |
|
|
50 |
public FieldExpressionOperator(Hashtable<String, Object> symbol_table) { |
|
51 |
super(symbol_table); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
public void addArgument(int i, Expression arg) { |
|
56 |
arguments.add(i, arg); |
|
57 |
} |
|
58 |
|
|
59 |
public void check() |
|
60 |
throws ExpressionException { |
|
61 |
} |
|
62 |
|
|
63 |
public Object evaluate() |
|
64 |
throws ExpressionException { |
|
65 |
|
|
66 |
String result = ""; |
|
67 |
|
|
68 |
if(arguments != null) { |
|
69 |
|
|
70 |
for (int i = arguments.size()-1; i >= 0; i--) { |
|
71 |
Expression function = (Expression)arguments.get(i); |
|
72 |
Object value1=function.evaluate(); |
|
73 |
if (value1==null) |
|
74 |
value1=""; |
|
75 |
result += ((String) (value1.toString())); |
|
76 |
} |
|
77 |
return result; |
|
78 |
} |
|
79 |
|
|
80 |
return null; |
|
81 |
} |
|
82 |
|
|
83 |
public ArrayList<Expression> getArguments() { |
|
84 |
return arguments; |
|
85 |
} |
|
86 |
|
|
87 |
public String getName() { |
|
88 |
return null; |
|
89 |
} |
|
90 |
|
|
91 |
public String getPattern() { |
|
92 |
throw new Error ("Not yet implemented"); |
|
93 |
} |
|
94 |
|
|
95 |
public void setArguments(ArrayList<Expression> arguments) { |
|
96 |
this.arguments = arguments; |
|
97 |
} |
|
98 |
|
|
99 |
|
|
100 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/OperationTags.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
public class OperationTags { |
|
44 |
|
|
45 |
//Useful to create the pattern |
|
46 |
public final static String OPERAND = "operand"; |
|
47 |
public final static String NUMERIC_VALUE = "numeric_value"; |
|
48 |
public final static String BOOLEAN_VALUE = "boolean_value"; |
|
49 |
public final static String CONSTANT = "constant"; |
|
50 |
public final static String NUMERIC_OR_BOOLEAN_CONSTANT ="numeric_or_boolean_value"; |
|
51 |
public static final String NULL_CONSTANT = "null"; |
|
52 |
public static final String STRING_CONSTANT = "String"; |
|
53 |
|
|
54 |
//Operators |
|
55 |
public final static String ADD_OP = "+"; |
|
56 |
public final static String DIV_OP = "/"; |
|
57 |
public final static String MINUS_OP = "-"; |
|
58 |
public final static String MULT_OP = "*"; |
|
59 |
public final static String AND_OP = "&&"; |
|
60 |
public final static String OR_OP = "||"; |
|
61 |
public final static String NOT_OP = "Not"; |
|
62 |
|
|
63 |
public final static String EQ_OP = "=="; |
|
64 |
public final static String NEQ_OP ="!="; |
|
65 |
public final static String GREATER_THAN_OP = ">"; |
|
66 |
public final static String GREATER_THAN_OR_EQ_OP = ">="; |
|
67 |
public final static String LESS_THAN_OP = "<"; |
|
68 |
public final static String LESS_THAN_OR_EQ_OP = "<="; |
|
69 |
|
|
70 |
public final static String ISBETWEEN_OP = "IsBetween"; |
|
71 |
public final static String ISNULL_OP = "IsNull"; |
|
72 |
public final static String REPLACE_OP = "Replace"; |
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/GreaterThanOperator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
import org.gvsig.i18n.Messages; |
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* Implements the funcionality of a ( > ) operator |
|
51 |
* |
|
52 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
53 |
* |
|
54 |
*/ |
|
55 |
|
|
56 |
public class GreaterThanOperator extends Operator { |
|
57 |
|
|
58 |
private ArrayList<Expression> arguments = new ArrayList<Expression>(); |
|
59 |
|
|
60 |
public String getName() { |
|
61 |
return OperationTags.GREATER_THAN_OP; |
|
62 |
} |
|
63 |
|
|
64 |
public GreaterThanOperator(Hashtable<String, Object> symbol_table) { |
|
65 |
super(symbol_table); |
|
66 |
} |
|
67 |
|
|
68 |
public Object evaluate()throws ExpressionException { |
|
69 |
Object eval1=((Expression)arguments.get(0)).evaluate(); |
|
70 |
Object eval2=((Expression)arguments.get(1)).evaluate(); |
|
71 |
if (eval1==null || eval2==null){ |
|
72 |
return false; |
|
73 |
} |
|
74 |
Double left = new Double(eval1.toString()); |
|
75 |
Double right = new Double(eval2.toString()); |
|
76 |
|
|
77 |
if (left > right) |
|
78 |
return true; |
|
79 |
else |
|
80 |
return false; |
|
81 |
} |
|
82 |
|
|
83 |
public void addArgument(int i, Expression arg) { |
|
84 |
arguments.add(i, arg); |
|
85 |
} |
|
86 |
|
|
87 |
public String getPattern() { |
|
88 |
return "("+Messages.getText(OperationTags.OPERAND) |
|
89 |
+ OperationTags.GREATER_THAN_OP +Messages.getText(OperationTags.OPERAND)+ ")\n"+ |
|
90 |
Messages.getText(OperationTags.OPERAND) +" = "+ |
|
91 |
Messages.getText(OperationTags.NUMERIC_VALUE); |
|
92 |
} |
|
93 |
|
|
94 |
public ArrayList<Expression> getArguments() { |
|
95 |
return arguments; |
|
96 |
} |
|
97 |
|
|
98 |
public void setArguments(ArrayList<Expression> arguments) { |
|
99 |
this.arguments = arguments; |
|
100 |
} |
|
101 |
|
|
102 |
public void check() throws ExpressionException { |
|
103 |
|
|
104 |
if (arguments.size() > 2) |
|
105 |
throw new ExpressionException(ExpressionException.INCORRECT_NUMBER_OF_ARGUMENTS); |
|
106 |
|
|
107 |
for (int i = 0; i < arguments.size(); i++) { |
|
108 |
if(!(arguments.get(i).evaluate()instanceof Double)) |
|
109 |
throw new ExpressionException(ExpressionException.CLASS_CASTING_EXCEPTION); |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
} |
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/filterencoding/operations/StringConstant.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.sldsupport.filterencoding.operations; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Hashtable; |
|
45 |
|
|
46 |
/** |
|
47 |
* Implements the funcionality of a String constant |
|
48 |
* |
|
49 |
* @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es |
|
50 |
* |
|
51 |
*/ |
|
52 |
public class StringConstant extends Operator |
|
53 |
{ |
|
54 |
private String value; |
|
55 |
|
|
56 |
|
|
57 |
public String getName() { |
|
58 |
return OperationTags.STRING_CONSTANT; |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
public StringConstant(String value,Hashtable<String, Object> symbol_table) |
|
63 |
{ |
|
64 |
super(symbol_table); |
|
65 |
this.value = value; |
|
66 |
} |
|
67 |
|
|
68 |
public void addArgument(Expression function) |
|
69 |
{ |
|
70 |
throw new RuntimeException("Cannot add an argument to a constant"); |
|
71 |
} |
|
72 |
|
|
73 |
public void addArgument(int index, Expression expression) |
|
74 |
{ |
|
75 |
throw new RuntimeException("Cannot add an argument to a constant"); |
|
76 |
} |
|
77 |
|
|
78 |
public Object evaluate() { |
|
79 |
return value; |
|
80 |
} |
|
81 |
|
|
82 |
public String getPattern() { |
Also available in: Unified diff