001: package org.geotools.wms.v1_1_1.bindings;
002:
003: import java.util.HashMap;
004: import java.util.Iterator;
005: import java.util.List;
006: import java.util.Map;
007: import java.util.TreeSet;
008:
009: import javax.xml.namespace.QName;
010:
011: import org.geotools.data.ows.CRSEnvelope;
012: import org.geotools.data.ows.Layer;
013: import org.geotools.xml.AbstractComplexBinding;
014: import org.geotools.xml.ElementInstance;
015: import org.geotools.xml.Node;
016:
017: /**
018: * Binding object for the type :_Layer.
019: *
020: * <p>
021: * <pre>
022: * <code>
023: * <xs:complexType name="_Layer">
024: * <xs:sequence>
025: * <xs:element minOccurs="0" ref="Name"/>
026: * <xs:element ref="Title"/>
027: * <xs:element minOccurs="0" ref="Abstract"/>
028: * <xs:element minOccurs="0" ref="KeywordList"/>
029: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="SRS"/>
030: * <xs:element minOccurs="0" ref="LatLonBoundingBox"/>
031: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="BoundingBox"/>
032: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="Dimension"/>
033: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="Extent"/>
034: * <xs:element minOccurs="0" ref="Attribution"/>
035: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="AuthorityURL"/>
036: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="Identifier"/>
037: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="MetadataURL"/>
038: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="DataURL"/>
039: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="FeatureListURL"/>
040: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="Style"/>
041: * <xs:element minOccurs="0" ref="ScaleHint"/>
042: * <xs:element maxOccurs="unbounded" minOccurs="0" ref="Layer"/>
043: * </xs:sequence>
044: * <xs:attribute default="0" name="queryable">
045: * <xs:simpleType>
046: * <xs:restriction base="xs:token">
047: * <xs:enumeration value="0"/>
048: * <xs:enumeration value="1"/>
049: * </xs:restriction>
050: * </xs:simpleType>
051: * </xs:attribute>
052: * <xs:attribute name="cascaded"/>
053: * <xs:attribute default="0" name="opaque">
054: * <xs:simpleType>
055: * <xs:restriction base="xs:token">
056: * <xs:enumeration value="0"/>
057: * <xs:enumeration value="1"/>
058: * </xs:restriction>
059: * </xs:simpleType>
060: * </xs:attribute>
061: * <xs:attribute default="0" name="noSubsets">
062: * <xs:simpleType>
063: * <xs:restriction base="xs:token">
064: * <xs:enumeration value="0"/>
065: * <xs:enumeration value="1"/>
066: * </xs:restriction>
067: * </xs:simpleType>
068: * </xs:attribute>
069: * <xs:attribute name="fixedWidth"/>
070: * <xs:attribute name="fixedHeight"/>
071: * </xs:complexType>
072: *
073: * </code>
074: * </pre>
075: * </p>
076: *
077: * @generated
078: */
079: public class _LayerBinding extends AbstractComplexBinding {
080:
081: /**
082: * @generated
083: */
084: public QName getTarget() {
085: return WMSV1_1_1._Layer;
086: }
087:
088: /**
089: * <!-- begin-user-doc -->
090: * <!-- end-user-doc -->
091: *
092: * @generated modifiable
093: */
094: public Class getType() {
095: return Layer.class;
096: }
097:
098: /**
099: * <!-- begin-user-doc -->
100: * <!-- end-user-doc -->
101: *
102: * @generated modifiable
103: */
104: public Object parse(ElementInstance instance, Node node,
105: Object value) throws Exception {
106: Layer ret = new Layer();
107: ret.set_abstract((String) node.getChildValue("Abstract"));
108:
109: HashMap bboxes = new HashMap();
110: Iterator iBboxList = node.getChildValues("BoundingBox")
111: .iterator();
112: while (iBboxList.hasNext()) {
113: CRSEnvelope bbox = (CRSEnvelope) iBboxList.next();
114: bboxes.put(bbox.getEPSGCode(), bbox);
115: }
116: ret.setBoundingBoxes(bboxes);
117:
118: ret.setLatLonBoundingBox((CRSEnvelope) node
119: .getChildValue("LatLonBoundingBox"));
120:
121: //get all layer children and set their parent to point back to us.
122: List childLayers = node.getChildValues("Layer");
123: Iterator iChildLayers = childLayers.iterator();
124: while (iChildLayers.hasNext())
125: ((Layer) iChildLayers.next()).setParent(ret);
126: ret.setChildren((Layer[]) childLayers
127: .toArray(new Layer[childLayers.size()]));
128:
129: ret.setKeywords((String[]) node.getChildValue("KeywordList"));
130: ret.setName((String) node.getChildValue("Name"));
131:
132: //This code from WMSComplexTypes.java
133: String queryable = (String) node.getAttributeValue("queryable");
134: if (queryable != null) {
135: if ("1".equals(queryable)) {
136: ret.setQueryable(true);
137: } else if ("0".equals(queryable)) {
138: ret.setQueryable(new Boolean(queryable).booleanValue());
139: }
140: }
141:
142: Map shints = (Map) node.getChildValue("ScaleHint");
143: if (shints != null && shints.get("max") != null)
144: ret.setScaleHintMax(Double.parseDouble((String) shints
145: .get("max")));
146: if (shints != null && shints.get("min") != null)
147: ret.setScaleHintMin(Double.parseDouble((String) shints
148: .get("min")));
149:
150: TreeSet srs = new TreeSet();
151: srs.addAll(node.getChildValues("SRS"));
152: ret.setSrs(srs);
153:
154: ret.setStyles((List) node.getChildValues("Style"));
155:
156: ret.setTitle((String) node.getChildValue("Title"));
157:
158: return ret;
159:
160: }
161:
162: }
|