public class Mode
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static StructuredQName |
ALL_MODES |
static int |
DEFAULT_MODE |
static StructuredQName |
DEFAULT_MODE_NAME |
static int |
NAMED_MODE |
static int |
STRIPPER_MODE |
Constructor and Description |
---|
Mode(int usage,
StructuredQName modeName)
Default constructor - creates a Mode containing no rules
|
Mode(Mode omniMode,
StructuredQName modeName)
Construct a new Mode, copying the contents of an existing Mode
|
Modifier and Type | Method and Description |
---|---|
void |
addRule(Pattern p,
java.lang.Object action,
int precedence,
double priority,
boolean explicitMode)
Add a rule to the Mode.
|
void |
explainTemplateRules(ExpressionPresenter presenter)
Explain all template rules in this mode by showing their
expression tree represented in XML.
|
int |
getList(int fingerprint,
int kind)
Determine which list to use for a given pattern (we must also search the generic list)
|
StructuredQName |
getModeName()
Get the name of the mode (for diagnostics only)
|
Rule |
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.
|
Rule |
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.
|
Rule |
getRule(NodeInfo node,
XPathContext context)
Get the rule corresponding to a given Node, by finding the best Pattern match.
|
boolean |
isDefaultMode()
Determine if this is the default mode
|
boolean |
isEmpty()
Ask whether there are any template rules in this mode
(a mode could exist merely because it is referenced in apply-templates)
|
public static final int DEFAULT_MODE
public static final int NAMED_MODE
public static final int STRIPPER_MODE
public static final StructuredQName ALL_MODES
public static final StructuredQName DEFAULT_MODE_NAME
public Mode(int usage, StructuredQName modeName)
usage
- one of DEFAULT_MODE
, NAMED_MODE
, STRIPPER_MODE
modeName
- the name of the modepublic Mode(Mode omniMode, StructuredQName modeName)
omniMode
- the existing mode. May be null, in which case it is not copiedmodeName
- the name of the new mode to be createdpublic boolean isDefaultMode()
public StructuredQName getModeName()
public boolean isEmpty()
public void addRule(Pattern p, java.lang.Object action, int precedence, double priority, boolean explicitMode)
p
- a Patternaction
- the Object to return from getRule() when the supplied node matches this Patternprecedence
- the import precedence of the rulepriority
- the explicit or implicit priority of the ruleexplicitMode
- true if adding a template rule for a specific (default or named) mode;
false if adding a rule because it applies to all modespublic int getList(int fingerprint, int kind)
fingerprint
- the name of the node being matchedkind
- the node kind of the node being matchedpublic Rule getRule(NodeInfo node, XPathContext context) throws XPathException
node
- the NodeInfo referring to the node to be matchedcontext
- the XPath dynamic evaluation contextXPathException
public Rule getRule(NodeInfo node, int min, int max, XPathContext context) throws XPathException
node
- the NodeInfo referring to the node to be matchedmin
- the minimum import precedencemax
- the maximum import precedencecontext
- the XPath dynamic evaluation contextXPathException
public Rule getNextMatchRule(NodeInfo node, Rule currentRule, XPathContext context) throws XPathException
node
- the NodeInfo referring to the node to be matchedcurrentRule
- the current rule; we are looking for the next match after the current rulecontext
- the XPath dynamic evaluation contextXPathException
public void explainTemplateRules(ExpressionPresenter presenter)
presenter
- used to display the expression tree