/*
* 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 org.geotools.se.v1_1.SE;
import org.geotools.xml.*;
import org.opengis.filter.FilterFactory;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.Function;
import javax.xml.namespace.QName;
/**
* Binding object for the element http://www.opengis.net/se:Trim.
*
* <p>
*
* <pre>
* <code>
* <xsd:element name="Trim" substitutionGroup="se:Function" type="se:TrimType">
* <xsd:annotation>
* <xsd:documentation>
* Strips off chars from a string value
* </xsd:documentation>
* </xsd:annotation>
* </xsd:element>
*
* </code>
* </pre>
*
* <pre>
* <code>
* <xsd:complexType name="TrimType">
* <xsd:complexContent>
* <xsd:extension base="se:FunctionType">
* <xsd:sequence>
* <xsd:element ref="se:StringValue"/>
* </xsd:sequence>
* <xsd:attribute name="stripOffPosition" type="se:stripOffPositionType"/>
* <xsd:attribute name="stripOffChar" type="xsd:string"/>
* </xsd:extension>
* </xsd:complexContent>
* </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/TrimBinding.java $
*/
public class TrimBinding extends AbstractComplexBinding {
FilterFactory filterFactory;
public TrimBinding(FilterFactory filterFactory) {
this.filterFactory = filterFactory;
}
/**
* @generated
*/
public QName getTarget() {
return SE.Trim;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Class getType() {
return Function.class;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
//<xsd:element ref="se:StringValue"/>
Expression str = (Expression) node.getChildValue("StringValue");
//<xsd:attribute name="stripOffPosition" type="se:stripOffPositionType"/>
Expression pos = filterFactory.literal(node.getAttributeValue("stripOffPosition"));
//<xsd:attribute name="stripOffChar" type="xsd:string"/>
Expression ch = filterFactory.literal(node.getAttributeValue("stripOffChar"));
return filterFactory.function("strTrim2", str, pos, ch);
}
}