20 package org.matsim.utils.objectattributes;
22 import java.util.IdentityHashMap;
23 import java.util.LinkedHashMap;
25 import java.util.Map.Entry;
46 Map<String, Map<String, Object>> attributes =
new LinkedHashMap<String, Map<String, Object>>(1000);
50 StringBuilder stb =
new StringBuilder() ;
51 for ( Entry<String, Map<String,Object>> entry : attributes.entrySet() ) {
52 String key = entry.getKey() ;
53 stb.append(
"key=").append(key);
54 Map<String,Object> map = entry.getValue() ;
55 for ( Entry<String,Object> ee : map.entrySet() ) {
56 String subkey = ee.getKey();
57 stb.append(
"; subkey=").append(subkey);
58 stb.append(
"; object=").append(ee.getValue().toString());
62 return stb.toString() ;
65 public Object
putAttribute(
final String objectId,
final String attribute,
final Object value) {
66 Map<String, Object> attMap = this.attributes.get(objectId);
68 attMap =
new IdentityHashMap<String, Object>(5);
69 this.attributes.put(objectId, attMap);
71 return attMap.put(attribute.intern(), value);
74 public Object
getAttribute(
final String objectId,
final String attribute) {
75 Map<String, Object> attMap = this.attributes.get(objectId);
79 return attMap.get(attribute.intern());
83 Map<String, Object> attMap = this.attributes.get(objectId);
87 return attMap.remove(attribute.intern());
91 this.attributes.remove(objectId);
98 this.attributes.clear();
Object putAttribute(final String objectId, final String attribute, final Object value)
void removeAllAttributes(final String objectId)
Object getAttribute(final String objectId, final String attribute)
Object removeAttribute(final String objectId, final String attribute)