Package net.sf.saxon.functions

## Class Minimax

- java.lang.Object
- - net.sf.saxon.functions.AbstractFunction
  - - net.sf.saxon.functions.SystemFunction
    - - net.sf.saxon.functions.CollatingFunctionFixed
      - - net.sf.saxon.functions.Minimax

- All Implemented Interfaces:
    `Callable`, `StatefulSystemFunction`, `Function`, `GroundedValue`, `Item`, `Sequence`
  Direct Known Subclasses:
    `Minimax.Max`, `Minimax.Min`

      public abstract class Minimax
      extends CollatingFunctionFixed

  This class implements the min() and max() functions, with the collation argument already known.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `Minimax.Max` | Concrete subclass to define the fn:max() function
    `static class` | `Minimax.Min` | Concrete subclass to define the fn:min() function

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Minimax()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ZeroOrOne` | `call​(XPathContext context, Sequence[] arguments)` | Evaluate the function
    `void` | `exportAttributes​(ExpressionPresenter out)` | Export any context attributes held within the SystemFunction object.
    `PlainType` | `getArgumentType()` |
    `AtomicComparer` | `getAtomicComparer​(XPathContext context)` | During evaluation, get the pre-allocated atomic comparer if available, or allocate a new one otherwise
    `int` | `getCardinality​(Expression[] arguments)` | Determine the cardinality of the function.
    `AtomicComparer` | `getComparer()` |
    `ItemType` | `getResultItemType​(Expression[] args)` | Get the return type, given knowledge of the actual arguments
    `java.lang.String` | `getStreamerName()` | 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.
    `void` | `importAttributes​(java.util.Properties attributes)` | Import any attributes found in the export file, that is, any attributes output using the exportAttributes method
    `boolean` | `isIgnoreNaN()` | Test whether NaN values are to be ignored
    `abstract boolean` | `isMaxFunction()` | Method to be implemented in subclasses to indicate whether the function implements fn:min() or fn:max()
    `Expression` | `makeOptimizedFunctionCall​(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, Expression... arguments)` | Allow the function to create an optimized call based on the values of the actual arguments
    `static AtomicValue` | `minimax​(SequenceIterator iter, boolean isMaxFunction, AtomicComparer atomicComparer, boolean ignoreNaN, XPathContext context)` | Static method to evaluate the minimum or maximum of a sequence
    `void` | `setIgnoreNaN​(boolean ignore)` | Indicate whether NaN values should be ignored.
    `void` | `supplyTypeInformation​(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, Expression[] arguments)` | Static analysis: preallocate a comparer if possible

    - ### Methods inherited from class net.sf.saxon.functions.CollatingFunctionFixed

      `copy, getPreAllocatedAtomicComparer, getStringCollator, isSubstringMatchingFunction, preAllocateComparer, setCollationName, setRetainedStaticContext`

    - ### Methods inherited from class net.sf.saxon.functions.SystemFunction

      `dependsOnContextItem, dynamicCall, equals, export, exportAdditionalArguments, fixArguments, getArity, getCompilerName, getContextNode, getDescription, getDetails, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getRetainedStaticContext, getSpecialProperties, getStaticBaseUriString, isTrustedResultType, makeCall, makeFunction, makeFunctionCall, resultIfEmpty, setArity, setDetails, toShortString, toString, typeCheckCaller`

    - ### Methods inherited from class net.sf.saxon.functions.AbstractFunction

      `atomize, deepEquals, effectiveBooleanValue, getAnnotations, getStringValue, getStringValueCS, isArray, isMap, makeNewContext, simplify, typeCheck`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.om.Function

      `getGenre`

    - ### Methods inherited from interface net.sf.saxon.om.GroundedValue

      `asIterable, concatenate, containsNode, materialize`

    - ### Methods inherited from interface net.sf.saxon.om.Item

      `getLength, head, isStreamed, itemAt, iterate, reduce, subsequence`

    - ### Methods inherited from interface net.sf.saxon.om.Sequence

      `makeRepeatable`

- - ### 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

    - #### getComparer

          public AtomicComparer getComparer()

    - #### 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.