Class Streamability


  • public class Streamability
    extends java.lang.Object
    Supporting class for assessing the streamability of expressions. Among other things, it contains an implementation of the General Streamability Rules.
    • Constructor Detail

      • Streamability

        public Streamability()
    • Method Detail

      • getConsumingOperand

        public static Operand getConsumingOperand​(Expression exp)
        Get the consuming (or potentially consuming) operand of an expression, assuming there is exactly one
        Parameters:
        exp - the expression
        Returns:
        if there are one or more consuming subexpressions, then the first of these; otherwise, null. Also returns null if the posture and sweep have not yet been assessed.
      • rewriteForExpressionAsMappingExpression

        public static Expression rewriteForExpressionAsMappingExpression​(ForExpression forEx)
      • generalStreamabilityRules

        public static PostureAndSweep generalStreamabilityRules​(Expression target,
                                                                java.lang.Iterable<Operand> operands,
                                                                ContextItemStaticInfoEE contextInfo,
                                                                java.util.List<java.lang.String> reasons)
        Implement the general streamability rules; the rules used to determine the posture and sweep of any expression except when more specific rules are defined for that class of expression
        Parameters:
        target - the expression whose streamability is being analyzed (used only for diagnostics)
        operands - the operands of the expression being evaluated
        contextInfo - information about the static context item type and posture
        reasons - (optionally null) an array to which explanations of non-streamability should be appended
        Returns:
        the posture and sweep of the expression
      • isChildlessNodeKind

        public static boolean isChildlessNodeKind​(ItemType type)
        Ask whether an ItemType only allows nodes that cannot have children
        Parameters:
        type - the item type
        Returns:
        true if the item type only allows nodes that cannot have children
      • toStreamingPattern

        public static Pattern toStreamingPattern​(Expression expr,
                                                 Configuration config)
        Convert an expression to a streaming pattern (a pattern used internally to match nodes during push processing of an event stream)
        Parameters:
        expr - the expression to be converted
        config - the Saxon configuration
        Returns:
        the equivalent pattern if conversion succeeds; otherwise null
      • getStreamability

        public static PostureAndSweep getStreamability​(Expression exp,
                                                       ContextItemStaticInfoEE contextInfo,
                                                       java.util.List<java.lang.String> reasons)
        Get the posture and sweep of this expression as defined in the W3C streamability specifications. This provides an assessment of stylesheet code against the W3C criteria for guaranteed streamability, and is implemented to allow these criteria to be tested. It is not the case that all expression that emerge as streamable from this analysis are currently capable of being streamed by Saxon
        Parameters:
        contextInfo - Information about the context item type and posture
        reasons - the caller may supply a list, in which case the implementation may add to this list a message explaining why the construct is not streamable, suitable for inclusion in an
        Returns:
        the posture and sweep of the expression
      • getPostureAndSweepIfKnown

        public static PostureAndSweep getPostureAndSweepIfKnown​(Expression exp)
        Get the posture and sweep of the expression if these have already been computed
        Returns:
        the posture and sweep if known, or null if the streamability has not yet been assessed.
      • computeAccumulatorAfterSweep

        public static Sweep computeAccumulatorAfterSweep​(SystemFunctionCall call,
                                                         ContextItemStaticInfoEE contextInfo,
                                                         java.util.List<java.lang.String> reasons)
        Compute the sweep of a call to accumulator-after (which depends on what else is found in the same sequence constructor
        Parameters:
        call - the call on accumulator-after
        Returns:
        the computed sweep, which is consuming if all previous instructions are motionless, or motionless if a previous instruction is consuming.