org.jaxen.pattern

Class Pattern

public abstract class Pattern extends Object

Pattern defines the behaviour for pattern in the XSLT processing model.

Version: $Revision: 1.13 $

Author: James Strachan

Field Summary
static shortANY_NODE
Matches any node
static shortATTRIBUTE_NODE
Matches attribute nodes
static shortCDATA_SECTION_NODE
Matches CDATA section nodes
static shortCOMMENT_NODE
Matches comment nodes
static shortDOCUMENT_NODE
Matches document nodes
static shortDOCUMENT_TYPE_NODE
Matches DocumentType nodes
static shortELEMENT_NODE
Matches Element nodes
static shortENTITY_REFERENCE_NODE
Matches entity reference nodes
static shortMAX_NODE_TYPE
The maximum number of node types for sizing purposes
static shortNAMESPACE_NODE
Matches a Namespace Node
static shortNO_NODE
Matches no nodes
static shortPROCESSING_INSTRUCTION_NODE
Matches ProcessingInstruction
static shortTEXT_NODE
Matches text nodes
static shortUNKNOWN_NODE
Does not match any valid node
Method Summary
StringgetMatchesNodeName()
For patterns which only match an ATTRIBUTE_NODE or an ELEMENT_NODE then this pattern may return the name of the element or attribute it matches.
shortgetMatchType()
Returns the type of node the pattern matches.
doublegetPriority()
Returns the default resolution policy of the pattern according to the XSLT conflict resolution rules.
abstract StringgetText()
Returns a textual representation of this pattern
Pattern[]getUnionPatterns()
If this pattern is a union pattern then this method should return an array of patterns which describe the union pattern, which should contain more than one pattern.
abstract booleanmatches(Object node, Context context)
Patternsimplify()

Field Detail

ANY_NODE

public static final short ANY_NODE
Matches any node

ATTRIBUTE_NODE

public static final short ATTRIBUTE_NODE
Matches attribute nodes

CDATA_SECTION_NODE

public static final short CDATA_SECTION_NODE
Matches CDATA section nodes

COMMENT_NODE

public static final short COMMENT_NODE
Matches comment nodes

DOCUMENT_NODE

public static final short DOCUMENT_NODE
Matches document nodes

DOCUMENT_TYPE_NODE

public static final short DOCUMENT_TYPE_NODE
Matches DocumentType nodes

ELEMENT_NODE

public static final short ELEMENT_NODE
Matches Element nodes

ENTITY_REFERENCE_NODE

public static final short ENTITY_REFERENCE_NODE
Matches entity reference nodes

MAX_NODE_TYPE

public static final short MAX_NODE_TYPE
The maximum number of node types for sizing purposes

NAMESPACE_NODE

public static final short NAMESPACE_NODE
Matches a Namespace Node

NO_NODE

public static final short NO_NODE
Matches no nodes

PROCESSING_INSTRUCTION_NODE

public static final short PROCESSING_INSTRUCTION_NODE
Matches ProcessingInstruction

TEXT_NODE

public static final short TEXT_NODE
Matches text nodes

UNKNOWN_NODE

public static final short UNKNOWN_NODE
Does not match any valid node

Method Detail

getMatchesNodeName

public String getMatchesNodeName()
For patterns which only match an ATTRIBUTE_NODE or an ELEMENT_NODE then this pattern may return the name of the element or attribute it matches. This allows a more efficient rule matching algorithm to be performed, rather than a brute force approach of evaluating every pattern for a given Node.

Returns: the name of the element or attribute this pattern matches or null if this pattern matches any or more than one name

getMatchType

public short getMatchType()
Returns the type of node the pattern matches.

Returns: ANY_NODE unless overridden

getPriority

public double getPriority()
Returns the default resolution policy of the pattern according to the XSLT conflict resolution rules.

Returns: 0.5; the default priority defined in XSLT

See Also: Section 5.5 of the XSLT specification

getText

public abstract String getText()
Returns a textual representation of this pattern

Returns: the usual string form of this XSLT pattern

getUnionPatterns

public Pattern[] getUnionPatterns()
If this pattern is a union pattern then this method should return an array of patterns which describe the union pattern, which should contain more than one pattern. Otherwise this method should return null.

Returns: an array of the patterns which make up this union pattern or null if this pattern is not a union pattern

matches

public abstract boolean matches(Object node, Context context)

Parameters: node ???? context ????

Returns: true if the pattern matches the given node

Throws: JaxenException if ????

simplify

public Pattern simplify()