/*
* 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.util.ArrayList;
import java.util.List;
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:FormatNumber.
*
* <p>
*
* <pre>
* <code>
* <xsd:element name="FormatNumber" substitutionGroup="se:Function" type="se:FormatNumberType">
* <xsd:annotation>
* <xsd:documentation>
* Function for formatting numbers to make them human readable.
* </xsd:documentation>
* </xsd:annotation>
* </xsd:element>
*
* </code>
* </pre>
*
* <pre>
* <code>
* <xsd:complexType name="FormatNumberType">
* <xsd:complexContent>
* <xsd:extension base="se:FunctionType">
* <xsd:sequence>
* <xsd:element ref="se:NumericValue"/>
* <xsd:element ref="se:Pattern"/>
* <xsd:element minOccurs="0" ref="se:NegativePattern"/>
* </xsd:sequence>
* <xsd:attribute default="." name="decimalPoint"
* type="xsd:string" use="optional"/>
* <xsd:attribute default="," name="groupingSeparator"
* type="xsd:string" use="optional"/>
* </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/FormatNumberBinding.java $
*/
public class FormatNumberBinding extends AbstractComplexBinding {
FilterFactory filterFactory;
public FormatNumberBinding(FilterFactory filterFactory) {
this.filterFactory = filterFactory;
}
/**
* @generated
*/
public QName getTarget() {
return SE.FormatNumber;
}
/**
* <!-- 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 {
Expression[] expressions = new Expression[5];
//<xsd:element ref="se:NumericValue"/>
expressions[1] = (Expression) node.getChildValue("NumericValue");
//<xsd:element ref="se:Pattern"/>
expressions[0] = filterFactory.literal(node.getChildValue("Pattern"));
//<xsd:element minOccurs="0" ref="se:NegativePattern"/>
if (node.hasChild("NegativePattern")) {
expressions[2] = filterFactory.literal(node.getChildValue("NegativePattern"));
}
else {
expressions[2] = filterFactory.literal("-");
}
//<xsd:attribute default="." name="decimalPoint" type="xsd:string" use="optional"/>
if (node.hasAttribute("decimalPoint")) {
expressions[3] = filterFactory.literal(node.getAttributeValue("decimalPoint"));
}
else {
expressions[3] = filterFactory.literal(".");
}
//<xsd:attribute default="," name="groupingSeparator" type="xsd:string" use="optional"/>
if (node.hasAttribute("groupingSeparator")) {
expressions[4] = filterFactory.literal(node.getAttributeValue("groupingSeparator"));
}
else {
expressions[4] = filterFactory.literal(",");
}
return filterFactory.function("numberFormat2", expressions);
}
}