cloneable property and properties v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 31 Dec 2013 18:11:50 +0100
branchv_0
changeset 10539d8b427e20f
parent 104 245f1b88a3e6
child 106 e9c3583580c8
cloneable property and properties
java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java
java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Tue Dec 31 17:35:33 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Tue Dec 31 18:11:50 2013 +0100
     1.3 @@ -20,6 +20,7 @@
     1.4  import java.util.ArrayList;
     1.5  import javax.xml.bind.annotation.XmlTransient;
     1.6  import static info.globalcode.sql.dk.Functions.findByName;
     1.7 +import java.util.Collections;
     1.8  
     1.9  /**
    1.10   * <p>List of configurables.</p>
    1.11 @@ -38,10 +39,17 @@
    1.12   *
    1.13   * @author Ing. František Kučera (frantovo.cz)
    1.14   */
    1.15 -public class Properties extends ArrayList<Property> {
    1.16 +public class Properties extends ArrayList<Property> implements Cloneable {
    1.17  
    1.18  	private Properties defaults;
    1.19  
    1.20 +	public Properties() {
    1.21 +	}
    1.22 +
    1.23 +	public Properties(int initialCapacity) {
    1.24 +		super(initialCapacity);
    1.25 +	}
    1.26 +
    1.27  	@XmlTransient
    1.28  	public Properties getDefaults() {
    1.29  		return defaults;
    1.30 @@ -73,4 +81,11 @@
    1.31  		Property p = findProperty(name);
    1.32  		return p == null ? defaultValue : Integer.valueOf(p.getValue());
    1.33  	}
    1.34 +
    1.35 +	@Override
    1.36 +	public Properties clone() {
    1.37 +		Properties clone = new Properties(size());
    1.38 +		Collections.copy(clone, this);
    1.39 +		return clone;
    1.40 +	}
    1.41  }
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java	Tue Dec 31 17:35:33 2013 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java	Tue Dec 31 18:11:50 2013 +0100
     2.3 @@ -25,7 +25,7 @@
     2.4   *
     2.5   * @author Ing. František Kučera (frantovo.cz)
     2.6   */
     2.7 -public class Property implements NameIdentified {
     2.8 +public class Property implements NameIdentified, Cloneable {
     2.9  
    2.10  	private String name;
    2.11  	private String value;
    2.12 @@ -61,4 +61,9 @@
    2.13  	public String toString() {
    2.14  		return name + "='" + value + "'";
    2.15  	}
    2.16 +
    2.17 +	@Override
    2.18 +	protected Property clone() {
    2.19 +		return new Property(name, value);
    2.20 +	}
    2.21  }