--- branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java 2009/08/26 11:03:27 315 +++ branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java 2009/10/13 11:29:54 463 @@ -31,6 +31,7 @@ import org.apache.log4j.Logger; +import skrueger.geotools.Copyable; import skrueger.geotools.StyledLayerInterface; import skrueger.i8n.Translation; @@ -40,24 +41,24 @@ * * @author Stefan Alfons Krüger */ -public class AttributeMetaData { +public class AttributeMetadata implements Copyable{ static private final Logger LOGGER = Logger - .getLogger(AttributeMetaData.class); + .getLogger(AttributeMetadata.class); protected Translation title = new Translation(); protected Translation desc = new Translation(); protected boolean visible = false; protected String unit = ""; protected int colIdx; - + /** - * Creates an {@link AttributeMetaData} object with the following information + * Creates an {@link AttributeMetadata} object with the following information * @param colIdx The column index of this attribute in the underlying table/dbf/etc... * @param visible Shall this attribute be displayed or hidden from the user? * @param title {@link Translation} for Name * @param desc {@link Translation} for an attribute description * @param unit {@link String} of the unit that the information is in */ - public AttributeMetaData(final int colIdx, final Boolean visible, + public AttributeMetadata(final int colIdx, final Boolean visible, final Translation title, final Translation desc, final String unit) { this.colIdx = colIdx; @@ -72,13 +73,17 @@ } /** - * Creates a new visible {@link AttributeMetaData} with default (no) values. + * Creates a new visible {@link AttributeMetadata} with default (no) values. */ - public AttributeMetaData(final Integer col, final String defaultName) { + public AttributeMetadata(final Integer col, final String defaultName) { 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_; + } }