/** *Remove all parameters. */ public void removeMultiParameters() { this.duplicates = new DuplicateNameValueList(); }
/** * Removes the specified parameter from Parameters of this ParametersHeader. * This method returns silently if the parameter is not part of the * ParametersHeader. * * @param name - a String specifying the parameter name */ public void removeMultiParameter(String name) { this.duplicates.delete(name); }
public Object clone() { DuplicateNameValueList retval = new DuplicateNameValueList(); Iterator<NameValue> it = this.nameValueMap.values().iterator(); while (it.hasNext()) { retval.set((NameValue) ((NameValue) it.next()).clone()); } return retval; }
public String toString() { return this.encode(); }
/** Set the parameter given a name and value. * * @param nameValue - the name value of the parameter to set. */ public void setMultiParameter(NameValue nameValue) { this.duplicates.set(nameValue); }
/** * Do a lookup on a given name and return value associated with it. */ public Object getValue(String name) { Collection nv = this.getNameValue(name.toLowerCase()); if (nv != null) return nv; else return null; }
/** * Return the parameter as an object (dont convert to string). * * @param name is the name of the parameter to get. * @return the object associated with the name. */ public Object getMultiParameterValue(String name) { return this.duplicates.getValue(name); }
/** * Returns an Iterator over the names (Strings) of all parameters present * in this ParametersHeader. * * @return an Iterator over all the parameter names */ public Iterator<String> getMultiParameterNames() { return duplicates.getNames(); }
/** * Returns the parameter name * @param name * @return */ public String getMultiParameter(String name) { return this.duplicates.getParameter(name); }
/** Return true if you have a parameter and false otherwise. * *@return true if the parameters list is non-empty. */ public boolean hasMultiParameters() { return duplicates != null && !duplicates.isEmpty(); }
/** * Return true if has a parameter. * * @param parameterName is the name of the parameter. * * @return true if the parameter exists and false if not. */ public boolean hasMultiParameter(String parameterName) { return this.duplicates.hasNameValue(parameterName); }
/** * Encode the list in semicolon separated form. * * @return an encoded string containing the objects in this list. * @since v1.0 */ public String encode() { return encode(new StringBuilder()).toString(); }
/** * Introduced specifically for the P-Charging-Function-Addresses Header and * all other headers that may have multiple header parameters of the same name, but * with multiple possible values. * * Example: P-Charging-Function-Addresses: ccf=[5555::b99:c88:d77:e66]; ccf=[5555::a55:b44:c33:d22]; * ecf=[5555::1ff:2ee:3dd:4cc]; ecf=[5555::6aa:7bb:8cc:9dd] * @param name of the parameter * @param value of the parameter */ public void setMultiParameter(String name, String value) { NameValue nv = new NameValue(); nv.setName(name); nv.setValue(value); duplicates.set(nv); }
/** * 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; }
/** * Get the parameter as a String. * * @return the parameter as a string. */ public String getParameter(String name) { Object val = this.getValue(name); if (val == null) return null; if (val instanceof GenericObject) return ((GenericObject) val).encode(); else return val.toString(); }
protected ParametersHeader(String hdrName) { super(hdrName); this.parameters = new NameValueList(); this.duplicates = new DuplicateNameValueList(); }
protected ParametersHeader(String hdrName, boolean sync) { super(hdrName); this.parameters = new NameValueList(sync); this.duplicates = new DuplicateNameValueList(); }
protected ParametersHeader() { this.parameters = new NameValueList(); this.duplicates = new DuplicateNameValueList(); }