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.List;
022: import javax.xml.namespace.QName;
023: import org.geotools.styling.FeatureTypeStyle;
024: import org.geotools.styling.Rule;
025: import org.geotools.styling.StyleFactory;
026: import org.geotools.xml.*;
027:
028: /**
029: * Binding object for the element http://www.opengis.net/sld:FeatureTypeStyle.
030: *
031: * <p>
032: * <pre>
033: * <code>
034: * <xsd:element name="FeatureTypeStyle">
035: * <xsd:annotation>
036: * <xsd:documentation> A FeatureTypeStyle contains styling
037: * information specific to one feature type. This is the
038: * SLD level that separates the 'layer'
039: * handling from the 'feature' handling. </xsd:documentation>
040: * </xsd:annotation>
041: * <xsd:complexType>
042: * <xsd:sequence>
043: * <xsd:element ref="sld:Name" minOccurs="0"/>
044: * <xsd:element ref="sld:Title" minOccurs="0"/>
045: * <xsd:element ref="sld:Abstract" minOccurs="0"/>
046: * <xsd:element ref="sld:FeatureTypeName" minOccurs="0"/>
047: * <xsd:element ref="sld:SemanticTypeIdentifier" minOccurs="0" maxOccurs="unbounded"/>
048: * <xsd:element ref="sld:Rule" maxOccurs="unbounded"/>
049: * </xsd:sequence>
050: * </xsd:complexType>
051: * </xsd:element>
052: *
053: * </code>
054: * </pre>
055: * </p>
056: *
057: * @generated
058: */
059: public class SLDFeatureTypeStyleBinding extends AbstractComplexBinding {
060: StyleFactory styleFactory;
061:
062: public SLDFeatureTypeStyleBinding(StyleFactory styleFactory) {
063: this .styleFactory = styleFactory;
064: }
065:
066: /**
067: * @generated
068: */
069: public QName getTarget() {
070: return SLD.FEATURETYPESTYLE;
071: }
072:
073: /**
074: * <!-- begin-user-doc -->
075: * <!-- end-user-doc -->
076: *
077: * @generated modifiable
078: */
079: public int getExecutionMode() {
080: return AFTER;
081: }
082:
083: /**
084: * <!-- begin-user-doc -->
085: * <!-- end-user-doc -->
086: *
087: * @generated modifiable
088: */
089: public Class getType() {
090: return FeatureTypeStyle.class;
091: }
092:
093: /**
094: * <!-- begin-user-doc -->
095: * <!-- end-user-doc -->
096: *
097: * @generated modifiable
098: */
099: public void initialize(ElementInstance instance, Node node,
100: MutablePicoContainer context) {
101: }
102:
103: /**
104: * <!-- begin-user-doc -->
105: * <!-- end-user-doc -->
106: *
107: * @generated modifiable
108: */
109: public Object parse(ElementInstance instance, Node node,
110: Object value) throws Exception {
111: FeatureTypeStyle featureTypeStyle = styleFactory
112: .createFeatureTypeStyle();
113:
114: //<xsd:element ref="sld:Name" minOccurs="0"/>
115: if (node.hasChild("Name")) {
116: featureTypeStyle.setName((String) node
117: .getChildValue("Name"));
118: }
119:
120: //<xsd:element ref="sld:Title" minOccurs="0"/>
121: if (node.hasChild("Title")) {
122: featureTypeStyle.setTitle((String) node
123: .getChildValue("Title"));
124: }
125:
126: //<xsd:element ref="sld:Abstract" minOccurs="0"/>
127: if (node.hasChild("Abstract")) {
128: featureTypeStyle.setAbstract((String) node
129: .getChildValue("Abstract"));
130: }
131:
132: //<xsd:element ref="sld:FeatureTypeName" minOccurs="0"/>
133: if (node.hasChild("FeatureTypeName")) {
134: featureTypeStyle.setFeatureTypeName((String) node
135: .getChildValue("FeatureTypeName"));
136: }
137:
138: //<xsd:element ref="sld:SemanticTypeIdentifier" minOccurs="0" maxOccurs="unbounded"/>
139: if (node.hasChild("SemanticTypeIdentifier")) {
140: List ids = node.getChildValues("SemanticTypeIdentifier");
141: featureTypeStyle.setSemanticTypeIdentifiers((String[]) ids
142: .toArray(new String[ids.size()]));
143: }
144:
145: //<xsd:element ref="sld:Rule" maxOccurs="unbounded"/>
146: if (node.hasChild("Rule")) {
147: List rules = node.getChildValues("Rule");
148: featureTypeStyle.setRules((Rule[]) rules
149: .toArray(new Rule[rules.size()]));
150: }
151:
152: return featureTypeStyle;
153: }
154: }
|