/** * Get a string representation for this <code>ConfigProperties</code> object. * @return a string representation for this <code>ConfigProperties</code> object. */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append('['); for (Iterator i=properties.values().iterator(); i.hasNext(); ) { Property property = (Property)i.next(); buf.append('('). append(property.getName()). append(':').append(property.getType()). append('=').append(property.getValue()). append(')'); if (i.hasNext()) buf.append(','); } buf.append(']'); return buf.toString(); }
/** * Add a property to this <code>ConfigProperties</code> object. * @param property the property to add. * @throws NullPointerException if <code>property</code> is <code>null</code>. * @throws IllegalArgumentException if a property with the same name already * exists. */ public void addProperty(Property property) { if (property == null) throw new NullPointerException("property is null"); if (properties.containsKey(property.getName())) throw new IllegalArgumentException("A property with the name " + property.getName() + " is already present"); properties.put(property.getName(), property); }
/** * Creates and returns a deep copy of this <code>ConfigProperties</code> object. * Changes to the properties of the object returned from this method will not * affect the properties stored by the original object cloned. * @return a deep copy of this <code>ConfigProperties</code> object. */ public Object clone() { ConfigProperties clone = new ConfigProperties(); for (Iterator i=properties.values().iterator(); i.hasNext(); ) { Property property = (Property)i.next(); clone.addProperty(new Property(property.getName(), property.getType(), property.getValue())); } return clone; }