net.sf.saxon.trans

Class Mode

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

Nested Class Summary
static classMode.Rule
Inner class Rule used to support the implementation
Field Summary
static intALL_MODES
static intDEFAULT_MODE
static intNAMED_MODE
static intSTRIPPER_MODE
Constructor Summary
Mode(int usage)
Default constructor - creates a Mode containing no rules
Mode(Mode omniMode)
Construct a new Mode, copying the contents of an existing Mode
Method Summary
voidaddRule(Pattern p, Object obj, int precedence, double priority)
Add a rule to the Mode.
intgetList(int fingerprint, int type)
Determine which list to use for a given pattern (we must also search the generic list)
ObjectgetNextMatchRule(NodeInfo node, Object currentHandler, XPathContext context)
Get the rule corresponding to a given Node, by finding the next-best Pattern match after the specified object.
ObjectgetRule(NodeInfo node, XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match.
ObjectgetRule(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.
booleanisDefaultMode()
Determine if this is the default mode

Field Detail

ALL_MODES

public static final int ALL_MODES

DEFAULT_MODE

public static final int DEFAULT_MODE

NAMED_MODE

public static final int NAMED_MODE

STRIPPER_MODE

public static final int STRIPPER_MODE

Constructor Detail

Mode

public Mode(int usage)
Default constructor - creates a Mode containing no rules

Parameters: usage one of DEFAULT_MODE, NAMED_MODE, STRIPPER_MODE

Mode

public Mode(Mode omniMode)
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 Detail

addRule

public void addRule(Pattern p, Object obj, int precedence, double priority)
Add a rule to the Mode.
The rule effectively replaces any other rule for the same pattern/mode at the same or a lower priority.

Parameters: p a Pattern obj 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)

getNextMatchRule

public Object getNextMatchRule(NodeInfo node, Object currentHandler, XPathContext context)
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).

getRule

public Object getRule(NodeInfo node, XPathContext context)
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 object (e.g. a NodeHandler) registered for that element, if any (otherwise null).

getRule

public 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. (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).

isDefaultMode

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