Class CoreFunction
- java.lang.Object
-
- org.apache.commons.jxpath.ri.compiler.Expression
-
- org.apache.commons.jxpath.ri.compiler.Operation
-
- org.apache.commons.jxpath.ri.compiler.CoreFunction
-
public class CoreFunction extends Operation
An element of the compile tree representing one of built-in functions like "position()" or "number()".- Version:
- $Revision: 668329 $ $Date: 2008-06-16 16:59:48 -0500 (Mon, 16 Jun 2008) $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
-
-
Field Summary
Fields Modifier and Type Field Description private intfunctionCodeprivate static java.lang.DoubleZERO-
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE
-
-
Constructor Summary
Constructors Constructor Description CoreFunction(int functionCode, Expression[] args)Create a new CoreFunction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassertArgCount(int count)Assertcountargs.private voidassertArgRange(int min, int max)Assert at leastmin/at mostmaxargs.java.lang.Objectcompute(EvalContext context)Evaluates the expression.booleancomputeContextDependent()Returns true if any argument is context dependent or if the function is last(), position(), boolean(), local-name(), name(), string(), lang(), number().java.lang.ObjectcomputeValue(EvalContext context)Evaluates the expression.protected java.lang.ObjectfunctionBoolean(EvalContext context)boolean() implementation.protected java.lang.ObjectfunctionCeiling(EvalContext context)ceiling() implementation.protected java.lang.ObjectfunctionConcat(EvalContext context)concat() implementation.protected java.lang.ObjectfunctionContains(EvalContext context)contains() implementation.protected java.lang.ObjectfunctionCount(EvalContext context)count() implementation.protected java.lang.ObjectfunctionFalse(EvalContext context)false() implementation.protected java.lang.ObjectfunctionFloor(EvalContext context)floor() implementation.private java.lang.ObjectfunctionFormatNumber(EvalContext context)format-number() implementation.protected java.lang.ObjectfunctionID(EvalContext context)id() implementation.protected java.lang.ObjectfunctionKey(EvalContext context)key() implementation.protected java.lang.ObjectfunctionLang(EvalContext context)lang() implementation.protected java.lang.ObjectfunctionLast(EvalContext context)last() implementation.protected java.lang.ObjectfunctionLocalName(EvalContext context)local-name() implementation.protected java.lang.ObjectfunctionName(EvalContext context)name() implementation.protected java.lang.ObjectfunctionNamespaceURI(EvalContext context)namespace-uri() implementation.protected java.lang.ObjectfunctionNormalizeSpace(EvalContext context)normalize-space() implementation.protected java.lang.ObjectfunctionNot(EvalContext context)not() implementation.protected java.lang.ObjectfunctionNull(EvalContext context)null() implementation.protected java.lang.ObjectfunctionNumber(EvalContext context)number() implementation.protected java.lang.ObjectfunctionPosition(EvalContext context)position() implementation.protected java.lang.ObjectfunctionRound(EvalContext context)round() implementation.protected java.lang.ObjectfunctionStartsWith(EvalContext context)starts-with() implementation.protected java.lang.ObjectfunctionString(EvalContext context)string() implementation.protected java.lang.ObjectfunctionStringLength(EvalContext context)string-length() implementation.protected java.lang.ObjectfunctionSubstring(EvalContext context)substring() implementation.protected java.lang.ObjectfunctionSubstringAfter(EvalContext context)substring-after() implementation.protected java.lang.ObjectfunctionSubstringBefore(EvalContext context)substring-before() implementation.protected java.lang.ObjectfunctionSum(EvalContext context)sum() implementation.protected java.lang.ObjectfunctionTranslate(EvalContext context)translate() implementation.protected java.lang.ObjectfunctionTrue(EvalContext context)true() implementation.ExpressiongetArg1()Convenience method to return the first argument.ExpressiongetArg2()Convenience method to return the second argument.ExpressiongetArg3()Convenience method to return the third argument.intgetArgumentCount()Return the number of argument Expressions.intgetFunctionCode()Get the function code.protected java.lang.StringgetFunctionName()Get the name of this function.java.lang.StringtoString()-
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Operation
getArguments
-
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Expression
isContextDependent, iterate, iteratePointers
-
-
-
-
Constructor Detail
-
CoreFunction
public CoreFunction(int functionCode, Expression[] args)Create a new CoreFunction.- Parameters:
functionCode- int function codeargs- argument Expressions
-
-
Method Detail
-
getFunctionCode
public int getFunctionCode()
Get the function code.- Returns:
- int function code
-
getFunctionName
protected java.lang.String getFunctionName()
Get the name of this function.- Returns:
- String function name
-
getArg1
public Expression getArg1()
Convenience method to return the first argument.- Returns:
- Expression
-
getArg2
public Expression getArg2()
Convenience method to return the second argument.- Returns:
- Expression
-
getArg3
public Expression getArg3()
Convenience method to return the third argument.- Returns:
- Expression
-
getArgumentCount
public int getArgumentCount()
Return the number of argument Expressions.- Returns:
- int count
-
computeContextDependent
public boolean computeContextDependent()
Returns true if any argument is context dependent or if the function is last(), position(), boolean(), local-name(), name(), string(), lang(), number().- Overrides:
computeContextDependentin classOperation- Returns:
- boolean
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compute
public java.lang.Object compute(EvalContext context)
Description copied from class:ExpressionEvaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
computein classExpression- Parameters:
context- evaluation context- Returns:
- Object
-
computeValue
public java.lang.Object computeValue(EvalContext context)
Description copied from class:ExpressionEvaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
computeValuein classExpression- Parameters:
context- evaluation context- Returns:
- Object
-
functionLast
protected java.lang.Object functionLast(EvalContext context)
last() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionPosition
protected java.lang.Object functionPosition(EvalContext context)
position() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionCount
protected java.lang.Object functionCount(EvalContext context)
count() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionLang
protected java.lang.Object functionLang(EvalContext context)
lang() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean
-
functionID
protected java.lang.Object functionID(EvalContext context)
id() implementation.- Parameters:
context- evaluation context- Returns:
- Pointer
-
functionKey
protected java.lang.Object functionKey(EvalContext context)
key() implementation.- Parameters:
context- evaluation context- Returns:
- various Object
-
functionNamespaceURI
protected java.lang.Object functionNamespaceURI(EvalContext context)
namespace-uri() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionLocalName
protected java.lang.Object functionLocalName(EvalContext context)
local-name() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionName
protected java.lang.Object functionName(EvalContext context)
name() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionString
protected java.lang.Object functionString(EvalContext context)
string() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionConcat
protected java.lang.Object functionConcat(EvalContext context)
concat() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionStartsWith
protected java.lang.Object functionStartsWith(EvalContext context)
starts-with() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean
-
functionContains
protected java.lang.Object functionContains(EvalContext context)
contains() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean
-
functionSubstringBefore
protected java.lang.Object functionSubstringBefore(EvalContext context)
substring-before() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionSubstringAfter
protected java.lang.Object functionSubstringAfter(EvalContext context)
substring-after() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionSubstring
protected java.lang.Object functionSubstring(EvalContext context)
substring() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionStringLength
protected java.lang.Object functionStringLength(EvalContext context)
string-length() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionNormalizeSpace
protected java.lang.Object functionNormalizeSpace(EvalContext context)
normalize-space() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionTranslate
protected java.lang.Object functionTranslate(EvalContext context)
translate() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
functionBoolean
protected java.lang.Object functionBoolean(EvalContext context)
boolean() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean
-
functionNot
protected java.lang.Object functionNot(EvalContext context)
not() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean
-
functionTrue
protected java.lang.Object functionTrue(EvalContext context)
true() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean.TRUE
-
functionFalse
protected java.lang.Object functionFalse(EvalContext context)
false() implementation.- Parameters:
context- evaluation context- Returns:
- Boolean.FALSE
-
functionNull
protected java.lang.Object functionNull(EvalContext context)
null() implementation.- Parameters:
context- evaluation context- Returns:
- null
-
functionNumber
protected java.lang.Object functionNumber(EvalContext context)
number() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionSum
protected java.lang.Object functionSum(EvalContext context)
sum() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionFloor
protected java.lang.Object functionFloor(EvalContext context)
floor() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionCeiling
protected java.lang.Object functionCeiling(EvalContext context)
ceiling() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionRound
protected java.lang.Object functionRound(EvalContext context)
round() implementation.- Parameters:
context- evaluation context- Returns:
- Number
-
functionFormatNumber
private java.lang.Object functionFormatNumber(EvalContext context)
format-number() implementation.- Parameters:
context- evaluation context- Returns:
- String
-
assertArgCount
private void assertArgCount(int count)
Assertcountargs.- Parameters:
count- int
-
assertArgRange
private void assertArgRange(int min, int max)Assert at leastmin/at mostmaxargs.- Parameters:
min- intmax- int
-
-