Class Mode

java.lang.Object
net.sf.saxon.trans.Mode
All Implemented Interfaces:
Serializable

public class Mode extends Object implements Serializable
A Mode is a collection of rules; the selection of a rule to apply to a given element is determined by a Pattern.
Author:
Michael H. Kay
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mode(int usage, int nameCode)
    Default constructor - creates a Mode containing no rules
    Mode(Mode omniMode, int modeNameCode)
    Construct a new Mode, copying the contents of an existing Mode
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRule(Pattern p, Object action, int precedence, double priority)
    Add a rule to the Mode.
    int
    getList(int fingerprint, int type)
    Determine which list to use for a given pattern (we must also search the generic list)
    int
    Get the name of the mode (for diagnostics only)
    getNextMatchRule(NodeInfo node, Rule currentRule, XPathContext context)
    Get the rule corresponding to a given Node, by finding the next-best Pattern match after the specified object.
    getRule(NodeInfo node, int min, int max, XPathContext context)
    Get the rule corresponding to a given Node, by finding the best Pattern match, subject to a minimum and maximum precedence.
    getRule(NodeInfo node, XPathContext context)
    Get the rule corresponding to a given Node, by finding the best Pattern match.
    boolean
    Determine if this is the default mode

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Mode

      public Mode(int usage, int nameCode)
      Default constructor - creates a Mode containing no rules
      Parameters:
      usage - one of DEFAULT_MODE, NAMED_MODE, STRIPPER_MODE
    • Mode

      public Mode(Mode omniMode, int modeNameCode)
      Construct a new Mode, copying the contents of an existing Mode
      Parameters:
      omniMode - the existing mode. May be null, in which case it is not copied
  • Method Details

    • isDefaultMode

      public boolean isDefaultMode()
      Determine if this is the default mode
    • getModeNameCode

      public int getModeNameCode()
      Get the name of the mode (for diagnostics only)
    • addRule

      public void addRule(Pattern p, Object action, int precedence, double priority)
      Add a rule to the Mode.
      Parameters:
      p - a Pattern
      action - the Object to return from getRule() when the supplied node matches this Pattern
      precedence - the import precedence of the rule
      priority - the explicit or implicit priority of the rule
    • getList

      public int getList(int fingerprint, int type)
      Determine which list to use for a given pattern (we must also search the generic list)
    • getRule

      public Rule getRule(NodeInfo node, XPathContext context) throws XPathException
      Get the rule corresponding to a given Node, by finding the best Pattern match.
      Parameters:
      node - the NodeInfo referring to the node to be matched
      Returns:
      the best matching rule, if any (otherwise null).
      Throws:
      XPathException
    • getRule

      public Rule getRule(NodeInfo node, int min, int max, XPathContext context) throws XPathException
      Get the rule corresponding to a given Node, by finding the best Pattern match, subject to a minimum and maximum precedence. (This supports xsl:apply-imports)
      Parameters:
      node - the NodeInfo referring to the node to be matched
      Returns:
      the object (e.g. a NodeHandler) registered for that element, if any (otherwise null).
      Throws:
      XPathException
    • getNextMatchRule

      public Rule getNextMatchRule(NodeInfo node, Rule currentRule, XPathContext context) throws XPathException
      Get the rule corresponding to a given Node, by finding the next-best Pattern match after the specified object.
      Parameters:
      node - the NodeInfo referring to the node to be matched
      Returns:
      the object (e.g. a NodeHandler) registered for that element, if any (otherwise null).
      Throws:
      XPathException