001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/owscommon/com110/OWSDomainType110.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstraße 19
030: 53177 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042: ---------------------------------------------------------------------------*/
043:
044: package org.deegree.owscommon.com110;
045:
046: import org.deegree.datatypes.values.TypedLiteral;
047: import org.deegree.owscommon.OWSMetadata;
048:
049: /**
050: * FIXME should be renamed.
051: *
052: * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a>
053: * @author last edited by: $Author: apoth $
054: *
055: * @version 2.0, $Revision: 9346 $, $Date: 2007-12-27 08:39:07 -0800 (Thu, 27 Dec 2007) $
056: *
057: * @since 2.0
058: */
059: public class OWSDomainType110 {
060:
061: /* FIXME
062: * When this class OWSDomainType110 gets integrated properly,
063: * the class OWSMetadata should be provided with an identifier (private String name),
064: * to enable identification of the kind of OWSMetadata.
065: * With this handle, the implemented String 'measurementType' becomes obsolete,
066: * because its content could be moved into the String 'name' within the OWSMetadata object.
067: */
068:
069: public static final String REFERENCE_SYSTEM = "REFERENCE_SYSTEM";
070: public static final String UOM = "UOM";
071:
072: // the choice of one of these four elements is mandatory:
073: private OWSAllowedValues allowedValues;
074: private boolean anyValue;
075: private boolean noValues;
076: private OWSMetadata valuesListReference;
077:
078: // these elements are optional:
079: private TypedLiteral defaultValue;
080: private OWSMetadata meaning;
081: private OWSMetadata owsDataType;
082: private String measurementType; // choice between REFERENCE_SYSTEM and UOM
083: private OWSMetadata measurement;
084: private OWSMetadata[] metadata;
085:
086: // mandatory attribute:
087: public String name;
088:
089: /**
090: * Creates a new <code>DomainType110</code> object.
091: * This is the basic constructor, which is called from any other public constructor.
092: *
093: * @param allowedValues
094: * @param anyValue
095: * @param noValues
096: * @param valuesListReference
097: * @param defaultValue
098: * @param meaning
099: * @param dataType
100: * @param measurementType
101: * @param measurement
102: * @param metadata
103: * @param name
104: */
105: private OWSDomainType110(OWSAllowedValues allowedValues,
106: boolean anyValue, boolean noValues,
107: OWSMetadata valuesListReference, String defaultValue,
108: OWSMetadata meaning, OWSMetadata dataType,
109: String measurementType, OWSMetadata measurement,
110: OWSMetadata[] metadata, String name) {
111:
112: if (anyValue == true && noValues == true) {
113: throw new IllegalArgumentException(
114: "anyValue and noValues cannot both be true.");
115: }
116:
117: if (measurement != null) {
118:
119: if (measurementType == null) {
120: throw new NullPointerException(
121: "measurementType cannot be null.");
122: }
123: if (REFERENCE_SYSTEM.equals(measurementType)
124: || UOM.equals(measurementType)) {
125: this .measurementType = measurementType;
126: } else {
127: throw new IllegalArgumentException(
128: "measurementType must be either "
129: + getClass().getName()
130: + ".REFERENCE_SYSTEM or "
131: + getClass().getName() + ".UOM");
132: }
133: this .measurement = measurement;
134: }
135:
136: this .allowedValues = allowedValues;
137: this .anyValue = anyValue;
138: this .noValues = noValues;
139: this .valuesListReference = valuesListReference;
140: setDefaultValue(defaultValue);
141: this .meaning = meaning;
142: this .owsDataType = dataType;
143: if (metadata == null) {
144: this .metadata = new OWSMetadata[0];
145: } else {
146: this .metadata = metadata;
147: }
148: this .name = name;
149:
150: }
151:
152: /**
153: * Creates a new <code>DomainType110</code> object.
154: *
155: * Use this constructor to create the <code>DomainType110</code> object
156: * with an <code>OWSAllowedValues</code> object.
157: *
158: * @param allowedValues
159: * @param defaultValue
160: * @param meaning
161: * @param dataType
162: * @param measurementType
163: * Must be either "REFERENCE_SYSTEM" or "UOM".
164: * @param measurement
165: * @param metadata
166: * @param name
167: * mandatory attribute
168: */
169: public OWSDomainType110(OWSAllowedValues allowedValues,
170: String defaultValue, OWSMetadata meaning,
171: OWSMetadata dataType, String measurementType,
172: OWSMetadata measurement, OWSMetadata[] metadata, String name) {
173:
174: this (allowedValues, false, false, null, defaultValue, meaning,
175: dataType, measurementType, measurement, metadata, name);
176: }
177:
178: /**
179: * Creates a new <code>DomainType110</code> object.
180: *
181: * Use this constructor to create the <code>DomainType110</code> object
182: * when <code>anyValue</code> OR <code>noValues</code> is true.
183: *
184: * @param anyValue
185: * Cannot be true if noValues is true.
186: * @param noValues
187: * Cannot be true if anyValue is true.
188: * @param defaultValue
189: * @param meaning
190: * @param dataType
191: * @param measurementType
192: * Must be either "REFERENCE_SYSTEM" or "UOM".
193: * @param measurement
194: * @param metadata
195: * @param name
196: * mandatory attribute
197: */
198: public OWSDomainType110(boolean anyValue, boolean noValues,
199: String defaultValue, OWSMetadata meaning,
200: OWSMetadata dataType, String measurementType,
201: OWSMetadata measurement, OWSMetadata[] metadata, String name) {
202:
203: this (null, anyValue, noValues, null, defaultValue, meaning,
204: dataType, measurementType, measurement, metadata, name);
205: }
206:
207: /**
208: * Creates a new <code>DomainType110</code> object.
209: *
210: * Use this constructor to create the <code>DomainType110</code> object
211: * with an <code>OWSMetadata</code> object of valuesListReference.
212: *
213: * @param valuesListReference
214: * @param defaultValue
215: * @param meaning
216: * @param dataType
217: * @param measurementType
218: * Must be either "REFERENCE_SYSTEM" or "UOM".
219: * @param measurement
220: * @param metadata
221: * @param name
222: * mandatory attribute
223: */
224: public OWSDomainType110(OWSMetadata valuesListReference,
225: String defaultValue, OWSMetadata meaning,
226: OWSMetadata dataType, String measurementType,
227: OWSMetadata measurement, OWSMetadata[] metadata, String name) {
228:
229: this (null, false, false, valuesListReference, defaultValue,
230: meaning, dataType, measurementType, measurement,
231: metadata, name);
232: }
233:
234: /**
235: * @return Returns the allowedValues.
236: */
237: public OWSAllowedValues getAllowedValues() {
238: return allowedValues;
239: }
240:
241: /**
242: * @return Returns the anyValue.
243: */
244: public boolean isAnyValue() {
245: return anyValue;
246: }
247:
248: /**
249: * @return Returns the noValues.
250: */
251: public boolean hasNoValues() {
252: return noValues;
253: }
254:
255: /**
256: * @return Returns the valuesListReference.
257: */
258: public OWSMetadata getValuesListReference() {
259: return valuesListReference;
260: }
261:
262: /**
263: * @return Returns the defaultValue.
264: */
265: public TypedLiteral getDefaultValue() {
266: return defaultValue;
267: }
268:
269: /**
270: * @return Returns the meaning.
271: */
272: public OWSMetadata getMeaning() {
273: return meaning;
274: }
275:
276: /**
277: * @return Returns the owsDataType.
278: */
279: public OWSMetadata getOwsDataType() {
280: return owsDataType;
281: }
282:
283: /**
284: * Returns the measurementType, or null if the measurement object is null.
285: *
286: * @return Returns the measurementType.
287: */
288: public String getMeasurementType() {
289: return measurementType;
290: }
291:
292: /**
293: * @return Returns the measurement.
294: */
295: public OWSMetadata getMeasurement() {
296: return measurement;
297: }
298:
299: /**
300: * Returns an array of OWSMetadata objects. If metadata is null, an array of size 0 is returned.
301: *
302: * @return Returns the metadata.
303: */
304: public OWSMetadata[] getMetadata() {
305: return metadata;
306: }
307:
308: /**
309: * @return Returns the name.
310: */
311: public String getName() {
312: return name;
313: }
314:
315: /**
316: * @param defaultValue The defaultValue to set.
317: */
318: public void setDefaultValue(TypedLiteral defaultValue) {
319: this .defaultValue = defaultValue;
320: }
321:
322: /**
323: * Sets the defaultValue to a new TypedLiteral with the given value.
324: *
325: * @param defaultURI
326: */
327: private void setDefaultValue(String value) {
328: this .defaultValue = new TypedLiteral(value, null);
329: }
330:
331: }
|