Mercurial > dive4elements > framework
changeset 322:93a774fe2bb4
Added deepCopy() method to facets and state data.
artifacts/trunk@2530 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 23 Aug 2011 10:54:38 +0000 |
parents | ce62ae504d22 |
children | 1d3607ceb9fa |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/data/DefaultStateData.java artifact-database/src/main/java/de/intevation/artifactdatabase/data/StateData.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java |
diffstat | 5 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Aug 22 10:05:39 2011 +0000 +++ b/ChangeLog Tue Aug 23 10:54:38 2011 +0000 @@ -1,3 +1,13 @@ +2011-08-22 Sascha L. Teichmann <teichmann@intevation.de> + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java: + Added a deepCopy() method to make them cloneable (Not using java.lang.Cloneable for this). + + * artifact-database/src/main/java/de/intevation/artifactdatabase/data/DefaultStateData.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/data/StateData.java: + Implement the changed interfaces. + 2011-08-22 Sascha L. Teichmann <teichmann@intevation.de> * artifact-database/pom.xml: Bumped PostgreSQL driver from
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/data/DefaultStateData.java Mon Aug 22 10:05:39 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/data/DefaultStateData.java Tue Aug 23 10:54:38 2011 +0000 @@ -25,6 +25,8 @@ /** The value. */ protected Object value; + public DefaultStateData() { + } /** * The default constructor. It creates empty StateData objects with no @@ -40,6 +42,13 @@ this.type = type; } + public void set(StateData other) { + name = other.getName(); + description = other.getDescription(); + type = other.getType(); + value = other.getValue(); + } + /** * A constructor that takes the name of the data, its value and the @@ -111,5 +120,12 @@ public void setValue(Object value) { this.value = value; } + + @Override + public StateData deepCopy() { + DefaultStateData copy = new DefaultStateData(); + copy.set(this); + return copy; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/data/StateData.java Mon Aug 22 10:05:39 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/data/StateData.java Tue Aug 23 10:54:38 2011 +0000 @@ -53,5 +53,7 @@ * @param value The new value for this data object. */ public void setValue(Object value); + + public StateData deepCopy(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java Mon Aug 22 10:05:39 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java Tue Aug 23 10:54:38 2011 +0000 @@ -27,6 +27,8 @@ /** The description of this facet.*/ protected String description; + public DefaultFacet() { + } /** * The default constructor to create new Facet objects. @@ -52,6 +54,18 @@ this.description = description; } + public void set(Facet other) { + index = other.getIndex(); + name = other.getName(); + description = other.getDescription(); + } + + public Facet deepCopy() { + DefaultFacet copy = new DefaultFacet(); + copy.set(this); + return copy; + } + public int getIndex() { return index;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java Mon Aug 22 10:05:39 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java Tue Aug 23 10:54:38 2011 +0000 @@ -56,5 +56,7 @@ * @return the representation as Node. */ Node toXML(Document doc); + + Facet deepCopy(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :