Class Rule

  • All Implemented Interfaces:
    java.lang.Comparable<Rule>

    public class Rule
    extends java.lang.Object
    implements java.lang.Comparable<Rule>

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

    Version:
    $Revision: 1.7 $
    • Field Summary

      Fields 
      Modifier and Type Field 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 java.lang.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

      Constructors 
      Constructor Description
      Rule()  
      Rule​(Pattern pattern)  
      Rule​(Pattern pattern, Action action)  
      Rule​(Rule that, Pattern pattern)
      Constructs a new Rule with the same instance data as the given rule but a different pattern.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static int compareInt​(int value1, int value2)  
      int compareTo​(Rule that)
      Compares two rules in XSLT processing model order assuming that the modes are equal.
      boolean equals​(java.lang.Object that)  
      Action getAction()
      Getter for property action.
      int getAppearenceCount()
      Getter for property appearenceCount.
      int getImportPrecedence()
      Getter for property importPrecedence.
      java.lang.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.
      short getMatchType()
      DOCUMENT ME!
      java.lang.String getMode()
      Getter for property mode.
      Pattern getPattern()
      Getter for property pattern.
      double getPriority()
      Getter for property priority.
      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.
      int hashCode()  
      boolean matches​(Node node)
      DOCUMENT ME!
      void setAction​(Action action)
      Setter for property action.
      void setAppearenceCount​(int appearenceCount)
      Setter for property appearenceCount.
      void setImportPrecedence​(int importPrecedence)
      Setter for property importPrecedence.
      void setMode​(java.lang.String mode)
      Setter for property mode.
      void setPattern​(Pattern pattern)
      Setter for property pattern.
      void setPriority​(double priority)
      Setter for property priority.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • mode

        private java.lang.String mode
        Holds value of property mode.
      • importPrecedence

        private int importPrecedence
        Holds value of property importPrecedence.
      • priority

        private double priority
        Holds value of property priority.
      • appearenceCount

        private int appearenceCount
        Holds value of property appearenceCount.
      • pattern

        private Pattern pattern
        Holds value of property pattern.
      • action

        private Action action
        Holds value of property action.
    • Constructor Detail

      • Rule

        public Rule()
      • Rule

        public Rule​(Pattern pattern)
      • Rule

        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 - DOCUMENT ME!
        pattern - DOCUMENT ME!
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object that)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(Rule that)
        Compares two rules in XSLT processing model order assuming that the modes are equal.
        Specified by:
        compareTo in interface java.lang.Comparable<Rule>
        Parameters:
        that - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • matches

        public final boolean matches​(Node node)
        DOCUMENT ME!
        Parameters:
        node - DOCUMENT ME!
        Returns:
        true if the pattern matches the given DOM4J node.
      • getUnionRules

        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:
        an array of the rules which make up this union rule or null if this rule is not a union rule
      • getMatchType

        public final short getMatchType()
        DOCUMENT ME!
        Returns:
        the type of node the pattern matches which by default should return ANY_NODE if it can match any kind of node.
      • getMatchesNodeName

        public final java.lang.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.
      • getMode

        public java.lang.String getMode()
        Getter for property mode.
        Returns:
        Value of property mode.
      • setMode

        public void setMode​(java.lang.String mode)
        Setter for property mode.
        Parameters:
        mode - New value of property mode.
      • getImportPrecedence

        public int getImportPrecedence()
        Getter for property importPrecedence.
        Returns:
        Value of property importPrecedence.
      • setImportPrecedence

        public void setImportPrecedence​(int importPrecedence)
        Setter for property importPrecedence.
        Parameters:
        importPrecedence - New value of property importPrecedence.
      • getPriority

        public double getPriority()
        Getter for property priority.
        Returns:
        Value of property priority.
      • setPriority

        public void setPriority​(double priority)
        Setter for property priority.
        Parameters:
        priority - New value of property priority.
      • getAppearenceCount

        public int getAppearenceCount()
        Getter for property appearenceCount.
        Returns:
        Value of property appearenceCount.
      • setAppearenceCount

        public void setAppearenceCount​(int appearenceCount)
        Setter for property appearenceCount.
        Parameters:
        appearenceCount - New value of property appearenceCount.
      • getPattern

        public Pattern getPattern()
        Getter for property pattern.
        Returns:
        Value of property pattern.
      • setPattern

        public void setPattern​(Pattern pattern)
        Setter for property pattern.
        Parameters:
        pattern - New value of property pattern.
      • getAction

        public Action getAction()
        Getter for property action.
        Returns:
        Value of property action.
      • setAction

        public void setAction​(Action action)
        Setter for property action.
        Parameters:
        action - New value of property action.
      • compareInt

        private static int compareInt​(int value1,
                                      int value2)