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.filter.Expression;
024: import org.geotools.filter.FilterFactory;
025: import org.geotools.sld.CssParameter;
026: import org.geotools.xml.*;
027:
028: /**
029: * Binding object for the element http://www.opengis.net/sld:CssParameter.
030: *
031: * <p>
032: * <pre>
033: * <code>
034: * <xsd:element name="CssParameter">
035: * <xsd:annotation>
036: * <xsd:documentation> A "CssParameter" refers to
037: * an SVG/CSS graphical-formatting parameter. The
038: * parameter is identified using the "name" attribute
039: * and the content of the element gives the SVG/CSS-coded
040: * value. </xsd:documentation>
041: * </xsd:annotation>
042: * <xsd:complexType mixed="true">
043: * <xsd:complexContent mixed="true">
044: * <xsd:extension base="sld:ParameterValueType">
045: * <xsd:attribute name="name" type="xsd:string" use="required"/>
046: * </xsd:extension>
047: * </xsd:complexContent>
048: * </xsd:complexType>
049: * </xsd:element>
050: *
051: * </code>
052: * </pre>
053: * </p>
054: *
055: * @generated
056: */
057: public class SLDCssParameterBinding extends AbstractComplexBinding {
058: FilterFactory filterFactory;
059:
060: public SLDCssParameterBinding(FilterFactory filterFactory) {
061: this .filterFactory = filterFactory;
062: }
063:
064: /**
065: * @generated
066: */
067: public QName getTarget() {
068: return SLD.CSSPARAMETER;
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 CssParameter.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: CssParameter parameter = new CssParameter((String) node
110: .getAttributeValue("name"));
111:
112: for (Iterator itr = node.getChildren().iterator(); itr
113: .hasNext();) {
114: Node child = (Node) itr.next();
115:
116: if (child.getValue() instanceof Expression) {
117: parameter.getExpressions().add(child.getValue());
118: }
119: }
120:
121: String text = instance.getText();
122:
123: if ((text != null) && !"".equals(text)) {
124: Expression exp = filterFactory
125: .createLiteralExpression(text);
126:
127: if (exp != null) {
128: parameter.getExpressions().add(exp);
129: }
130: }
131:
132: return parameter;
133: }
134: }
|