2
* Copyright (C) 2008 Steve Ratcliffe
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
14
* Author: Steve Ratcliffe
15
* Create date: 02-Dec-2008
17
package uk.me.parabola.mkgmap.osmstyle.actions;
19
import java.util.ArrayList;
20
import java.util.List;
22
import uk.me.parabola.mkgmap.reader.osm.Element;
25
* Set the name on the given element. The tags of the element may be
26
* used in setting the name.
28
* We have a list of possible substitutions.
30
* @author Steve Ratcliffe
32
public class NameAction implements Action {
34
private final List<ValueBuilder> names = new ArrayList<ValueBuilder>();
37
* search for the first matching name pattern and set the element name
40
* If the element name is already set, then nothing is done.
42
* @param el The element on which the name may be set.
44
public void perform(Element el) {
45
if (el.getName() != null)
48
for (ValueBuilder vb : names) {
49
String s = vb.build(el);
57
public void add(String val) {
58
ValueBuilder vb = new ValueBuilder(val);
62
public String toString() {
63
StringBuilder sb = new StringBuilder();
65
for (ValueBuilder vb : names) {
69
sb.setLength(sb.length() - 1);