net.sf.xmlform.util.KeyValuePairs Maven / Gradle / Ivy
package net.sf.xmlform.util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* @author Liu Zhikun
*/
public class KeyValuePairs implements Cloneable {
private Map texts=new HashMap(5);
public void put(KeyValuePair kv){
texts.put(kv.getKey(),kv);
}
public void putAll(KeyValuePairs texts){
this.texts.putAll(texts.texts);
}
public int size(){
return texts.size();
}
public KeyValuePair get(String key){
if(!texts.containsKey(key))
return null;
return (KeyValuePair)texts.get(key);
}
public void clear(){
texts.clear();
}
public boolean contains(String key){
return texts.containsKey(key);
}
public KeyValuePair remove(String key){
KeyValuePair text=get(key);
texts.remove(key);
return text;
}
public Set getKeys(){
return texts.keySet();
}
public Object clone() {
try {
KeyValuePairs cloneObj=(KeyValuePairs)super.clone();
cloneObj.texts=new HashMap();
Iterator kvIt=texts.values().iterator();
while(kvIt.hasNext()){
KeyValuePair kv=(KeyValuePair)((KeyValuePair)kvIt.next()).clone();
cloneObj.texts.put(kv.getKey(), kv);
}
return cloneObj;
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy