public class StringLengthFunction extends 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 String
contains 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.
Constructor and Description |
---|
StringLengthFunction()
Create a new
StringLengthFunction object. |
Modifier and Type | Method and Description |
---|---|
Object |
call(Context context,
List args)
Returns the number of Unicode characters in the string-value of the argument.
|
static Double |
evaluate(Object obj,
Navigator nav)
Returns the number of Unicode characters in the string-value of
an object.
|
public StringLengthFunction()
StringLengthFunction
object.public Object call(Context context, List args) throws FunctionCallException
Returns the number of Unicode characters in the string-value of the argument.
call
in interface Function
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.Double
giving the number of Unicode charactersFunctionCallException
- if args has more than one itempublic static Double evaluate(Object obj, Navigator nav) throws FunctionCallException
Returns the number of Unicode characters in the string-value of an object.
obj
- the object whose string-value is countednav
- used to calculate the string-values of the first two argumentsDouble
giving the number of Unicode charactersFunctionCallException
- if the string contains mismatched surrogatesCopyright 2001–2022 The Jaxen Project. All rights reserved.