001: //=============================================================================
002: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.wfp.vam.intermap.kernel.map.mapServices.wms.schema.impl;
025:
026: import java.util.List;
027: import org.jdom.Element;
028: import org.wfp.vam.intermap.kernel.map.mapServices.wms.schema.type.WMSDimension;
029:
030: /**
031: * @author ETj
032: */
033: public class WMSDimensionImpl implements WMSDimension {
034: private String _value = null;
035:
036: private String _name = null; // req
037: private String _units = null; // req
038: private String _unitSymbol = null;
039: private String _default = null;
040: private boolean _multipleValues = false;
041: private boolean _nearestValue = false;
042: private boolean _current = false;
043:
044: private WMSDimensionImpl() {
045: }
046:
047: public static WMSDimension newInstance() {
048: return new WMSDimensionImpl();
049: }
050:
051: public static WMSDimension parse(Element eDimension) {
052: WMSDimensionImpl dim = new WMSDimensionImpl();
053:
054: dim.setValue(eDimension.getText());
055:
056: dim.setName(eDimension.getAttributeValue("name"));
057: dim.setUnits(eDimension.getAttributeValue("units"));
058: dim.setUnitSymbol(eDimension.getAttributeValue("unitSymbol"));
059: dim.setDefault(eDimension.getAttributeValue("default"));
060: dim.setMultipleValues(Utils.getBooleanAttrib(eDimension
061: .getAttributeValue("multipleValues"), false));
062: dim.setNearestValue(Utils.getBooleanAttrib(eDimension
063: .getAttributeValue("nearestValue"), false));
064: dim.setCurrent(Utils.getBooleanAttrib(eDimension
065: .getAttributeValue("current"), false));
066:
067: return dim;
068: }
069:
070: /**
071: * Import in current 1.3.0 Dimension the attributes that in 1.1.x were in Extent elements
072: */
073: public void setExtent(List<Element> extentList) {
074: if (extentList == null)
075: return;
076:
077: for (Element eext : extentList) {
078: if (getName().equals(eext.getAttributeValue("name"))) {
079: setDefault(eext.getAttributeValue("default"));
080: setNearestValue(Utils.getBooleanAttrib(eext
081: .getAttributeValue("nearestValue"), false));
082: break;
083: }
084: }
085: }
086:
087: /**
088: * Sets Value
089: */
090: public void setValue(String value) {
091: _value = value;
092: }
093:
094: /**
095: * Returns Value
096: */
097: public String getValue() {
098: return _value;
099: }
100:
101: /**
102: * Sets Name
103: */
104: public void setName(String name) {
105: _name = name;
106: }
107:
108: /**
109: * Returns Name
110: */
111: public String getName() {
112: return _name;
113: }
114:
115: /**
116: * Sets Units
117: */
118: public void setUnits(String units) {
119: _units = units;
120: }
121:
122: /**
123: * Returns Units
124: */
125: public String getUnits() {
126: return _units;
127: }
128:
129: /**
130: * Sets UnitSymbol
131: */
132: public void setUnitSymbol(String unitSymbol) {
133: _unitSymbol = unitSymbol;
134: }
135:
136: /**
137: * Returns UnitSymbol
138: */
139: public String getUnitSymbol() {
140: return _unitSymbol;
141: }
142:
143: /**
144: * Sets Default
145: */
146: public void setDefault(String def) {
147: _default = def;
148: }
149:
150: /**
151: * Returns Default
152: */
153: public String getDefault() {
154: return _default;
155: }
156:
157: /**
158: * Sets MultipleValues
159: */
160: public void setMultipleValues(boolean multipleValues) {
161: _multipleValues = multipleValues;
162: }
163:
164: /**
165: * Returns MultipleValues
166: */
167: public boolean isMultipleValues() {
168: return _multipleValues;
169: }
170:
171: /**
172: * Sets NearestValue
173: */
174: public void setNearestValue(boolean nearestValue) {
175: _nearestValue = nearestValue;
176: }
177:
178: /**
179: * Returns NearestValue
180: */
181: public boolean isNearestValue() {
182: return _nearestValue;
183: }
184:
185: /**
186: * Sets Current
187: */
188: public void setCurrent(boolean current) {
189: _current = current;
190: }
191:
192: /**
193: * Returns Current
194: */
195: public boolean isCurrent() {
196: return _current;
197: }
198: }
|