001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2004, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * This package contains documentation from OpenGIS specifications.
018: * OpenGIS consortium's work is fully acknowledged here.
019: */
020: package org.geotools.metadata.iso.quality;
021:
022: // J2SE dependencies and extension
023: import java.util.Collection;
024: import java.util.Collections;
025: import java.util.List;
026: import javax.units.Unit;
027:
028: // OpenGIS dependencies
029: import org.opengis.metadata.quality.QuantitativeResult;
030: import org.opengis.util.InternationalString;
031: import org.opengis.util.RecordType;
032:
033: // Geotools dependencies
034: import org.geotools.util.CheckedArrayList;
035:
036: /**
037: * Information about the value (or set of values) obtained from applying a data quality measure.
038: *
039: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/quality/QuantitativeResultImpl.java $
040: * @version $Id: QuantitativeResultImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
041: * @author Martin Desruisseaux
042: * @author Touraïvane
043: *
044: * @since 2.1
045: */
046: public class QuantitativeResultImpl extends ResultImpl implements
047: QuantitativeResult {
048: /**
049: * Serial number for compatibility with different versions.
050: */
051: private static final long serialVersionUID = 1230713599561236060L;
052:
053: /**
054: * Quantitative value or values, content determined by the evaluation procedure used.
055: */
056: private Collection/*<Double>*/values;
057:
058: /**
059: * Value type for reporting a data quality result, or {@code null} if none.
060: */
061: private RecordType valueType;
062:
063: /**
064: * Value unit for reporting a data quality result, or {@code null} if none.
065: */
066: private Unit valueUnit;
067:
068: /**
069: * Statistical method used to determine the value, or {@code null} if none.
070: */
071: private InternationalString errorStatistic;
072:
073: /**
074: * Constructs an initially empty quantitative result.
075: */
076: public QuantitativeResultImpl() {
077: }
078:
079: /**
080: * Constructs a metadata entity initialized with the values from the specified metadata.
081: *
082: * @since 2.4
083: */
084: public QuantitativeResultImpl(final QuantitativeResult source) {
085: super (source);
086: }
087:
088: /**
089: * Constructs a quantitative result initialized to the specified value.
090: */
091: public QuantitativeResultImpl(final double[] values) {
092: setValues(values);
093: }
094:
095: /**
096: * Quantitative value or values, content determined by the evaluation procedure used.
097: */
098: public synchronized Collection getValues() {
099: if (values == null) {
100: if (isModifiable()) {
101: values = new CheckedArrayList(Double.class);
102: } else {
103: values = Collections.EMPTY_LIST;
104: }
105: }
106: return values;
107: }
108:
109: /**
110: * Set the quantitative value or values, content determined by the evaluation procedure used.
111: */
112: public synchronized void setValues(final double[] newValues) {
113: checkWritePermission();
114: if (newValues == null) {
115: values = null;
116: } else {
117: values = new CheckedArrayList(Double.class,
118: newValues.length);
119: for (int i = 0; i < newValues.length; i++) {
120: values.add(new Double(newValues[i]));
121: }
122: }
123: }
124:
125: /**
126: * Set the quantitative value or values, content determined by the evaluation procedure used.
127: *
128: * @since 2.4
129: */
130: public synchronized void setValues(
131: final Collection/*<Double>*/newValues) {
132: values = copyCollection(newValues, values, Double.class);
133: }
134:
135: /**
136: * Value type for reporting a data quality result, or {@code null} if none.
137: */
138: public RecordType getValueType() {
139: return valueType;
140: }
141:
142: /**
143: * Set the value type for reporting a data quality result, or {@code null} if none.
144: */
145: public synchronized void setValueType(final RecordType newValue) {
146: checkWritePermission();
147: valueType = newValue;
148: }
149:
150: /**
151: * Value unit for reporting a data quality result, or {@code null} if none.
152: */
153: public Unit getValueUnit() {
154: return valueUnit;
155: }
156:
157: /**
158: * Set the value unit for reporting a data quality result, or {@code null} if none.
159: */
160: public synchronized void setValueUnit(final Unit newValue) {
161: checkWritePermission();
162: valueUnit = newValue;
163: }
164:
165: /**
166: * Statistical method used to determine the value, or {@code null} if none.
167: */
168: public InternationalString getErrorStatistic() {
169: return errorStatistic;
170: }
171:
172: /**
173: * Set the statistical method used to determine the value, or {@code null} if none.
174: */
175: public synchronized void setErrorStatistic(
176: final InternationalString newValue) {
177: checkWritePermission();
178: errorStatistic = newValue;
179: }
180: }
|