- Timestamp:
- 2013-12-23T00:13:58+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Tag.java
r6512 r6513 99 99 } 100 100 101 /** 102 * This constructs a {@link Tag} by splitting {@code s} on the first equality sign. 103 * @see org.openstreetmap.josm.tools.TextTagParser 104 * @param s the string to convert 105 * @return the constructed tag 106 */ 101 107 public static Tag ofString(String s) { 102 108 CheckParameterUtil.ensureParameterNotNull(s, "s"); -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6512 r6513 229 229 public void initialize() throws Exception { 230 230 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/deprecated.mapcss"), "UTF-8")); 231 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/highway.mapcss"), "UTF-8")); 231 232 } 232 233 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r6455 r6513 38 38 } 39 39 40 public static Condition create(String k, boolean not, boolean yes, Context context) { 40 public static Condition create(String k, boolean not, boolean yes, boolean no, Context context) { 41 41 switch (context) { 42 42 case PRIMITIVE: 43 return new KeyCondition(k, not, yes); 43 return new KeyCondition(k, not, yes, no); 44 44 case LINK: 45 if (yes) 45 if (yes || no) 46 46 throw new MapCSSException("Question mark operator ''?'' not supported in LINK context"); 47 47 if (not) … … 216 216 * ["a label"?] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a true-value 217 217 * LINK: not supported 218 * 219 * ["a label"?!] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a false-value 220 * LINK: not supported 218 221 * </pre> 219 222 */ … … 221 224 222 225 private String label; 223 private boolean exclamationMarkPresent; 224 private boolean questionMarkPresent; 225 226 /** 227 * 228 * @param label 229 * @param exclamationMarkPresent 230 * @param questionMarkPresent 231 */ 232 public KeyCondition(String label, boolean exclamationMarkPresent, boolean questionMarkPresent){ 226 private boolean negateResult; 227 private boolean testForTrueValues; 228 private boolean testForFalseValues; 229 230 public KeyCondition(String label, boolean negateResult, boolean testForTrueValues, boolean testForFalseValues){ 233 231 this.label = label; 234 this.exclamationMarkPresent = exclamationMarkPresent; 235 this.questionMarkPresent = questionMarkPresent; 232 this.negateResult = negateResult; 233 this.testForTrueValues = testForTrueValues; 234 this.testForFalseValues = testForFalseValues; 236 235 } 237 236 … … 240 239 switch(e.getContext()) { 241 240 case PRIMITIVE: 242 if (questionMarkPresent) 243 return OsmUtils.isTrue(e.osm.get(label)) ^ exclamationMarkPresent; 241 if (testForTrueValues) 242 return OsmUtils.isTrue(e.osm.get(label)) ^ negateResult; 243 else if (testForFalseValues) 244 return OsmUtils.isFalse(e.osm.get(label)) ^ negateResult; 244 245 else 245 return e.osm.hasKey(label) ^ exclamationMarkPresent;246 return e.osm.hasKey(label) ^ negateResult; 246 247 case LINK: 247 248 Utils.ensure(false, "Illegal state: KeyCondition not supported in LINK context"); … … 253 254 @Override 254 255 public String toString() { 255 return "[" + ( exclamationMarkPresent ? "!" : "") + label + "]";256 return "[" + (negateResult ? "!" : "") + label + "]"; 256 257 } 257 258 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r6455 r6513 345 345 boolean not = false; 346 346 boolean yes = false; 347 boolean no = false; 347 348 String key; 348 349 } … … 350 351 ( <EXCLAMATION> { not = true; } )? 351 352 key=tag_key() 353 ( LOOKAHEAD(2) <QUESTION> <EXCLAMATION> { no = true; } )? 352 354 ( <QUESTION> { yes = true; } )? 353 { return Condition.create(key, not, yes, context); } 355 { return Condition.create(key, not, yes, no, context); } 354 356 } 355 357
Note:
See TracChangeset
for help on using the changeset viewer.