Package org.jaxen.function
Class StringLengthFunction
- java.lang.Object
-
- org.jaxen.function.StringLengthFunction
-
- All Implemented Interfaces:
Function
public class StringLengthFunction extends java.lang.Object implements Function
4.2
number string-length(string)The string-length function returns the number of Unicode characters in its argument. This is not necessarily the same as the number Java chars in the corresponding Java string. In particular, if the Java
Stringcontains surrogate pairs each such pair will be counted as only one character by this function. If the argument is omitted, it returns the length of the string-value of the context node.- Author:
- bob mcwhirter (bob @ werken.com)
- See Also:
- Section 4.2 of the XPath Specification
-
-
Constructor Summary
Constructors Constructor Description StringLengthFunction()Create a newStringLengthFunctionobject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcall(Context context, java.util.List args)Returns the number of Unicode characters in the string-value of the argument.static java.lang.Doubleevaluate(java.lang.Object obj, Navigator nav)Returns the number of Unicode characters in the string-value of an object.
-
-
-
Method Detail
-
call
public java.lang.Object call(Context context, java.util.List args) throws FunctionCallException
Returns the number of Unicode characters in the string-value of the argument.
- Specified by:
callin interfaceFunction- Parameters:
context- the context at the point in the expression when the function is calledargs- a list containing the item whose string-value is to be counted. If empty, the length of the context node's string-value is returned.- Returns:
- a
Doublegiving the number of Unicode characters - Throws:
FunctionCallException- if args has more than one item
-
evaluate
public static java.lang.Double evaluate(java.lang.Object obj, Navigator nav) throws FunctionCallExceptionReturns the number of Unicode characters in the string-value of an object.
- Parameters:
obj- the object whose string-value is countednav- used to calculate the string-values of the first two arguments- Returns:
- a
Doublegiving the number of Unicode characters - Throws:
FunctionCallException- if the string contains mismatched surrogates
-
-