- Timestamp:
- 2013-12-28T01:31:47+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r6547 r6554 22 22 abstract public boolean applies(Environment e); 23 23 24 public static Condition create(String k, String v, Op op, Context context) { 24 public static Condition create(String k, String v, Op op, Context context, boolean considerValAsKey) { 25 25 switch (context) { 26 26 case PRIMITIVE: 27 return new KeyValueCondition(k, v, op); 27 return new KeyValueCondition(k, v, op, considerValAsKey); 28 28 case LINK: 29 if (considerValAsKey) 30 throw new MapCSSException("''considerValAsKey'' not supported in LINK context"); 29 31 if ("role".equalsIgnoreCase(k)) 30 32 return new RoleCondition(v, op); … … 144 146 public final String v; 145 147 public final Op op; 148 public boolean considerValAsKey; 146 149 147 150 /** … … 151 154 * @param v the value 152 155 * @param op the operation 156 * @param considerValAsKey whether to consider {@code v} as another key and compare the values of key {@code k} and key {@code v}. 153 157 */ 154 public KeyValueCondition(String k, String v, Op op) { 158 public KeyValueCondition(String k, String v, Op op, boolean considerValAsKey) { 155 159 this.k = k; 156 160 this.v = v; 157 161 this.op = op; 162 this.considerValAsKey = considerValAsKey; 158 163 } 159 164 160 165 @Override 161 166 public boolean applies(Environment env) { 162 return op.eval(env.osm.get(k), v); 167 return op.eval(env.osm.get(k), considerValAsKey ? env.osm.get(v) : v); 163 168 } 164 169 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r6547 r6554 367 367 int i; 368 368 Condition.Op op; 369 boolean considerValAsKey = false; 369 370 } 370 371 { 371 372 key=tag_key() s() 372 373 ( 373 LOOKAHEAD(2) 374 <EQUAL> <TILDE> { op=Condition.Op.REGEX; } s() val=regex() 375 | 376 LOOKAHEAD(2) 377 <EXCLAMATION> <TILDE> { op=Condition.Op.NREGEX; } s() val=regex() 374 LOOKAHEAD(3) 375 ( 376 <EQUAL> <TILDE> { op=Condition.Op.REGEX; } 377 | 378 <EXCLAMATION> <TILDE> { op=Condition.Op.NREGEX; } 379 ) 380 s() 381 ( <STAR> { considerValAsKey=true; } )? 382 val=regex() 378 383 | 379 384 ( … … 391 396 ) 392 397 s() 398 ( <STAR> { considerValAsKey=true; } )? 393 399 ( 394 400 LOOKAHEAD(2) … … 412 418 f=float_() { val=Float.toString(f); } 413 419 ) 414 { return Condition.create(key, val, op, context); } 420 { return Condition.create(key, val, op, context, considerValAsKey); } 415 421 } 416 422
Note:
See TracChangeset
for help on using the changeset viewer.