Class StringRightFunction

  • All Implemented Interfaces:
    FunctionIfc

    @FunctionParameter(name="string") @FunctionParameter(name="length")
    public class StringRightFunction
    extends AbstractFunction
    Represents a function that extracts a substring from the right side of a given string. This class extends the AbstractFunction and implements the logic for the `RIGHT` string function, which returns a specified number of characters from the end (right) of the input string.

    Two parameters are required for this function:

    • string - The input string from which the substring will be extracted.
    • length - The number of characters to extract from the right side of the string. If the specified length is greater than the string's length, the entire string is returned. If the length is negative or zero, an empty string is returned.

    Example usage: If the input string is "hello" and the length is 2, the result will be "lo".

    • Constructor Detail

      • StringRightFunction

        public StringRightFunction()
    • Method Detail

      • evaluate

        public EvaluationValue evaluate​(Expression expression,
                                        Token functionToken,
                                        EvaluationValue... parameterValues)
        Evaluates the `RIGHT` string function by extracting a substring from the right side of the given string.
        Parameters:
        expression - the current expression being evaluated
        functionToken - the token representing the function being called
        parameterValues - the parameters passed to the function; expects exactly two parameters: a string and a numeric value for length
        Returns:
        the substring extracted from the right side of the input string as an EvaluationValue