home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / APCHSSL2.ZIP / OS2HTTPD / jserv / com / kav / xsl / NodeExpr.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-05-16  |  1.9 KB  |  117 lines

  1. package com.kav.xsl;
  2.  
  3. import java.io.PrintWriter;
  4.  
  5. class NodeExpr extends PatternExpr {
  6.    public static final int ANCESTOR_EXPR = 0;
  7.    public static final int ATTRIBUTE_EXPR = 1;
  8.    public static final int ELEMENT_EXPR = 2;
  9.    public static final int ID_EXPR = 3;
  10.    public static final int IDENTITY_EXPR = 4;
  11.    public static final int PARENT_EXPR = 5;
  12.    public static final int TEXT_EXPR = 6;
  13.    public static final int COMMENT_EXPR = 7;
  14.    public static final int PI_EXPR = 8;
  15.    public static final String ATTRIBUTE = "@";
  16.    public static final String COMMENT = "comment";
  17.    // $FF: renamed from: ID java.lang.String
  18.    public static final String field_0 = "id";
  19.    // $FF: renamed from: PI java.lang.String
  20.    public static final String field_1 = "pi";
  21.    public static final String TEXT = "text";
  22.    public static final String IDENTITY_PATTERN = ".";
  23.    public static final String PARENT_PATTERN = "..";
  24.    public static final String WILD_CARD = "*";
  25.    private String name;
  26.    private int type = -1;
  27.  
  28.    protected NodeExpr(int var1) {
  29.       super(2);
  30.       this.type = var1;
  31.    }
  32.  
  33.    public String toString() {
  34.       switch (this.type) {
  35.          case 1:
  36.             return "@" + this.name;
  37.          case 2:
  38.             return this.name;
  39.          case 3:
  40.             return "id('" + this.name + "')";
  41.          case 4:
  42.             return ".";
  43.          case 5:
  44.             return "..";
  45.          case 6:
  46.             return "text()";
  47.          case 7:
  48.             return "comment()";
  49.          case 8:
  50.             String var1 = "pi(";
  51.             if (this.name != null) {
  52.                var1 = var1 + this.name;
  53.             }
  54.  
  55.             return var1 + ")";
  56.          default:
  57.             return this.name;
  58.       }
  59.    }
  60.  
  61.    protected int compareTo(NodeExpr var1) {
  62.       if (var1 == null) {
  63.          return 1;
  64.       } else {
  65.          int var2 = var1.getType();
  66.          if (var2 != this.type) {
  67.             return 0;
  68.          } else {
  69.             String var3 = var1.getName();
  70.             switch (this.type) {
  71.                case 1:
  72.                case 2:
  73.                case 3:
  74.                case 8:
  75.                   if (var3 == null && this.name == null) {
  76.                      return 0;
  77.                   } else if (var3 == null && this.name != null) {
  78.                      return 1;
  79.                   } else if (var3 != null && this.name == null) {
  80.                      return -1;
  81.                   } else if (!this.name.equals(var3)) {
  82.                      if ("*".equals(var3)) {
  83.                         return 1;
  84.                      } else if ("*".equals(this.name)) {
  85.                         return -1;
  86.                      }
  87.                   }
  88.                case 5:
  89.                default:
  90.                   return 0;
  91.                case 4:
  92.                case 6:
  93.                case 7:
  94.                   return 0;
  95.             }
  96.          }
  97.       }
  98.    }
  99.  
  100.    protected String getName() {
  101.       return this.name;
  102.    }
  103.  
  104.    protected int getType() {
  105.       return this.type;
  106.    }
  107.  
  108.    protected void print(PrintWriter var1) {
  109.       var1.print(this.toString());
  110.       var1.flush();
  111.    }
  112.  
  113.    protected void setName(String var1) {
  114.       this.name = var1;
  115.    }
  116. }
  117.