/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2002-2010, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.se.v1_1.bindings;
import java.net.URI;
import org.geotools.se.v1_1.SE;
import org.geotools.styling.Symbolizer;
import org.geotools.styling.UomOgcMapping;
import org.geotools.xml.*;
import org.opengis.style.Description;
import javax.xml.namespace.QName;
/**
* Binding object for the type http://www.opengis.net/se:SymbolizerType.
*
* <p>
*
* <pre>
* <code>
* <xsd:complexType abstract="true" name="SymbolizerType">
* <xsd:annotation>
* <xsd:documentation>
* A "SymbolizerType" is an abstract type for encoding the graphical
* properties used to portray geographic information. Concrete Symbolizer
* types are derived from this base type.
* </xsd:documentation>
* </xsd:annotation>
* <xsd:sequence>
* <xsd:element minOccurs="0" ref="se:Name"/>
* <xsd:element minOccurs="0" ref="se:Description"/>
* <xsd:element minOccurs="0" ref="se:BaseSymbolizer"/>
* </xsd:sequence>
* <xsd:attribute name="version" type="se:VersionType"/>
* <xsd:attribute name="uom" type="xsd:anyURI"/>
* </xsd:complexType>
*
* </code>
* </pre>
*
* </p>
*
* @generated
*
* @source $URL: http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/SymbolizerTypeBinding.java $
*/
public class SymbolizerTypeBinding extends AbstractComplexBinding {
/**
* @generated
*/
public QName getTarget() {
return SE.SymbolizerType;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Class getType() {
return Symbolizer.class;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
Symbolizer sym = (Symbolizer) value;
// <xsd:sequence>
// <xsd:element minOccurs="0" ref="se:Name"/>
// <xsd:element minOccurs="0" ref="se:Description"/>
// <xsd:element minOccurs="0" ref="se:BaseSymbolizer"/>
// </xsd:sequence>
// <xsd:attribute name="version" type="se:VersionType"/>
// <xsd:attribute name="uom" type="xsd:anyURI"/>
if (node.hasChild("Name")) {
sym.setName((String)node.getChildValue("Name"));
}
if (node.hasChild("Description")) {
sym.setDescription((Description) node.getChildValue("Description"));
}
if (node.hasChild("BaseSymbolizer")) {
//throw new IllegalArgumentException("BaseSymbolizer not supported");
}
if (node.hasAttribute("version")) {
//throw new IllegalArgumentException("version not supported");
}
if (node.hasAttribute("uom")) {
String uom = ((URI) node.getAttributeValue("uom")).toString();
if (UomOgcMapping.get(uom) == null) {
throw new IllegalArgumentException("uom " + uom + " not supported");
}
sym.setUnitOfMeasure(UomOgcMapping.get(uom).getUnit());
}
return sym;
}
}