Class Minimax

    • Constructor Detail

      • Minimax

        public Minimax()
    • Method Detail

      • isMaxFunction

        public abstract boolean isMaxFunction()
        Method to be implemented in subclasses to indicate whether the function implements fn:min() or fn:max()
        Returns:
        true if this is the fn:max() function
      • setIgnoreNaN

        public void setIgnoreNaN​(boolean ignore)
        Indicate whether NaN values should be ignored. For the external min() and max() function, a NaN value in the input causes the result to be NaN. Internally, however, min() and max() are also used in such a way that NaN values should be ignored. This is the case for internally-generated min() and max() functions used to support general comparisons.
        Parameters:
        ignore - true if NaN values are to be ignored when computing the min or max.
      • isIgnoreNaN

        public boolean isIgnoreNaN()
        Test whether NaN values are to be ignored
        Returns:
        true if NaN values are to be ignored. This is the case for internally-generated min() and max() functions used to support general comparisons
      • getArgumentType

        public PlainType getArgumentType()
      • supplyTypeInformation

        public void supplyTypeInformation​(ExpressionVisitor visitor,
                                          ContextItemStaticInfo contextItemType,
                                          Expression[] arguments)
        Static analysis: preallocate a comparer if possible
        Overrides:
        supplyTypeInformation in class SystemFunction
        Parameters:
        visitor - an expression visitor, providing access to the static context and configuration
        contextItemType - information about whether the context item is set, and what its type is
        arguments - the expressions appearing as arguments in the function call
      • getResultItemType

        public ItemType getResultItemType​(Expression[] args)
        Description copied from class: SystemFunction
        Get the return type, given knowledge of the actual arguments
        Overrides:
        getResultItemType in class SystemFunction
        Parameters:
        args - the actual arguments supplied
        Returns:
        the best available item type that the function will return
      • getCardinality

        public int getCardinality​(Expression[] arguments)
        Determine the cardinality of the function.
        Overrides:
        getCardinality in class SystemFunction
        Parameters:
        arguments - the actual arguments supplied
        Returns:
        the most precise available cardinality that the function will return
      • makeOptimizedFunctionCall

        public Expression makeOptimizedFunctionCall​(ExpressionVisitor visitor,
                                                    ContextItemStaticInfo contextInfo,
                                                    Expression... arguments)
                                             throws XPathException
        Description copied from class: SystemFunction
        Allow the function to create an optimized call based on the values of the actual arguments
        Overrides:
        makeOptimizedFunctionCall in class SystemFunction
        Parameters:
        visitor - the expression visitor
        contextInfo - information about the context item
        arguments - the supplied arguments to the function call. Note: modifying the contents of this array should not be attempted, it is likely to have no effect.
        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
        Throws:
        XPathException - if an error is detected
      • getAtomicComparer

        public AtomicComparer getAtomicComparer​(XPathContext context)
        Description copied from class: CollatingFunctionFixed
        During evaluation, get the pre-allocated atomic comparer if available, or allocate a new one otherwise
        Overrides:
        getAtomicComparer in class CollatingFunctionFixed
        Parameters:
        context - the dynamic evaluation context
        Returns:
        the pre-allocated comparer if one is available; otherwise, a newly allocated one, using the specified StringCollator for comparing strings
      • minimax

        public static AtomicValue minimax​(SequenceIterator iter,
                                          boolean isMaxFunction,
                                          AtomicComparer atomicComparer,
                                          boolean ignoreNaN,
                                          XPathContext context)
                                   throws XPathException
        Static method to evaluate the minimum or maximum of a sequence
        Parameters:
        iter - Iterator over the input sequence
        isMaxFunction - true for the max() function, false for min()
        atomicComparer - an AtomicComparer used to compare values
        ignoreNaN - true if NaN values are to be ignored
        context - dynamic evaluation context
        Returns:
        the min or max value in the sequence, according to the rules of the fn:min() or fn:max() functions
        Throws:
        XPathException - typically if non-comparable values are found in the sequence
      • call

        public ZeroOrOne call​(XPathContext context,
                              Sequence[] arguments)
                       throws XPathException
        Evaluate the function
        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
      • exportAttributes

        public void exportAttributes​(ExpressionPresenter out)
        Description copied from class: SystemFunction
        Export any context attributes held within the SystemFunction object. The implementation will normally make one or more calls on out.emitAttribute(name, value).
        Overrides:
        exportAttributes in class CollatingFunctionFixed
        Parameters:
        out - the export destination
      • importAttributes

        public void importAttributes​(java.util.Properties attributes)
                              throws XPathException
        Description copied from class: SystemFunction
        Import any attributes found in the export file, that is, any attributes output using the exportAttributes method
        Overrides:
        importAttributes in class CollatingFunctionFixed
        Parameters:
        attributes - the attributes, as a properties object
        Throws:
        XPathException
      • getStreamerName

        public java.lang.String getStreamerName()
        Description copied from class: SystemFunction
        Get a name that identifies the class that can be used to evaluate this function in streaming mode, that is, supplying one item or event at a time as it is delivered by the parser. Special streaming support is generally available in Saxon-EE for all system functions that take a sequence as their argument.
        Overrides:
        getStreamerName in class SystemFunction
        Returns:
        a name that identifies a class that supports streamed evaluation of this system function, or null if no such class is available. The mapping of names to classes is defined in the Saxon-EE class StreamerMap. In non-streaming Saxon editions (HE and PE) the method always returns null.