home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / allaire / util / template / Token.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  2.7 KB  |  121 lines

  1. package allaire.util.template;
  2.  
  3. import allaire.util.TypelessValue;
  4. import java.io.StreamTokenizer;
  5. import netscape.util.Hashtable;
  6.  
  7. class Token {
  8.    private int m_enType;
  9.    private char m_cQuote;
  10.    private TypelessValue m_value;
  11.    // $FF: renamed from: LP int
  12.    static final int field_0 = 40;
  13.    // $FF: renamed from: RP int
  14.    static final int field_1 = 41;
  15.    static final int COMMA = 44;
  16.    static final int PLUS = 43;
  17.    static final int MINUS = 45;
  18.    static final int MUL = 42;
  19.    static final int DIV = 47;
  20.    static final int CONCAT = 38;
  21.    // $FF: renamed from: LT int
  22.    static final int field_2 = 1;
  23.    static final int LTE = 2;
  24.    // $FF: renamed from: GT int
  25.    static final int field_3 = 3;
  26.    static final int GTE = 4;
  27.    // $FF: renamed from: EQ int
  28.    static final int field_4 = 5;
  29.    static final int NEQ = 6;
  30.    static final int AND = 7;
  31.    // $FF: renamed from: OR int
  32.    static final int field_5 = 8;
  33.    static final int NOT = 9;
  34.    static final int NAME = 10;
  35.    static final int STRING = 11;
  36.    static final int NUMBER = 12;
  37.    static final int EOF = -1;
  38.    static Hashtable m_logicalOperators = new Hashtable();
  39.  
  40.    public char getQuoteChar() {
  41.       return this.m_cQuote;
  42.    }
  43.  
  44.    public TypelessValue getValue() {
  45.       if (this.m_value == null) {
  46.          if (this.m_enType == -1) {
  47.             this.m_value = new TypelessValue("-1");
  48.          } else {
  49.             this.m_value = new TypelessValue(String.valueOf((char)this.m_enType));
  50.          }
  51.       }
  52.  
  53.       return this.m_value;
  54.    }
  55.  
  56.    public void appendToValue(String var1) {
  57.       TypelessValue var2 = this.getValue();
  58.       this.m_value = new TypelessValue(var2.asString() + var1);
  59.    }
  60.  
  61.    static Integer lookupOperator(String var0) {
  62.       return (Integer)m_logicalOperators.get(var0.toUpperCase());
  63.    }
  64.  
  65.    static {
  66.       m_logicalOperators.put("LT", new Integer(1));
  67.       m_logicalOperators.put("LTE", new Integer(2));
  68.       m_logicalOperators.put("GT", new Integer(3));
  69.       m_logicalOperators.put("GTE", new Integer(4));
  70.       m_logicalOperators.put("EQ", new Integer(5));
  71.       m_logicalOperators.put("NEQ", new Integer(6));
  72.       m_logicalOperators.put("AND", new Integer(7));
  73.       m_logicalOperators.put("OR", new Integer(8));
  74.       m_logicalOperators.put("NOT", new Integer(9));
  75.    }
  76.  
  77.    public int getType() {
  78.       return this.m_enType;
  79.    }
  80.  
  81.    public Token(int var1, StreamTokenizer var2) throws ExpressionException {
  82.       switch (var1) {
  83.          case -3:
  84.             Integer var3 = lookupOperator(var2.sval);
  85.             if (var3 != null) {
  86.                this.m_enType = var3;
  87.                return;
  88.             }
  89.  
  90.             this.m_enType = 10;
  91.             this.m_value = new TypelessValue(var2.sval);
  92.             return;
  93.          case -2:
  94.             this.m_enType = 12;
  95.             this.m_value = new TypelessValue(var2.nval);
  96.             return;
  97.          case -1:
  98.             this.m_enType = -1;
  99.             return;
  100.          case 34:
  101.          case 39:
  102.             this.m_enType = 11;
  103.             this.m_cQuote = (char)var1;
  104.             this.m_value = new TypelessValue(var2.sval);
  105.             return;
  106.          case 38:
  107.          case 40:
  108.          case 41:
  109.          case 42:
  110.          case 43:
  111.          case 44:
  112.          case 45:
  113.          case 47:
  114.             this.m_enType = var1;
  115.             return;
  116.          default:
  117.             throw new ExpressionException(100, "Unexpected token '" + String.valueOf((char)var1) + "' found while parsing expression.");
  118.       }
  119.    }
  120. }
  121.