Top Description Fields Constructors Methods
org.dom4j.rule

public Class Rule

extends Object
implements Comparable<Rule>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
org.dom4j.Node

Rule matches against DOM4J Node so that some action can be performed such as in the XSLT processing model.

Author
James Strachan
Version
$Revision: 1.7 $

Field Summary

Modifier and TypeField and Description
private Action
action

Holds value of property action.

private int
appearenceCount

Holds value of property appearenceCount.

private int
importPrecedence

Holds value of property importPrecedence.

private String
mode

Holds value of property mode.

private Pattern
pattern

Holds value of property pattern.

private double
priority

Holds value of property priority.

Constructor Summary

AccessConstructor and Description
public
Rule()

public
Rule(Pattern pattern)

public
Rule(Pattern pattern, Action action)

public
Rule(Rule
DOCUMENT ME!
that
,
Pattern
DOCUMENT ME!
pattern
)

Constructs a new Rule with the same instance data as the given rule but a different pattern.

Method Summary

Modifier and TypeMethod and Description
private static int
compareInt(int value1, int value2)

public int

Returns:

DOCUMENT ME!
compareTo
(Rule
DOCUMENT ME!
that
)

Implements java.lang.Comparable.compareTo.

Compares two rules in XSLT processing model order assuming that the modes are equal.
public boolean
equals(Object
the reference object with which to compare.
that
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Action

Returns:

Value of property action.
getAction
()

Getter for property action.

public int

Returns:

Value of property appearenceCount.
getAppearenceCount
()

Getter for property appearenceCount.

public int

Returns:

Value of property importPrecedence.
getImportPrecedence
()

Getter for property importPrecedence.

public final String

Returns:

the name of the element or attribute this pattern matches or null if this pattern matches any or more than one name.
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.

public final short

Returns:

the type of node the pattern matches which by default should return ANY_NODE if it can match any kind of node.
getMatchType
()

DOCUMENT ME!

public String

Returns:

Value of property mode.
getMode
()

Getter for property mode.

public Pattern

Returns:

Value of property pattern.
getPattern
()

Getter for property pattern.

public double

Returns:

Value of property priority.
getPriority
()

Getter for property priority.

public Rule[]

Returns:

an array of the rules which make up this union rule or null if this rule is not a union rule
getUnionRules
()

If this rule contains a union pattern then this method should return an array of Rules which describe the union rule, which should contain more than one rule.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public final boolean

Returns:

true if the pattern matches the given DOM4J node.
matches
(Node
DOCUMENT ME!
node
)

DOCUMENT ME!

public void
setAction(Action
New value of property action.
action
)

Setter for property action.

public void
setAppearenceCount(int
New value of property appearenceCount.
appearenceCount
)

Setter for property appearenceCount.

public void
setImportPrecedence(int
New value of property importPrecedence.
importPrecedence
)

Setter for property importPrecedence.

public void
setMode(String
New value of property mode.
mode
)

Setter for property mode.

public void
setPattern(Pattern
New value of property pattern.
pattern
)

Setter for property pattern.

public void
setPriority(double
New value of property priority.
priority
)

Setter for property priority.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

actionback to summary
private Action action

Holds value of property action.

appearenceCountback to summary
private int appearenceCount

Holds value of property appearenceCount.

importPrecedenceback to summary
private int importPrecedence

Holds value of property importPrecedence.

modeback to summary
private String mode

Holds value of property mode.

patternback to summary
private Pattern pattern

Holds value of property pattern.

priorityback to summary
private double priority

Holds value of property priority.

Constructor Detail

Ruleback to summary
public Rule()
Ruleback to summary
public Rule(Pattern pattern)
Ruleback to summary
public Rule(Pattern pattern, Action action)
Ruleback to summary
public Rule(Rule that, Pattern pattern)

Constructs a new Rule with the same instance data as the given rule but a different pattern.

Parameters
that:Rule

DOCUMENT ME!

pattern:Pattern

DOCUMENT ME!

Method Detail

compareIntback to summary
private static int compareInt(int value1, int value2)
compareToback to summary
public int compareTo(Rule that)

Implements java.lang.Comparable.compareTo.

Compares two rules in XSLT processing model order assuming that the modes are equal.

Parameters
that:Rule

DOCUMENT ME!

Returns:int

DOCUMENT ME!

equalsback to summary
public boolean equals(Object that)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
that:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getActionback to summary
public Action getAction()

Getter for property action.

Returns:Action

Value of property action.

getAppearenceCountback to summary
public int getAppearenceCount()

Getter for property appearenceCount.

Returns:int

Value of property appearenceCount.

getImportPrecedenceback to summary
public int getImportPrecedence()

Getter for property importPrecedence.

Returns:int

Value of property importPrecedence.

getMatchesNodeNameback to summary
public final 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:String

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

getMatchTypeback to summary
public final short getMatchType()

DOCUMENT ME!

Returns:short

the type of node the pattern matches which by default should return ANY_NODE if it can match any kind of node.

getModeback to summary
public String getMode()

Getter for property mode.

Returns:String

Value of property mode.

getPatternback to summary
public Pattern getPattern()

Getter for property pattern.

Returns:Pattern

Value of property pattern.

getPriorityback to summary
public double getPriority()

Getter for property priority.

Returns:double

Value of property priority.

getUnionRulesback to summary
public Rule[] getUnionRules()

If this rule contains a union pattern then this method should return an array of Rules which describe the union rule, which should contain more than one rule. Otherwise this method should return null.

Returns:Rule[]

an array of the rules which make up this union rule or null if this rule is not a union rule

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

matchesback to summary
public final boolean matches(Node node)

DOCUMENT ME!

Parameters
node:Node

DOCUMENT ME!

Returns:boolean

true if the pattern matches the given DOM4J node.

setActionback to summary
public void setAction(Action action)

Setter for property action.

Parameters
action:Action

New value of property action.

setAppearenceCountback to summary
public void setAppearenceCount(int appearenceCount)

Setter for property appearenceCount.

Parameters
appearenceCount:int

New value of property appearenceCount.

setImportPrecedenceback to summary
public void setImportPrecedence(int importPrecedence)

Setter for property importPrecedence.

Parameters
importPrecedence:int

New value of property importPrecedence.

setModeback to summary
public void setMode(String mode)

Setter for property mode.

Parameters
mode:String

New value of property mode.

setPatternback to summary
public void setPattern(Pattern pattern)

Setter for property pattern.

Parameters
pattern:Pattern

New value of property pattern.

setPriorityback to summary
public void setPriority(double priority)

Setter for property priority.

Parameters
priority:double

New value of property priority.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.