org.jaxen.function

Class StringFunction

Implemented Interfaces:
Function

public class StringFunction
extends java.lang.Object
implements Function

4.2 string string(object)

The string function converts an object to a string as follows:

  • The boolean false value is converted to the string false. The boolean true value is converted to the string true.

  • An object of a type other than the four basic types is converted to a string in a way that is dependent on that type.

  • If the argument is omitted, it defaults to a node-set with the context node as its only member.

    Author:
    bob mcwhirter (bob @ werken.com)
    See Also:
    Section 4.2 of the XPath Specification

    Field Summary

    private static DecimalFormat
    format

    Constructor Summary

    StringFunction()
    Create a new StringFunction object.

    Method Summary

    Object
    call(Context context, List args)
    Returns the string-value of args.get(0) or of the context node if args is empty.
    static String
    evaluate(Object obj, Navigator nav)
    Returns the XPath string-value of obj.
    private static String
    stringValue(boolean value)
    private static String
    stringValue(double value)

    Field Details

    format

    private static DecimalFormat format

    Constructor Details

    StringFunction

    public StringFunction()
    Create a new StringFunction object.

    Method Details

    call

    public Object call(Context context,
                       List args)
                throws FunctionCallException
    Returns the string-value of args.get(0) or of the context node if args is empty.
    Specified by:
    call in interface Function
    Parameters:
    context - the context at the point in the expression where the function is called
    args - list with zero or one element
    Returns:
    a String
    Throws:
    FunctionCallException - if args has more than one item

    evaluate

    public static String evaluate(Object obj,
                                  Navigator nav)
    Returns the XPath string-value of obj. This operation is only defined if obj is a node, node-set, String, Number, or Boolean. For other types this function returns the empty string.
    Parameters:
    obj - the node, node-set, string, number, or boolean whose string-value is calculated
    nav - the navigator used to calculate the string-value
    Returns:
    a String. May be empty but is never null.

    stringValue

    private static String stringValue(boolean value)

    stringValue

    private static String stringValue(double value)