Package net.sf.saxon.pattern
Class CombinedNodeTest
java.lang.Object
net.sf.saxon.pattern.CombinedNodeTest
- All Implemented Interfaces:
NodePredicate,NodeTest
A CombinedNodeTest combines two node tests using one of the operators
union (=or), intersect (=and), difference (= "and not"). This arises
when optimizing a union (etc) of two path expressions using the same axis.
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedNodeTest(NodeTest nt1, OperatorSymbol operator, NodeTest nt2) Create a NodeTest that combines two other node tests -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the "parameters" of the type to a dictionary containing the type information in structured formasXNodeTest(Configuration config) Get an XNodeTest that will match any XNode that this NodeTest matches: that is, eliminate the possibility of matching a JNode.booleanIndicates whether some other object is "equal to" this one.explainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.export()Return a string representation of this ItemType suitable for use in stylesheet export files.NodeTest[]Get the two parts of the combined node testdoubleGet the default priority of this nodeTest when used as a pattern.Get an item type that all matching nodes must satisfygetOperand(int which) Get the operator used to combine the two node tests: one ofToken.VBAR,OperatorSymbol.INTERSECT,OperatorSymbol.EXCEPT,Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTestgetUType()Get the correspondingUType.inthashCode()Returns a hash code value for the object.booleanDetermine whether the content type (if present) is nillablebooleanTest whether this node test is satisfied by a given node.Get a concise string representation of this node test for use in diagnosticstoString()
-
Constructor Details
-
CombinedNodeTest
Create a NodeTest that combines two other node tests- Parameters:
nt1- the first operand. Note that if the defaultPriority of the pattern is required, it will be taken from that of the first operand.operator- one of Token.UNION, Token.INTERSECT, Token.EXCEPTnt2- the second operand
-
-
Method Details
-
getUType
Get the correspondingUType. A UType is a union of primitive item types. -
asXNodeTest
Description copied from interface:NodeTestGet an XNodeTest that will match any XNode that this NodeTest matches: that is, eliminate the possibility of matching a JNode.- Specified by:
asXNodeTestin interfaceNodeTest
-
test
Test whether this node test is satisfied by a given node. This alternative method is used in the case of nodes where calculating the fingerprint is expensive, for example DOM or JDOM nodes.- Specified by:
testin interfaceNodePredicate- Specified by:
testin interfaceNodeTest- Parameters:
node- the node to be matched- Returns:
- true if the node test is satisfied by the supplied node, false otherwise
-
toString
-
export
Return a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of callingtoString(). -
addTypeDetails
Add the "parameters" of the type to a dictionary containing the type information in structured form -
getQNameTest
Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTest- Specified by:
getQNameTestin interfaceNodeTest- Returns:
- the strongest possible QNameTest
-
getItemType
Get an item type that all matching nodes must satisfy- Specified by:
getItemTypein interfaceNodeTest- Returns:
- an item type
-
toShortString
Get a concise string representation of this node test for use in diagnostics- Specified by:
toShortStringin interfaceNodeTest- Returns:
- a suitably abbreviated represention of the node test
-
isNillable
public boolean isNillable()Determine whether the content type (if present) is nillable- Specified by:
isNillablein interfaceNodeTest- Returns:
- true if the content test (when present) can match nodes that are nilled
-
hashCode
public int hashCode()Returns a hash code value for the object. -
equals
Indicates whether some other object is "equal to" this one. -
getDefaultPriority
public double getDefaultPriority()Get the default priority of this nodeTest when used as a pattern. In the case of a union, this will always be (arbitrarily) the default priority of the first operand. In other cases, again somewhat arbitrarily, it is 0.25, reflecting the common usage of an intersection to represent the pattern element(E, T).- Specified by:
getDefaultPriorityin interfaceNodeTest- Returns:
- the default priority for the pattern
-
getComponentNodeTests
Get the two parts of the combined node test- Returns:
- the two operands
-
getOperator
Get the operator used to combine the two node tests: one ofToken.VBAR,OperatorSymbol.INTERSECT,OperatorSymbol.EXCEPT,- Returns:
- the operator
-
getOperand
-
explainMismatch
Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Specified by:
explainMismatchin interfaceNodeTest- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-