public synchronized Object clone () { final MapAttribute clone = (MapAttribute)ReflectionUtils.newInstance(this); java.util.Iterator it = this.map.keySet().iterator(); while (it.hasNext()) { Attribute key = (Attribute)it.next(); Attribute value = this.aget(key); //clone.put((Attribute)key.clone(), (Attribute)value.clone()); //if (key != null) clone.put((Attribute)key.clone(), clone(value)); } return clone; }
/** * Turns an OpenWFE MapAttribute or StringMapAttribute into * a java HashMap */ public static java.util.Map map2java (final MapAttribute ma) { java.util.Map result = new java.util.HashMap(ma.size()); java.util.Iterator it = ma.keySet().iterator(); while (it.hasNext()) { Attribute k = (Attribute)it.next(); Attribute v = (Attribute)ma.get(k); result.put(owfe2java(k), owfe2java(v)); } return result; }
/** * Turns a java Map into an OpenWFE MapAttribute. * Doesn't produce a StringMapAttribute. */ public static MapAttribute map2owfe (java.util.Map m) { MapAttribute result = new MapAttribute(); fillMap(result, m); return result; }
/** * The equivalent of put(new StringAttribute(key), value). But this * is mainly a method required by CollectionAttribute, the parent class. * This method is used by setField in CollectionAttribute, * it has thus an internal value rather than an API value. */ public void cput (final String key, final Attribute value) { this.put(new StringAttribute(key), value); }
/** * This returns a set of String keys (not StringAttribute keys) */ public java.util.Set stringKeySet () { java.util.Set initialSet = super.keySet(); java.util.Set set = new java.util.HashSet(); java.util.Iterator it = initialSet.iterator(); while (it.hasNext()) { set.add(it.next().toString()); } return set; }
/** * You could use this method directly, but aget() and cget() are better. */ public Object get (final Object key) { if (key instanceof String) return cget((String)key); return this.map.get(key); }
private static void fillMap (final MapAttribute ma, final java.util.Map m) { java.util.Iterator it = m.keySet().iterator(); while (it.hasNext()) { Object k = it.next(); Object v = m.get(k); if (ma instanceof StringMapAttribute) ma.put(new StringAttribute(k.toString()), java2owfe(v)); else ma.put(java2owfe(k), java2owfe(v)); } }
(SqlWorkItemCoder.AttributeRecord)keyAndValue.get(1); result.put (decodeChild(key.id, key.type, args), decodeChild(value.id, value.type, args));
public Attribute decode (final Object o, final java.util.Map args) throws CodingException { final org.jdom.Element elt = enforceElement(o); MapAttribute ma = new MapAttribute(); fillMap(ma, elt); return ma; }
protected void fillMap (final MapAttribute ma, final org.jdom.Element elt) throws CodingException { java.util.Iterator it = elt.getChildren(ENTRY, elt.getNamespace()).iterator(); while (it.hasNext()) { final org.jdom.Element entry = (org.jdom.Element)it.next(); org.jdom.Element key = entry.getChild(KEY, elt.getNamespace()); org.jdom.Element value = null; // those XmlUtils methods do not care about namespaces if (key == null) { key = XmlUtils.getChild(entry, 0); value = XmlUtils.getChild(entry, 1); } else { key = XmlUtils.getFirstChild(key); value = entry.getChild(VALUE, elt.getNamespace()); value = XmlUtils.getFirstChild(value); } if (key == null || value == null) continue; ma.put(decodeElement(key), decodeElement(value)); } }