home *** CD-ROM | disk | FTP | other *** search
- package com.kav.xsl;
-
- import java.util.Hashtable;
- import org.w3c.dom.Node;
-
- public class TemplateRule extends XSLObject {
- private MatchExpr matchExpr;
- float priority;
- private boolean mIsRoot = false;
-
- public TemplateRule(XSLStylesheet var1) {
- super(var1, (short)31);
- }
-
- public XSLObject copy() {
- Object var1 = null;
- TemplateRule var2 = new TemplateRule(((XSLObject)this).getParentStylesheet());
- var2.setPriority(this.priority);
- var2.setMatchExpr(this.matchExpr);
- ((XSLObject)var2).copyActions(this);
- ((XSLObject)var2).copyAttributes(this);
- return var2;
- }
-
- public int compareTo(TemplateRule var1, Node var2, Hashtable var3) {
- PathExpr var4 = this.matchExpr.getMatchingExpr(var2, var3);
- PathExpr var5 = var1.getMatchingExpr(var2, var3);
- if (var5 == null && var4 == null) {
- return 0;
- } else if (var5 == null) {
- return 1;
- } else if (var4 == null) {
- return -1;
- } else {
- int var6 = var4.compareTo(var5);
- if (var6 != 0) {
- return var6;
- } else if (var1.getPriority() > this.priority) {
- return -1;
- } else {
- return var1.getPriority() < this.priority ? 1 : 0;
- }
- }
- }
-
- public PathExpr getMatchingExpr(Node var1, Hashtable var2) {
- return this.matchExpr.getMatchingExpr(var1, var2);
- }
-
- public MatchExpr getMatchExpr() {
- return this.matchExpr;
- }
-
- public String getMode() {
- return ((XSLObject)this).getAttribute("mode");
- }
-
- public float getPriority() {
- if (this.priority == 0.0F) {
- String var1 = ((XSLObject)this).getAttribute("priority");
- if (var1 != null && var1.length() > 0) {
- try {
- this.priority = Float.valueOf(var1);
- } catch (NumberFormatException var2) {
- this.priority = 0.0F;
- }
- }
- }
-
- return this.priority;
- }
-
- public boolean matchesRoot() {
- return this.mIsRoot;
- }
-
- public boolean matches(Node var1, Hashtable var2) {
- return this.matchExpr.matches(var1, var2);
- }
-
- public void setIsRoot(boolean var1) {
- this.mIsRoot = var1;
- }
-
- public void setMatchExpr(String var1) throws InvalidExprException {
- if (var1 == null) {
- var1 = "";
- }
-
- this.matchExpr = ExpressionParser.createMatchExpr(var1);
-
- try {
- this.setAttribute("match", var1);
- } catch (XSLException var2) {
- }
-
- if (this.matchExpr != null && this.matchExpr.matchesRoot()) {
- this.mIsRoot = true;
- }
-
- }
-
- public void setMatchExpr(MatchExpr var1) {
- this.matchExpr = var1;
- if (var1 != null && var1.matchesRoot()) {
- this.mIsRoot = true;
- }
-
- }
-
- public void setMode(String var1) {
- try {
- this.setAttribute("mode", var1);
- } catch (XSLException var2) {
- }
- }
-
- public void setPriority(float var1) {
- this.priority = var1;
-
- try {
- this.setAttribute("priority", String.valueOf(var1));
- } catch (XSLException var2) {
- }
- }
-
- public void setAttribute(String var1, String var2) throws XSLException {
- if ("priority".equals(var1)) {
- try {
- this.priority = Float.valueOf(var2);
- } catch (NumberFormatException var3) {
- this.priority = 0.0F;
- }
- }
-
- super.setAttribute(var1, var2);
- }
- }
-