--- branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java 2009/08/26 15:32:54 325 +++ branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java 2009/10/01 20:22:48 420 @@ -31,6 +31,7 @@ import org.apache.log4j.Logger; +import skrueger.geotools.Copyable; import skrueger.geotools.StyledLayerInterface; import skrueger.i8n.Translation; @@ -40,7 +41,7 @@ * * @author Stefan Alfons Krüger */ -public class AttributeMetaData { +public class AttributeMetaData implements Copyable{ static private final Logger LOGGER = Logger .getLogger(AttributeMetaData.class); protected Translation title = new Translation(); @@ -48,7 +49,7 @@ protected boolean visible = false; protected String unit = ""; protected int colIdx; - + /** * Creates an {@link AttributeMetaData} object with the following information * @param colIdx The column index of this attribute in the underlying table/dbf/etc... @@ -78,7 +79,11 @@ this(col, true, new Translation(defaultName), new Translation(), ""); } - public Boolean isVisible() { + /** Only used for {@link Copyable#copy()}**/ + private AttributeMetaData() { + } + + public boolean isVisible() { return visible; } @@ -114,4 +119,31 @@ public void setUnit(final String unit) { this.unit = unit; } + + @Override + public AttributeMetaData copyTo(AttributeMetaData amd) { + getTitle().copyTo(amd.getTitle()); + getDesc().copyTo(amd.getDesc()); + amd.setUnit(getUnit()); + amd.setVisible(isVisible()); + amd.setColIdx(getColIdx()); + + return amd; + } + + @Override + public AttributeMetaData copy() { + AttributeMetaData amd = new AttributeMetaData(); + getTitle().copyTo(amd.getTitle()); + getDesc().copyTo(amd.getDesc()); + amd.setUnit(getUnit()); + amd.setVisible(isVisible()); + amd.setColIdx(getColIdx()); + + return amd; + } + + private void setColIdx(int colIdx_) { + colIdx = colIdx_; + } }