net.sf.saxon.pattern

Class UnionPattern

public class UnionPattern extends Pattern

A pattern formed as the union (or) of two other patterns
Field Summary
protected Patternp1
protected Patternp2
Constructor Summary
UnionPattern(Pattern p1, Pattern p2)
Constructor
Method Summary
Patternanalyze(StaticContext env, ItemType contextItemType)
Type-check the pattern.
PatterngetLHS()
Get the LHS of the union
intgetNodeKind()
Determine the types of nodes to which this pattern applies.
NodeTestgetNodeTest()
Get a NodeTest that all the nodes matching this pattern must satisfy
PatterngetRHS()
Get the RHS of the union
booleanmatches(NodeInfo e, XPathContext context)
Determine if the supplied node matches the pattern
voidsetLineNumber(int lineNumber)
Override method to set the system ID, so it's set on both halves
voidsetOriginalText(String pattern)
Set the original text
voidsetSystemId(String systemId)
Override method to set the system ID, so it's set on both halves
Patternsimplify(StaticContext env)
Simplify the pattern: perform any context-independent optimisations

Field Detail

p1

protected Pattern p1

p2

protected Pattern p2

Constructor Detail

UnionPattern

public UnionPattern(Pattern p1, Pattern p2)
Constructor

Parameters: p1 the left-hand operand p2 the right-hand operand

Method Detail

analyze

public Pattern analyze(StaticContext env, ItemType contextItemType)
Type-check the pattern. This is only needed for patterns that contain variable references or function calls.

Returns: the optimised Pattern

getLHS

public Pattern getLHS()
Get the LHS of the union

getNodeKind

public int getNodeKind()
Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Node.NODE

Returns: the type of node matched by this pattern. e.g. Node.ELEMENT or Node.TEXT

getNodeTest

public NodeTest getNodeTest()
Get a NodeTest that all the nodes matching this pattern must satisfy

getRHS

public Pattern getRHS()
Get the RHS of the union

matches

public boolean matches(NodeInfo e, XPathContext context)
Determine if the supplied node matches the pattern

Parameters: e the node to be compared

Returns: true if the node matches either of the operand patterns

setLineNumber

public void setLineNumber(int lineNumber)
Override method to set the system ID, so it's set on both halves

setOriginalText

public void setOriginalText(String pattern)
Set the original text

setSystemId

public void setSystemId(String systemId)
Override method to set the system ID, so it's set on both halves

simplify

public Pattern simplify(StaticContext env)
Simplify the pattern: perform any context-independent optimisations