Last change
on this file since 6986 was 6986, checked in by Don-vip, 10 years ago |
sonar - fix various minor issues
|
-
Property svn:eol-style
set to
native
|
File size:
1.5 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.xml;
|
---|
3 |
|
---|
4 | import java.util.Collection;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
7 | import org.openstreetmap.josm.data.osm.OsmUtils;
|
---|
8 | import org.openstreetmap.josm.gui.mappaint.Range;
|
---|
9 |
|
---|
10 | public abstract class Prototype {
|
---|
11 | // zoom range to display the feature
|
---|
12 | public Range range;
|
---|
13 |
|
---|
14 | public int priority;
|
---|
15 | public String code;
|
---|
16 | public Collection<XmlCondition> conditions = null;
|
---|
17 |
|
---|
18 | public Prototype(Range range) {
|
---|
19 | this.range = range;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public Prototype() {
|
---|
23 | }
|
---|
24 |
|
---|
25 | public String getCode() {
|
---|
26 | if(code == null) {
|
---|
27 | if (conditions == null || conditions.isEmpty()) {
|
---|
28 | code = "";
|
---|
29 | } else {
|
---|
30 | final StringBuilder sb = new StringBuilder();
|
---|
31 | for(XmlCondition r: conditions) {
|
---|
32 | r.appendCode(sb);
|
---|
33 | }
|
---|
34 | code = sb.toString();
|
---|
35 | }
|
---|
36 | }
|
---|
37 | return code;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public boolean check(OsmPrimitive primitive) {
|
---|
41 | if(conditions == null)
|
---|
42 | return true;
|
---|
43 | for(XmlCondition r : conditions) {
|
---|
44 | String k = primitive.get(r.key);
|
---|
45 |
|
---|
46 | if (k == null || (r.value != null && !k.equals(r.value)))
|
---|
47 | return false;
|
---|
48 |
|
---|
49 | String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
|
---|
50 |
|
---|
51 | if (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k)))
|
---|
52 | return false;
|
---|
53 | }
|
---|
54 | return true;
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.