diff -x '*entries' -x .DS_Store -Naur mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java /Users/thilo/work/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java --- mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/StartWithFilter.java 1970-01-01 01:00:00.000000000 +0100 +++ /Users/thilo/work/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/StartWithFilter.java 2009-05-16 23:58:15.000000000 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright 2009 Thilo Hannemann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +package uk.me.parabola.mkgmap.osmstyle.actions; + +/** + * Ensure that a name starts with a certain phrase if that phrase is not already part of that name. + * + * @author Thilo Hannemann + */ +public class StartWithFilter extends ValueFilter { + private final String phrase, searchPhrase; + + public StartWithFilter(String arg) { + phrase = arg; + searchPhrase = arg.trim().toLowerCase(); + } + + public String doFilter(String value) { + if (value == null) + return null; + else if (value.toLowerCase().indexOf(searchPhrase) != -1) + return value; + else + return phrase.concat(value); + } +} diff -x '*entries' -x .DS_Store -Naur mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java /Users/thilo/work/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java --- mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java 2009-05-17 23:18:53.000000000 +0200 +++ /Users/thilo/work/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java 2009-05-16 23:23:45.000000000 +0200 @@ -158,6 +158,8 @@ item.addFilter(new ConvertFilter(arg)); } else if (cmd.equals("subst")) { item.addFilter(new SubstitutionFilter(arg)); + } else if (cmd.equals("start-with")) { + item.addFilter(new StartWithFilter(arg)); } else if (cmd.equals("prefix")) { item.addFilter(new PrependFilter(arg)); } else if (cmd.equals("highway-symbol")) {