Changeset 6737 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r6677 r6737 240 240 /** 241 241 * Assembles the strings to one. 242 * @see Utils#join 242 243 */ 243 244 @NullableArguments 244 245 public static String concat(Object... args) { 245 StringBuilder res = new StringBuilder(); 246 for (Object f : args) { 247 res.append(String.valueOf(f)); 248 } 249 return res.toString(); 246 return Utils.join("", Arrays.asList(args)); 247 } 248 249 /** 250 * Assembles the strings to one, where the first entry is used as separator. 251 * @see Utils#join 252 */ 253 @NullableArguments 254 public static String join(String... args) { 255 return Utils.join(args[0], Arrays.asList(args).subList(1, args.length)); 250 256 } 251 257 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r6736 r6737 199 199 assert mc.getCascade(Environment.DEFAULT_LAYER).get("width") == 15 200 200 } 201 202 @Test 203 public void testTicket80711() throws Exception { 204 def sheet = new MapCSSStyleSource("") 205 getParser("*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }").sheet(sheet) 206 def mc = new MultiCascade() 207 sheet.apply(mc, TestUtils.createPrimitive("way name=Foo"), 20, null, false) 208 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == " Foo" 209 sheet.apply(mc, TestUtils.createPrimitive("way rcn_ref=15"), 20, null, false) 210 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 " 211 sheet.apply(mc, TestUtils.createPrimitive("way rcn_ref=15 name=Foo"), 20, null, false) 212 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 Foo" 213 214 sheet = new MapCSSStyleSource("") 215 getParser("*[rcn_ref], *[name] {text: join(\" - \", tag(rcn_ref), tag(ref), tag(name)); }").sheet(sheet) 216 sheet.apply(mc, TestUtils.createPrimitive("way rcn_ref=15 ref=1.5 name=Foo"), 20, null, false) 217 assert mc.getCascade(Environment.DEFAULT_LAYER).get("text") == "15 - 1.5 - Foo" 218 } 201 219 }
Note:
See TracChangeset
for help on using the changeset viewer.