Package net.sf.saxon.trans.rules

## Class Rule

- java.lang.Object
- - net.sf.saxon.trans.rules.Rule

- Direct Known Subclasses:
    `RuleEE`

      public class Rule
      extends java.lang.Object

  Rule: a template rule, or a strip-space rule used to support the implementation

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected RuleTarget` | `action` |
    `protected int` | `minImportPrecedence` |
    `protected Rule` | `next` |
    `protected int` | `part` |
    `protected Pattern` | `pattern` |
    `protected int` | `precedence` |
    `protected double` | `priority` |
    `protected int` | `sequence` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Rule()` |
    `Rule​(Pattern p, RuleTarget o, int prec, int min, double prio, int seq, int part)` | Create a Rule.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `compareComputedRank​(Rule other)` | Rules have an ordering, based on their precedence and priority.
    `int` | `compareRank​(Rule other)` | Rules have an ordering, based on their precedence and priority.
    `Rule` | `copy​(boolean copyChain)` |
    `protected void` | `copyFrom​(Rule r, boolean copyChain)` | Copy a rule, including optionally the chain of rules linked to it
    `void` | `export​(ExpressionPresenter out, boolean modeStreamable)` | Export this rule
    `void` | `exportOtherProperties​(ExpressionPresenter out)` | Add other exported properties as required
    `RuleTarget` | `getAction()` |
    `int` | `getMinImportPrecedence()` |
    `Rule` | `getNext()` |
    `int` | `getPartNumber()` |
    `Pattern` | `getPattern()` |
    `int` | `getPrecedence()` |
    `double` | `getPriority()` |
    `int` | `getRank()` |
    `int` | `getSequence()` |
    `boolean` | `isAlwaysMatches()` |
    `boolean` | `matches​(Item item, XPathContextMajor context)` |
    `void` | `setAction​(RuleTarget action)` |
    `void` | `setAlwaysMatches​(boolean matches)` |
    `void` | `setNext​(Rule next)` |
    `void` | `setPattern​(Pattern pattern)` |
    `void` | `setRank​(int rank)` |

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

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

- - ### Field Detail

    - #### pattern

          protected Pattern pattern

    - #### action

          protected RuleTarget action

    - #### precedence

          protected int precedence

    - #### minImportPrecedence

          protected int minImportPrecedence

    - #### priority

          protected double priority

    - #### next

          protected Rule next

    - #### sequence

          protected int sequence

    - #### part

          protected int part

  - ### Constructor Detail

    - #### Rule

          public Rule()

    - #### Rule

          public Rule​(Pattern p,
                      RuleTarget o,
                      int prec,
                      int min,
                      double prio,
                      int seq,
                      int part)

      Create a Rule.
      Parameters:
        `p` - the pattern that this rule matches
        `o` - the object invoked by this rule (usually a Template)
        `prec` - the precedence of the rule
        `min` - the minumum import precedence for xsl:apply-imports
        `prio` - the priority of the rule
        `seq` - a sequence number for ordering of rules

  - ### Method Detail

    - #### copyFrom

          protected void copyFrom​(Rule r,
                                  boolean copyChain)

      Copy a rule, including optionally the chain of rules linked to it
      Parameters:
        `r` - the rule to be copied
        `copyChain` - true if the whole chain of rules is to be copied

    - #### copy

          public Rule copy​(boolean copyChain)

    - #### getSequence

          public int getSequence()

    - #### getPartNumber

          public int getPartNumber()

    - #### setAction

          public void setAction​(RuleTarget action)

    - #### getAction

          public RuleTarget getAction()

    - #### getNext

          public Rule getNext()

    - #### setNext

          public void setNext​(Rule next)

    - #### getPattern

          public Pattern getPattern()

    - #### setPattern

          public void setPattern​(Pattern pattern)

    - #### getPrecedence

          public int getPrecedence()

    - #### getMinImportPrecedence

          public int getMinImportPrecedence()

    - #### getPriority

          public double getPriority()

    - #### setAlwaysMatches

          public void setAlwaysMatches​(boolean matches)

    - #### isAlwaysMatches

          public boolean isAlwaysMatches()

    - #### setRank

          public void setRank​(int rank)

    - #### getRank

          public int getRank()

    - #### export

          public void export​(ExpressionPresenter out,
                             boolean modeStreamable)
                      throws XPathException

      Export this rule
      Parameters:
        `out` - the destination for the export
        `modeStreamable` - if the mode for this rule is streamable (should be EE only?)
      Throws:
        `XPathException`

    - #### exportOtherProperties

          public void exportOtherProperties​(ExpressionPresenter out)
                                     throws XPathException

      Add other exported properties as required
      Parameters:
        `out` - the export destination
      Throws:
        `XPathException`

    - #### compareRank

          public int compareRank​(Rule other)

      Rules have an ordering, based on their precedence and priority. This method compares them using the precomputed rank value.
      Parameters:
        `other` - Another rule whose ordering rank is to be compared with this one
      Returns:
        <0 if this rule has lower rank, that is if it has lower precedence or equal precedence and lower priority. 0 if the two rules have equal precedence and priority. >0 if this rule has higher rank in precedence/priority order

    - #### compareComputedRank

          public int compareComputedRank​(Rule other)

      Rules have an ordering, based on their precedence and priority.
      Parameters:
        `other` - Another rule whose ordering rank is to be compared with this one
      Returns:
        <0 if this rule has lower rank, that is if it has lower precedence or equal precedence and lower priority. 0 if the two rules have equal precedence and priority. >0 if this rule has higher rank in precedence/priority order

    - #### matches

          public boolean matches​(Item item,
                                 XPathContextMajor context)
                          throws XPathException

      Throws:
        `XPathException`