Class Translate

    • Constructor Detail

      • Translate

        public Translate()
    • Method Detail

      • fixArguments

        public Expression fixArguments​(Expression... arguments)
        Allow the function to create an optimized call based on the values of the actual arguments
        Overrides:
        fixArguments in class SystemFunction
        Parameters:
        arguments - the supplied arguments to the function call
        Returns:
        either a function call on this function, or an expression that delivers the same result, or null indicating that no optimization has taken place
      • getStaticMap

        public IntToIntMap getStaticMap()
        Get the translation map built at compile time if there is one
        Returns:
        the map built at compile time, or null if not available
      • translate

        public static StringValue translate​(StringValue sv0,
                                            StringValue sv1,
                                            StringValue sv2)
        Perform the translate function
        Parameters:
        sv0 - the string to be translated
        sv1 - the characters to be substituted
        sv2 - the replacement characters
        Returns:
        the converted string
      • translateUsingMap

        public static StringValue translateUsingMap​(StringValue in,
                                                    IntToIntMap map)
        Implement the translate() function using an index built at compile time
        Parameters:
        in - the string to be translated
        map - index built at compile time, mapping input characters to output characters. The map returns -1 for a character that is to be deleted from the input string, Integer.MAX_VALUE for a character that is to remain intact
        Returns:
        the translated character string
      • call

        public StringValue call​(XPathContext context,
                                Sequence[] arguments)
                         throws XPathException
        Evaluate the expression
        Specified by:
        call in interface Callable
        Parameters:
        context - the dynamic evaluation context
        arguments - the values of the arguments, supplied as Sequences
        Returns:
        the result of the evaluation, in the form of a Sequence
        Throws:
        XPathException - if a dynamic error occurs during the evaluation of the expression
      • copy

        public Translate copy()
        Make a copy of this SystemFunction. This is required only for system functions such as regex functions that maintain state on behalf of a particular caller.
        Specified by:
        copy in interface StatefulSystemFunction
        Returns:
        a copy of the system function able to contain its own copy of the state on behalf of the caller.
      • getElaborator

        public Elaborator getElaborator()
        Make an elaborator for a system function call on this function
        Overrides:
        getElaborator in class SystemFunction
        Returns:
        a suitable elaborator; or null if no custom elaborator is available