com.apelon.modules.dts.editor.tql
Interface TQLFunction

All Known Implementing Classes:
TQLFunctionAdapter

public interface TQLFunction

Interface class for a TQL function.

Copyright (c) 2013 Apelon, Inc. All rights reserved.


Method Summary
 java.lang.String[] extractValues(java.lang.Object[] objs, TQLField field)
          Return the result(s) of the function as applied to the argument objects.
 boolean forceFullSearch(java.lang.String op, java.lang.String value)
          Return whether this function, when used in a selector with the operator op and argument value, should search all objects in the TQL Context.
 java.lang.String getName()
          Return the base name of this user function (without the initial "%")
 boolean isAggregator()
          Return whether this function returns one value for each extractValues argument object or one value for all the arguments (an aggregator).
 java.lang.String validateArgument(TQLField field)
          Test if the specified function argument is valid.
 

Method Detail

getName

java.lang.String getName()
Return the base name of this user function (without the initial "%")

Returns:
base name of the function

isAggregator

boolean isAggregator()
Return whether this function returns one value for each extractValues argument object or one value for all the arguments (an aggregator). The value of this method is typically false. Some functions, such as COUNT, are aggregators and must be handled as 'independent' export attributes. In this case, they must return true to isAggregator() and the length of the returned array will be one, not the size of the argument array.

Returns:
true if the function returns a single value independent of the number of extractValues arguments

forceFullSearch

boolean forceFullSearch(java.lang.String op,
                        java.lang.String value)
Return whether this function, when used in a selector with the operator op and argument value, should search all objects in the TQL Context. This is typically false and search optimizers/accelerators can be used. The COUNT function, on the other hand, must search all concepts when a value of zero is acceptable: COUNT(MyProp) < 2. In this case, forceFullSearch must return true to inhibit optimization. Returning true generally has negative performance implications.

Returns:
true if the function selector expression must search all concepts

validateArgument

java.lang.String validateArgument(TQLField field)
Test if the specified function argument is valid. Called during query parse.

Parameters:
field - the TQLField that defines the argument
Returns:
empty string if argument is valid, otherwise the error message

extractValues

java.lang.String[] extractValues(java.lang.Object[] objs,
                                 TQLField field)
Return the result(s) of the function as applied to the argument objects. The field argument can be used to determine the type of object used in the invocation if multiple types are permitted, e.g. an inverse association vs. a regular association.

Parameters:
objs - the array of objects resulting from evaluating the function argument
field - the TQLField object that defines the object
Returns:
the String array of function values, this array can be of different size than objs