source: osm/applications/editors/josm/plugins/opendata/includes/org/geotools/filter/FunctionImpl.java@ 28000

Last change on this file since 28000 was 28000, checked in by donvip, 12 years ago

Import new "opendata" JOSM plugin

File size: 2.7 KB
Line 
1/*
2 * GeoTools - The Open Source Java GIS Toolkit
3 * http://geotools.org
4 *
5 * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation;
10 * version 2.1 of the License.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
17package org.geotools.filter;
18
19import java.util.ArrayList;
20import java.util.Collections;
21import java.util.List;
22
23import org.geotools.filter.expression.ExpressionAbstract;
24import org.opengis.filter.expression.Expression;
25import org.opengis.filter.expression.ExpressionVisitor;
26import org.opengis.filter.expression.Function;
27import org.opengis.filter.expression.Literal;
28
29/**
30 * Default implementation of a Function; you may extend this class to
31 * implement specific functionality.
32 * <p>
33 *
34 * @author Cory Horner, Refractions Research
35 *
36 *
37 *
38 * @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FunctionImpl.java $
39 */
40public class FunctionImpl extends ExpressionAbstract implements Function {
41
42 /** function name **/
43 String name;
44
45 /** function params **/
46 List<Expression> params = Collections.emptyList();
47
48 Literal fallbackValue;
49
50 /**
51 * Gets the name of this function.
52 *
53 * @return the name of the function.
54 *
55 */
56 public String getName() {
57 return name;
58 }
59
60 /**
61 * Returns the function parameters.
62 */
63 public List<Expression> getParameters() {
64 return new ArrayList<Expression>(params);
65 }
66
67 /**
68 * Default implementation simply returns the fallbackValue.
69 * <p>
70 * Please override this method to produce a value based on the
71 * provided arguments.
72 * @param object Object being evaluated; often a Feature
73 * @return value for the provided object
74 */
75 public Object evaluate(Object object) {
76 return fallbackValue.evaluate( object );
77 }
78
79 /**
80 * Sets the function parameters.
81 */
82 @SuppressWarnings("unchecked")
83 public void setParameters(List<Expression> params) {
84 this.params = params == null? Collections.EMPTY_LIST : new ArrayList<Expression>(params);
85 }
86
87 public void setFallbackValue(Literal fallbackValue) {
88 this.fallbackValue = fallbackValue;
89 }
90
91 public Object accept(ExpressionVisitor visitor, Object extraData) {
92 return visitor.visit( this, extraData );
93 }
94}
Note: See TracBrowser for help on using the repository browser.