diff --git a/modules/library/api/src/main/java/org/geotools/data/Parameter.java b/modules/library/api/src/main/java/org/geotools/data/Parameter.java index 2cc4c0d..6a45320 100644 --- a/modules/library/api/src/main/java/org/geotools/data/Parameter.java +++ b/modules/library/api/src/main/java/org/geotools/data/Parameter.java @@ -29,7 +29,7 @@ import org.opengis.util.InternationalString; * * @source $URL$ */ -public class Parameter { +public class Parameter implements org.opengis.parameter.Parameter{ /** * This is the key (ie machine readable text) used to represent this parameter in a * java.util.Map. @@ -263,6 +263,60 @@ public class Parameter { this.sample = sample; this.metadata = metadata == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(metadata); } + + /** + * Constructs a parameter from key and type + * + * @param key machine readable key for use in a java.util.Map + * @param type Java class for the expected value + */ + public Parameter(String key, Class type) { + this(key, type, null, null,true, 1, 1, null, null); + } + + /** + * Constructs a parameter from key, type, and min/max occurs. + * + * @param key machine readable key for use in a java.util.Map + * @param type Java class for the expected value + * @param min Minimum value of occurrences + * @param max Maximum value of occurrences + */ + public Parameter(String key, Class type, int min, int max) { + this(key, type, null, null, min > 0, min, max, null, null); + } + + public String getName() { + return key; + } + + public InternationalString getTitle() { + return title; + } + + public InternationalString getDescription() { + return description; + } + + public Class getType() { + return type; + } + + public Boolean isRequired() { + return required; + } + + public int getMinOccurs() { + return minOccurs; + } + + public int getMaxOccurs() { + return maxOccurs; + } + + public T getDefaultValue() { + return (T) sample; + } /** * Provides for easy access to the {@link Parameter#IS_PASSWORD} metadata diff --git a/modules/library/main/src/main/java/org/geotools/filter/FilterFactoryImpl.java b/modules/library/main/src/main/java/org/geotools/filter/FilterFactoryImpl.java index 55dbcdf..fcc6a7e 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/FilterFactoryImpl.java +++ b/modules/library/main/src/main/java/org/geotools/filter/FilterFactoryImpl.java @@ -111,6 +111,8 @@ import org.opengis.filter.spatial.Touches; import org.opengis.filter.spatial.Within; import org.opengis.geometry.BoundingBox; import org.opengis.geometry.Geometry; +import org.opengis.parameter.Parameter; +import org.opengis.util.InternationalString; import org.xml.sax.helpers.NamespaceSupport; import com.vividsolutions.jts.geom.Envelope; @@ -1019,7 +1021,13 @@ public class FilterFactoryImpl implements FilterFactory { String name, GeometryOperand[] geometryOperands) { return new SpatialOperatorImpl( name, geometryOperands ); } - + + public Parameter parameter(String name, Class type, InternationalString title, + InternationalString description, boolean required, int minOccurs, int maxOccurs, T defaultValue) { + return new org.geotools.data.Parameter(name, type, title, description, required, + minOccurs, maxOccurs, defaultValue, null); + }; + public FunctionName functionName(String name, int nargs) { return new FunctionNameImpl( name, nargs ); } @@ -1028,6 +1036,10 @@ public class FilterFactoryImpl implements FilterFactory { return new FunctionNameImpl( name, nargs, argNames ); } + public FunctionName functionName(String name, List> args, Parameter ret) { + return new FunctionNameImpl( name, ret, args ); + } + public Functions functions(FunctionName[] functionNames) { return new FunctionsImpl( functionNames ); } diff --git a/modules/library/main/src/main/java/org/geotools/filter/FunctionImpl.java b/modules/library/main/src/main/java/org/geotools/filter/FunctionImpl.java index 4fa39b3..38e5669 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/FunctionImpl.java +++ b/modules/library/main/src/main/java/org/geotools/filter/FunctionImpl.java @@ -18,6 +18,7 @@ package org.geotools.filter; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.List; import org.geotools.filter.capability.FunctionNameImpl; @@ -27,6 +28,7 @@ import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.ExpressionVisitor; import org.opengis.filter.expression.Function; import org.opengis.filter.expression.Literal; +import org.opengis.parameter.Parameter; /** * Default implementation of a Function; you may extend this class to @@ -118,5 +120,57 @@ public class FunctionImpl extends ExpressionAbstract implements Function { public Object accept(ExpressionVisitor visitor, Object extraData) { return visitor.visit( this, extraData ); - } + } + + /** + * Gathers up and groups the parameters to the function based on the declared parameters. + */ + protected LinkedHashMap prepArguments(Object obj) { + LinkedHashMap prepped = new LinkedHashMap(); + + List> args = getFunctionName().getArguments(); + List expr = getParameters(); + + if (expr.size() < args.size()) { + Parameter last = args.get(args.size()-1); + + //check the last argument + if (args.get(0).getMinOccurs() != 0) { + throw new IllegalArgumentException(String.format("No arguments specified for arg " + + "%s, minOccurs = %d", last.getName().toString(), last.getMinOccurs())); + } + } + for (int i = 0; i < expr.size(); i++) { + Parameter arg = args.get(Math.min(i, args.size()-1)); + String argName = arg.getName().toString(); + + Object o = expr.get(i).evaluate(obj); + + //TODO: check the argument type and convert if necessary + if (prepped.containsKey(argName)) { + if (arg.getMaxOccurs() == 1) { + throw new IllegalArgumentException(String.format("Multiple values specified for " + + "argument %s but maxOccurs = 1", argName)); + } + + //if there is already a value for this argument it is a multi argument which + // means a list + List l = (List) prepped.get(argName); + l.add(o); + } + else { + //check for variable argument, use a list if maxOccurs > 1 + if (arg.getMaxOccurs() < 0 || arg.getMaxOccurs() > 1) { + List l = new ArrayList(); + l.add(o); + prepped.put(argName, l); + } + else { + prepped.put(argName, o); + } + } + } + + return prepped; + } } diff --git a/modules/library/main/src/main/java/org/geotools/filter/capability/FunctionNameImpl.java b/modules/library/main/src/main/java/org/geotools/filter/capability/FunctionNameImpl.java index da83bb9..3b5af59 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/capability/FunctionNameImpl.java +++ b/modules/library/main/src/main/java/org/geotools/filter/capability/FunctionNameImpl.java @@ -16,11 +16,16 @@ */ package org.geotools.filter.capability; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.Map; import org.opengis.filter.capability.FunctionName; import org.opengis.filter.expression.Function; +import org.opengis.geometry.coordinate.ParametricCurveSurface; +import org.opengis.parameter.Parameter; /** * Implementation of the FunctionName interface. @@ -41,56 +46,69 @@ public class FunctionNameImpl extends OperatorImpl implements FunctionName { * Example: concat( str1, str2,... ) has -2 * */ - int argumentCount; + //int argumentCount; - List argumentNames; + //List argumentNames; + List> args; + Parameter ret; public FunctionNameImpl( String name, int argumentCount ) { - super( name ); - this.argumentCount = argumentCount; - this.argumentNames = null; + this(name, generateReturn(), generateArguments(argumentCount)); } public FunctionNameImpl( String name, String ... argumentsNames ) { - super( name ); - this.argumentCount = argumentsNames.length; - this.argumentNames = generateArgumentNames( argumentCount, argumentsNames ); + this(name, argumentsNames.length, Arrays.asList(argumentsNames)); } public FunctionNameImpl( String name, List argumentsNames ) { this( name, argumentsNames.size(), argumentsNames ); } + public FunctionNameImpl( String name, int argumentCount, List argumentsNames ) { - super( name ); - this.argumentCount = argumentCount; - this.argumentNames = generateArgumentNames( argumentCount, argumentsNames ); + this(name, generateReturn(), generateArguments(argumentsNames)); } + public FunctionNameImpl( String name, int argumentCount, String ... argumentsNames ) { - super( name ); - this.argumentCount = argumentCount; - this.argumentNames = generateArgumentNames( argumentCount, argumentsNames ); + this(name, argumentCount, Arrays.asList(argumentsNames)); } public FunctionNameImpl( FunctionName copy ) { super( copy ); - this.argumentCount = copy.getArgumentCount(); - this.argumentNames = generateArgumentNames( argumentCount, copy.getArgumentNames() ); + this.ret = copy.getReturn(); + this.args = copy.getArguments(); + validate(); + } + + public FunctionNameImpl( String name, Parameter retern, Parameter... arguments) { + this(name, retern, Arrays.asList(arguments)); } - public void setArgumentCount( int argumentCount ) { - this.argumentCount = argumentCount; - this.argumentNames = generateArgumentNames( argumentCount, argumentNames ); + public FunctionNameImpl( String name, Parameter retern, List> arguments) { + super(name); + this.ret = retern; + this.args = arguments; + validate(); } public int getArgumentCount() { - return argumentCount; + return args.size(); + } + + public List> getArguments() { + return args; + } + + public Parameter getReturn() { + return ret; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + argumentCount; + if (args != null) { + result = prime * result + args.hashCode(); + } return result; } @@ -103,54 +121,85 @@ public class FunctionNameImpl extends OperatorImpl implements FunctionName { if (getClass() != obj.getClass()) return false; final FunctionNameImpl other = (FunctionNameImpl) obj; - if (argumentCount != other.argumentCount) - return false; - return true; + if (args == null) { + return other.args == null; + } + return args.equals(other.args); } - public void setArgumentNames( List argumentNames ) { - this.argumentNames = argumentNames; - } /** * Optional ArgumentNames. *

* This is a fixed length list the same size as getArgumentCount(). */ public List getArgumentNames() { - if( argumentNames == null ){ - argumentNames = generateArgumentNames( argumentCount ); - } - return argumentNames; - } - - private static List generateArgumentNames( int count ){ - count = Math.abs( count ); - List names = Arrays.asList( new String[count]); - for( int i=0; i < count; i++){ - names.set(i, "arg"+i ); + List names = new ArrayList(); + for (Parameter arg : args) { + names.add(arg.getName()); } return names; + } - private static List generateArgumentNames( int count, List copy ){ - List names = Arrays.asList( new String[count]); - for( int i=0; i < count; i++){ - String name = "arg"+i; - if( copy != null && i < copy.size() && copy.get(i) != null ){ - name = copy.get(i); + + /** + * Validates the structure of arguments, basically enforcing java conventions for variable + * level arguments. + */ + private void validate() { + for (int i = 0; i < args.size(); i++) { + Parameter arg = args.get(i); + if (arg.getMaxOccurs() == 0) { + throw new IllegalArgumentException(String.format("Argument %s has zero max")); + } + if (arg.getMinOccurs() != 1 || arg.getMaxOccurs() != 1) { + //this can only happen for the last argument + if (i != args.size()-1) { + throw new IllegalArgumentException(String.format("Argument %s(%d,%d) invalid." + + " Variable arguments must be the last argument of function.", + arg.getName(), arg.getMinOccurs(), arg.getMaxOccurs())); + } } - names.set(i, name ); } - return names; } - private static List generateArgumentNames( int count, String[] copy ){ - List names = Arrays.asList( new String[count]); - for( int i=0; i < count; i++){ - String name = "arg"+i; - if( copy != null && i < copy.length && copy[i] != null ){ - name = copy[i]; + + private static Parameter generateReturn() { + return parameter("return", Object.class); + } + + private static List> generateArguments(int count) { + List> args = new ArrayList(); + if (count < 0) { + //negative count used to represent variable arguments, create a single argument + // with minOccurs == abs(count) + args.add(parameter("arg", Object.class, Math.abs(count), Integer.MAX_VALUE)); + } + else { + for (int i = 0; i < count; i++) { + args.add(parameter("arg" + i, Object.class, 1, 1)); } - names.set(i, name ); } - return names; + + return args; + } + + private static List> generateArguments(List names) { + List> args = new ArrayList(); + + for(String name : names) { + args.add(parameter(name, Object.class, 1, 1)); + } + + return args; + } + + public static Parameter parameter(String name, Class type) { + return parameter(name, type, 1, 1); + } + + public static Parameter parameter(String name, Class type, int min, int max) { + final int fmax = max < 0 ? Integer.MAX_VALUE : max; + final int fmin = min; + + return new org.geotools.data.Parameter(name, type, null, null, min==0, min, max, null, null); } } diff --git a/modules/library/main/src/main/java/org/geotools/filter/function/CategorizeFunction.java b/modules/library/main/src/main/java/org/geotools/filter/function/CategorizeFunction.java index 31c259e..2a1f040 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/function/CategorizeFunction.java +++ b/modules/library/main/src/main/java/org/geotools/filter/function/CategorizeFunction.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import org.geotools.factory.CommonFactoryFinder; +import org.geotools.filter.capability.FunctionNameImpl; import org.opengis.filter.Filter; import org.opengis.filter.FilterFactory2; import org.opengis.filter.capability.FunctionName; @@ -77,32 +78,8 @@ public class CategorizeFunction implements Function { * Make the instance of FunctionName available in * a consistent spot. */ - public static final FunctionName NAME = new Name(); - - /** - * Describe how this function works. - * (should be available via FactoryFinder lookup...) - */ - public static class Name implements FunctionName { - - public int getArgumentCount() { - return 2; // indicating unbounded, 2 minimum - } - - public List getArgumentNames() { - return Arrays.asList(new String[]{ - "LookupValue", - "Value", - "Threshold 1", "Value 1", - "Threshold 2", "Value 2", - "succeeding or preceding" - }); - } - - public String getName() { - return "Categorize"; - } - }; + public static final FunctionName NAME = new FunctionNameImpl("Categorize", "LookupValue", + "Value", "Threshold 1", "Value 1", "Threshold 2", "Value 2", "succeeding or preceding"); public CategorizeFunction() { this( new ArrayList(), null); diff --git a/modules/library/main/src/main/java/org/geotools/filter/function/InterpolateFunction.java b/modules/library/main/src/main/java/org/geotools/filter/function/InterpolateFunction.java index ef72602..2541feb 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/function/InterpolateFunction.java +++ b/modules/library/main/src/main/java/org/geotools/filter/function/InterpolateFunction.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.geotools.factory.CommonFactoryFinder; +import org.geotools.filter.capability.FunctionNameImpl; import org.geotools.util.Converters; import org.opengis.filter.FilterFactory2; @@ -161,32 +162,8 @@ public class InterpolateFunction implements Function { * Make the instance of FunctionName available in * a consistent spot. */ - public static final FunctionName NAME = new Name(); - - /** - * Describe how this function works. - * (should be available via FactoryFinder lookup...) - */ - public static class Name implements FunctionName { - - public int getArgumentCount() { - return -2; // indicating unbounded, 2 minimum - } - - public List getArgumentNames() { - return Arrays.asList(new String[]{ - "LookupValue", - "Data 1", "Value 1", - "Data 2", "Value 2", - "linear, cosine or cubic", - "numeric or color" - }); - } - - public String getName() { - return "Interpolate"; - } - }; + public static final FunctionName NAME = new FunctionNameImpl("Interpolate", "LookupValue", + "Data 1", "Value 1", "Data 2", "Value 2", "linear, cosine or cubic", "numeric or color"); public InterpolateFunction() { this( new ArrayList(), null); diff --git a/modules/library/main/src/main/java/org/geotools/filter/function/RecodeFunction.java b/modules/library/main/src/main/java/org/geotools/filter/function/RecodeFunction.java index 206fb7c..0a07ed9 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/function/RecodeFunction.java +++ b/modules/library/main/src/main/java/org/geotools/filter/function/RecodeFunction.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import org.geotools.factory.CommonFactoryFinder; +import org.geotools.filter.capability.FunctionNameImpl; import org.opengis.filter.FilterFactory2; import org.opengis.filter.capability.FunctionName; import org.opengis.filter.expression.Expression; @@ -63,26 +64,8 @@ public class RecodeFunction implements Function { /** * Make the instance of FunctionName available in a consistent spot. */ - public static final FunctionName NAME = new Name(); - - /** - * Describe how this function works. (should be available via FactoryFinder lookup...) - */ - public static class Name implements FunctionName { - - public int getArgumentCount() { - return -2; // indicating unbounded, 2 minimum - } - - public List getArgumentNames() { - return Arrays.asList(new String[] { "LookupValue", "Data 1", "Value 1", "Data 2", - "Value 2" }); - } - - public String getName() { - return "Recode"; - } - }; + public static final FunctionName NAME = new FunctionNameImpl("Recode", "LookupValue", "Data 1", + "Value 1", "Data 2", "Value 2"); public RecodeFunction() { this(new ArrayList(), null); diff --git a/modules/library/main/src/main/java/org/geotools/filter/function/string/ConcatenateFunction.java b/modules/library/main/src/main/java/org/geotools/filter/function/string/ConcatenateFunction.java index c3ef47e..cb9491b 100644 --- a/modules/library/main/src/main/java/org/geotools/filter/function/string/ConcatenateFunction.java +++ b/modules/library/main/src/main/java/org/geotools/filter/function/string/ConcatenateFunction.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.List; import org.geotools.filter.FunctionImpl; +import org.geotools.filter.capability.FunctionNameImpl; import org.opengis.filter.capability.FunctionName; import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.ExpressionVisitor; @@ -44,31 +45,9 @@ public class ConcatenateFunction extends FunctionImpl { * Make the instance of FunctionName available in * a consistent spot. */ - public static final FunctionName NAME = new Name(); + public static final FunctionName NAME = new FunctionNameImpl("Concatenate", "text 1", "text 2", + "text 3"); - /** - * Describe how this function works. - * (should be available via FactoryFinder lookup...) - */ - public static class Name implements FunctionName { - - public int getArgumentCount() { - return 2; // indicating unbounded, 2 minimum - } - - public List getArgumentNames() { - return Arrays.asList(new String[]{ - "text 1", - "text 2", - "text 3" - }); - } - - public String getName() { - return "Concatenate"; - } - }; - public ConcatenateFunction() { this.functionName = NAME; } diff --git a/modules/library/main/src/main/java/org/geotools/filter/function/string/StringInFunction.java b/modules/library/main/src/main/java/org/geotools/filter/function/string/StringInFunction.java new file mode 100644 index 0000000..2f82b99 --- /dev/null +++ b/modules/library/main/src/main/java/org/geotools/filter/function/string/StringInFunction.java @@ -0,0 +1,68 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2005-2008, 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.filter.function.string; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; + +import org.geotools.data.Parameter; +import org.geotools.factory.CommonFactoryFinder; +import org.geotools.filter.FunctionImpl; +import org.opengis.filter.FilterFactory2; +import org.opengis.filter.capability.FunctionName; + +@SuppressWarnings("unchecked") +public class StringInFunction extends FunctionImpl { + + static FunctionName NAME = null; + static { + FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); + NAME = ff.functionName("strIn", (List) Arrays.asList( new Parameter("string", String.class), + new Parameter("matchCase", Boolean.class), new Parameter("values", String.class, 1, -1)), + new Parameter("result", Boolean.class)); + } + + public StringInFunction() { + setName("strIn"); + functionName = NAME; + } + + @Override + public Object evaluate(Object object) { + LinkedHashMap args = prepArguments(object); + + String str = (String) args.get("string"); + Boolean matchCase = (Boolean) args.get("matchCase"); + List values = (List) args.get("values"); + + for (String value : values) { + if (matchCase) { + if (str.equals(value)) { + return true; + } + } + else { + if (str.equalsIgnoreCase(value)) { + return true; + } + } + } + + return false; + } +} diff --git a/modules/library/main/src/test/java/org/geotools/filter/function/string/StringInFunctionTest.java b/modules/library/main/src/test/java/org/geotools/filter/function/string/StringInFunctionTest.java new file mode 100644 index 0000000..1520fb4 --- /dev/null +++ b/modules/library/main/src/test/java/org/geotools/filter/function/string/StringInFunctionTest.java @@ -0,0 +1,43 @@ +package org.geotools.filter.function.string; + +import java.util.Arrays; +import java.util.List; + +import org.geotools.factory.CommonFactoryFinder; +import org.geotools.filter.FunctionImpl; +import org.opengis.filter.FilterFactory; + +import junit.framework.TestCase; + +public class StringInFunctionTest extends TestCase { + + FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); + + public void test() throws Exception { + StringInFunction f = new StringInFunction(); + + List params = Arrays.asList(ff.literal("foo"), ff.literal(true), ff.literal("foo"), + ff.literal("bar"), ff.literal("baz")); + ((FunctionImpl)f).setParameters(params); + + assertEquals(Boolean.TRUE, f.evaluate(null)); + + params = Arrays.asList(ff.literal("foo"), ff.literal(true), ff.literal("FOO"), + ff.literal("bar"), ff.literal("baz")); + ((FunctionImpl)f).setParameters(params); + assertEquals(Boolean.FALSE, f.evaluate(null)); + } + + public void testTooFewArguments() throws Exception { + StringInFunction f = new StringInFunction(); + + List params = Arrays.asList(ff.literal("foo"), ff.literal(true)); + ((FunctionImpl)f).setParameters(params); + + try { + f.evaluate(null); + fail(); + } + catch(IllegalArgumentException e) {} + } +} diff --git a/modules/library/opengis/src/main/java/org/opengis/filter/FilterFactory2.java b/modules/library/opengis/src/main/java/org/opengis/filter/FilterFactory2.java index 4ca3d66..2221575 100644 --- a/modules/library/opengis/src/main/java/org/opengis/filter/FilterFactory2.java +++ b/modules/library/opengis/src/main/java/org/opengis/filter/FilterFactory2.java @@ -30,6 +30,8 @@ import org.opengis.filter.spatial.Overlaps; import org.opengis.filter.spatial.Touches; import org.opengis.filter.spatial.Within; import org.opengis.geometry.BoundingBox; +import org.opengis.parameter.Parameter; +import org.opengis.util.InternationalString; import org.xml.sax.helpers.NamespaceSupport; @@ -51,7 +53,23 @@ public interface FilterFactory2 extends FilterFactory { // CAPABILITIES // //////////////////////////////////////////////////////////////////////////////// - + + /** + * Creates a parameter of a function. + * + * @param name Parameter name + * @param type Parameter type/class + * @param title Human readable title of the parameter + * @param description Extended description of the parameter + * @param required Flag indicating if the parameter is required or not + * @param minOccurs The minimum number of occurrences of the parameter + * @param maxOccurs The maximum number of occurrences of the parameter + * @param defaultValue Default value for the parameter + */ + Parameter parameter(String name, Class type, InternationalString title, + InternationalString description, boolean required, int minOccurs, int maxOccurs, + T defaultValue ); + /** * FunctionName used to describe an available function. * @@ -65,6 +83,15 @@ public interface FilterFactory2 extends FilterFactory { */ FunctionName functionName(String name, int nargs, List argNames); + /** + * FunctionName used to describe an available function. + * + * @param name name of function + * @param args Parameters describing function arguments. + * @param ret Parameter describing function return. + */ + FunctionName functionName(String name, List> args, Parameter ret); + //////////////////////////////////////////////////////////////////////////////// // // FILTERS diff --git a/modules/library/opengis/src/main/java/org/opengis/filter/capability/FunctionName.java b/modules/library/opengis/src/main/java/org/opengis/filter/capability/FunctionName.java index 400dc8b..adc3388 100644 --- a/modules/library/opengis/src/main/java/org/opengis/filter/capability/FunctionName.java +++ b/modules/library/opengis/src/main/java/org/opengis/filter/capability/FunctionName.java @@ -20,10 +20,11 @@ package org.opengis.filter.capability; // Annotations -import java.util.Collection; import java.util.List; import org.opengis.annotation.UML; +import org.opengis.parameter.Parameter; + import static org.opengis.annotation.Specification.*; /** @@ -61,14 +62,33 @@ public interface FunctionName extends Operator { * <xsd:attribute name="nArgs" type="xsd:string" use="required"/> * *

+ *

+ * This value is derived from {@link #getArguments()} + *

*/ @UML(identifier="argumentCount", specification=UNSPECIFIED) int getArgumentCount(); /** * Argument names for documentation purposes if known. - * + *

+ * This value is derived from {@link #getArguments()} + *

* @return Argument names (for documentation purposes) if known */ List getArgumentNames(); + + /** + * Arguments for the function accepts. + * + * @version 8.0 + */ + List> getArguments(); + + /** + * Return type of the function. + * + * @version 8.0 + */ + Parameter getReturn(); } \ No newline at end of file diff --git a/modules/library/opengis/src/main/java/org/opengis/parameter/Parameter.java b/modules/library/opengis/src/main/java/org/opengis/parameter/Parameter.java new file mode 100644 index 0000000..9b092be --- /dev/null +++ b/modules/library/opengis/src/main/java/org/opengis/parameter/Parameter.java @@ -0,0 +1,62 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * (C) 2003-2005, Open Geospatial Consortium Inc. + * + * All Rights Reserved. http://www.opengis.org/legal/ + */ +package org.opengis.parameter; + +import org.opengis.util.InternationalString; + +/** + * General parameter interface. + * + * @author Justin Deoliveira, OpenGeo + * + * @param + */ +public interface Parameter { + + /** + * Name of the parameter. + */ + String getName(); + + /** + * Title of the parameter. + */ + InternationalString getTitle(); + + /** + * Description of the parameter. + */ + InternationalString getDescription(); + + /** + * Type/class of the parameter. + */ + Class getType(); + + /** + * Flag indicating if the parameter is required or not. + */ + Boolean isRequired(); + + /** + * The minimum number of occurrences of the parameter. + */ + int getMinOccurs(); + + /** + * The maximum number of occurrences of the parameter. + */ + int getMaxOccurs(); + + /** + * A default value for the parameter. + */ + T getDefaultValue(); +}