001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.mappaint.xml;
003
004import org.openstreetmap.josm.data.osm.OsmUtils;
005
006public class XmlCondition
007{
008    public String key;
009    public String value;
010    public String boolValue;
011
012    public XmlCondition() {
013      init();
014    }
015
016    public XmlCondition(XmlCondition c) {
017      key = c.key;
018      value = c.value;
019      boolValue = c.boolValue;
020    }
021
022    public String getKey() {
023        if(value != null)
024            return "n" + key + "=" + value;
025        else if(boolValue != null)
026            return "b" + key  + "=" + OsmUtils.getNamedOsmBoolean(boolValue);
027        else
028            return "x" + key;
029    }
030
031    public final void init() {
032      key = value = boolValue = null;
033    }
034
035    public String toString() {
036      return "Rule["+key+","+(boolValue != null ? "b="+boolValue:"v="+value)+"]";
037    }
038
039    public void appendCode(StringBuilder sb) {
040        sb.append("[k=").append(key);
041
042        if (boolValue != null)
043            sb.append(",b=").append(boolValue);
044        else
045            sb.append(",v=").append(value);
046
047        sb.append("]");
048    }
049}