/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Class
 *  java.lang.Comparable
 *  java.lang.Math
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 */
package org.dom4j.rule;

import org.dom4j.Node;
import org.dom4j.rule.Action;
import org.dom4j.rule.Pattern;

public class Rule
implements Comparable {
    private Action action;
    private int appearenceCount;
    private int importPrecedence;
    private String mode;
    private Pattern pattern;
    private double priority;

    public Rule() {
        this.priority = 0.5;
    }

    public Rule(Pattern pattern) {
        this.pattern = pattern;
        this.priority = pattern.getPriority();
    }

    public Rule(Pattern pattern, Action action) {
        super(pattern);
        this.action = action;
    }

    public Rule(Rule rule, Pattern pattern) {
        this.mode = rule.mode;
        this.importPrecedence = rule.importPrecedence;
        this.priority = rule.priority;
        this.appearenceCount = rule.appearenceCount;
        this.action = rule.action;
        this.pattern = pattern;
    }

    public int compareTo(Object object) {
        if (object instanceof Rule) {
            return this.compareTo((Rule)object);
        }
        return this.getClass().getName().compareTo(object.getClass().getName());
    }

    public int compareTo(Rule rule) {
        int n = this.importPrecedence - rule.importPrecedence;
        if (n == 0 && (n = (int)Math.round((double)(this.priority - rule.priority))) == 0) {
            n = this.appearenceCount - rule.appearenceCount;
        }
        return n;
    }

    public boolean equals(Object object) {
        boolean bl = object instanceof Rule;
        boolean bl2 = false;
        if (bl) {
            int n = this.compareTo((Rule)object);
            bl2 = false;
            if (n == 0) {
                bl2 = true;
            }
        }
        return bl2;
    }

    public Action getAction() {
        return this.action;
    }

    public int getAppearenceCount() {
        return this.appearenceCount;
    }

    public int getImportPrecedence() {
        return this.importPrecedence;
    }

    public final short getMatchType() {
        return this.pattern.getMatchType();
    }

    public final String getMatchesNodeName() {
        return this.pattern.getMatchesNodeName();
    }

    public String getMode() {
        return this.mode;
    }

    public Pattern getPattern() {
        return this.pattern;
    }

    public double getPriority() {
        return this.priority;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public Rule[] getUnionRules() {
        Pattern[] arrpattern = this.pattern.getUnionPatterns();
        if (arrpattern == null) {
            return null;
        }
        int n = arrpattern.length;
        Rule[] arrrule = new Rule[n];
        int n2 = 0;
        while (n2 < n) {
            arrrule[n2] = new Rule(this, arrpattern[n2]);
            ++n2;
        }
        return arrrule;
    }

    public int hashCode() {
        return this.importPrecedence + this.appearenceCount;
    }

    public final boolean matches(Node node) {
        return this.pattern.matches(node);
    }

    public void setAction(Action action) {
        this.action = action;
    }

    public void setAppearenceCount(int n) {
        this.appearenceCount = n;
    }

    public void setImportPrecedence(int n) {
        this.importPrecedence = n;
    }

    public void setMode(String string2) {
        this.mode = string2;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public void setPriority(double d) {
        this.priority = d;
    }

    public String toString() {
        return new StringBuffer().append(super.toString()).append("[ pattern: ").append((Object)this.getPattern()).append(" action: ").append((Object)this.getAction()).append(" ]").toString();
    }
}

