w2phtml/src/main/java/writer2latex/xhtml/style/properties/Properties.java

51 lines
1.4 KiB
Java

package writer2latex.xhtml.style.properties;
import java.util.HashMap;
import java.util.Map;
public class Properties{
private String separator;
private String internalSeparator;
private HashMap<String, String> list;
private final static String DEFAULT_INTERNAL_SEPARATOR = ":";
public Properties(String separator, String internalSeapartor) {
this.separator = separator;
this.internalSeparator = internalSeapartor;
this.list = new HashMap<String, String>();
}
public Properties(String separator) {
this(separator, DEFAULT_INTERNAL_SEPARATOR);
}
public Properties(char charSeparator) {
this(Character.toString(charSeparator), DEFAULT_INTERNAL_SEPARATOR);
}
public void addProperty(String name, String value) {
if (name == null || value == null || this.hasProperty(name)) { return; }
list.put(name, value);
}
public void replaceProperty(String name, String value) {
if (name == null || value == null ) { return; }
list.put(name, value);
}
public boolean hasProperty(String name) {
return list.containsKey(name);
}
public String toString() {
StringBuilder buffer = new StringBuilder();
for (Map.Entry<String, String> entry: list.entrySet()) {
buffer.append(entry.getKey() + internalSeparator + entry.getValue() + separator);
}
return buffer.toString();
}
public boolean isEmpty() {
return list.isEmpty();
}
}