public Object clone() { MultiValueMapImpl obj = new MultiValueMapImpl<V>(); if(map != null) { obj.map = (HashMap<Object, ArrayList<V>>) this.map.clone(); } return obj; }
public void clear() { nameValueMap.clear(); }
/** * Remove the element corresponding to this name. */ public boolean delete(String name) { String lcName = name.toLowerCase(); if (this.nameValueMap.containsKey(lcName)) { this.nameValueMap.remove(lcName); return true; } else { return false; } }
/** * Compare if two NameValue lists are equal. * * @param otherObject is the object to compare to. * @return true if the two objects compare for equality. */ public boolean equals(Object otherObject) { if ( otherObject == null ) { return false; } if (!otherObject.getClass().equals(this.getClass())) { return false; } DuplicateNameValueList other = (DuplicateNameValueList) otherObject; if (nameValueMap.size() != other.nameValueMap.size()) { return false; } Iterator<String> li = this.nameValueMap.keySet().iterator(); while (li.hasNext()) { String key = (String) li.next(); Collection nv1 = this.getNameValue(key); Collection nv2 = (Collection) other.nameValueMap.get(key); if (nv2 == null) return false; else if (!nv2.equals(nv1)) return false; } return true; }
public StringBuilder encode(StringBuilder buffer) { if (!nameValueMap.isEmpty()) { Iterator<NameValue> iterator = nameValueMap.values().iterator(); if (iterator.hasNext()) { while (true) { Object obj = iterator.next(); if (obj instanceof GenericObject) { GenericObject gobj = (GenericObject) obj; gobj.encode(buffer); } else { buffer.append(obj.toString()); } if (iterator.hasNext()) buffer.append(Separators.SEMICOLON); else break; } } } return buffer; }
public List<V> put(String key, List<V> value) { return this.getMap().put(key,(ArrayList<V>) value); }
public NameValue put(String key, NameValue value) { return (NameValue) this.nameValueMap.put(key, value); }
/** * Get a list of parameter names. * * @return a list iterator that has the names of the parameters. */ public Iterator<String> getNames() { return this.nameValueMap.keySet().iterator(); }
public boolean isEmpty() { return this.nameValueMap.isEmpty(); }
public NameValue remove(Object key) { return (NameValue) this.nameValueMap.remove(key); }
public int size() { return this.nameValueMap.size(); }
/** * Get the NameValue record given a name. * */ public Collection getNameValue(String name) { return (Collection) this.nameValueMap.get(name.toLowerCase()); }
/** * Returns a boolean telling if this NameValueList has a record with this name */ public boolean hasNameValue(String name) { return nameValueMap.containsKey(name.toLowerCase()); }
public void putAll(Map< ? extends String, ? extends List<V>> mapToPut) { for (String k : mapToPut.keySet()) { ArrayList<V> al = new ArrayList<V>(); al.addAll(mapToPut.get(k)); getMap().put(k, al); } }
/** * Set a namevalue object in this list. */ public void set(NameValue nv) { this.nameValueMap.put(nv.getName().toLowerCase(), nv); }
public int hashCode() { return this.nameValueMap.keySet().hashCode(); }
public List<V> put(String key, V value) { ArrayList<V> keyList = null; if(map != null) { keyList = map.get(key); } if (keyList == null) { keyList = new ArrayList<V>(); getMap().put(key, keyList); } keyList.add(value); return keyList; }
/** * Set a namevalue object in this list. */ public void set(String name, Object value) { NameValue nameValue = new NameValue(name, value); nameValueMap.put(name.toLowerCase(), nameValue); }