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
      • getCompilerName

        public java.lang.String getCompilerName()
        Description copied from class: SystemFunction
        Get the (local) name of a class that can be used to generate bytecode for this system function
        Overrides:
        getCompilerName in class SystemFunction
        Returns:
        the name of a bytecode generation class, or null if there is no bytecode support for this function
      • 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.