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 @Override 036 public String toString() { 037 return "Rule["+key+','+(boolValue != null ? "b="+boolValue : "v="+value)+']'; 038 } 039 040 public void appendCode(StringBuilder sb) { 041 sb.append("[k=").append(key); 042 043 if (boolValue != null) 044 sb.append(",b=").append(boolValue); 045 else 046 sb.append(",v=").append(value); 047 048 sb.append(']'); 049 } 050}