001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.sld.bindings;
017:
018: import org.picocontainer.MutablePicoContainer;
019: import org.w3c.dom.Document;
020: import org.w3c.dom.Element;
021: import java.util.Iterator;
022: import javax.xml.namespace.QName;
023: import org.geotools.styling.LayerFeatureConstraints;
024: import org.geotools.styling.RemoteOWS;
025: import org.geotools.styling.Style;
026: import org.geotools.styling.StyleFactory;
027: import org.geotools.styling.UserLayer;
028: import org.geotools.xml.*;
029:
030: /**
031: * Binding object for the element http://www.opengis.net/sld:UserLayer.
032: *
033: * <p>
034: * <pre>
035: * <code>
036: * <xsd:element name="UserLayer">
037: * <xsd:annotation>
038: * <xsd:documentation> A UserLayer allows a user-defined
039: * layer to be built from WFS and WCS data. </xsd:documentation>
040: * </xsd:annotation>
041: * <xsd:complexType>
042: * <xsd:sequence>
043: * <xsd:element ref="sld:Name" minOccurs="0"/>
044: * <xsd:element ref="sld:RemoteOWS" minOccurs="0"/>
045: * <xsd:element ref="sld:LayerFeatureConstraints"/>
046: * <xsd:element ref="sld:UserStyle" maxOccurs="unbounded"/>
047: * </xsd:sequence>
048: * </xsd:complexType>
049: * </xsd:element>
050: *
051: * </code>
052: * </pre>
053: * </p>
054: *
055: * @generated
056: */
057: public class SLDUserLayerBinding extends AbstractComplexBinding {
058: StyleFactory styleFactory;
059:
060: public SLDUserLayerBinding(StyleFactory styleFactory) {
061: this .styleFactory = styleFactory;
062: }
063:
064: /**
065: * @generated
066: */
067: public QName getTarget() {
068: return SLD.USERLAYER;
069: }
070:
071: /**
072: * <!-- begin-user-doc -->
073: * <!-- end-user-doc -->
074: *
075: * @generated modifiable
076: */
077: public int getExecutionMode() {
078: return AFTER;
079: }
080:
081: /**
082: * <!-- begin-user-doc -->
083: * <!-- end-user-doc -->
084: *
085: * @generated modifiable
086: */
087: public Class getType() {
088: return UserLayer.class;
089: }
090:
091: /**
092: * <!-- begin-user-doc -->
093: * <!-- end-user-doc -->
094: *
095: * @generated modifiable
096: */
097: public void initialize(ElementInstance instance, Node node,
098: MutablePicoContainer context) {
099: }
100:
101: /**
102: * <!-- begin-user-doc -->
103: * <!-- end-user-doc -->
104: *
105: * @generated modifiable
106: */
107: public Object parse(ElementInstance instance, Node node,
108: Object value) throws Exception {
109: UserLayer userLayer = styleFactory.createUserLayer();
110:
111: //<xsd:element ref="sld:Name" minOccurs="0"/>
112: if (node.hasChild("Name")) {
113: userLayer.setName((String) node.getChildValue("Name"));
114: }
115:
116: //<xsd:element ref="sld:RemoteOWS" minOccurs="0"/>
117: if (node.hasChild("RemoteOWS")) {
118: userLayer.setRemoteOWS((RemoteOWS) node
119: .getChildValue("RemoteOWS"));
120: }
121:
122: //<xsd:element ref="sld:LayerFeatureConstraints"/>
123: if (node.hasChild("LayerFeatureConstraints")) {
124: LayerFeatureConstraints lfc = (LayerFeatureConstraints) node
125: .getChildValue("LayerFeatureConstraints");
126: userLayer.setLayerFeatureConstraints(lfc
127: .getFeatureTypeConstraints());
128: }
129:
130: //<xsd:element ref="sld:UserStyle" maxOccurs="unbounded"/>
131: for (Iterator i = node.getChildValues("UserStyle").iterator(); i
132: .hasNext();) {
133: userLayer.addUserStyle((Style) i.next());
134: }
135:
136: return userLayer;
137: }
138: }
|