home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 31 / SUPERCDa.iso / Inet / HotJava / hjava.exe / InstallerData / lax.jar / com / zerog / util / QuotedStreamTokenizer.class (.txt)
Encoding:
Java Class File  |  1999-01-21  |  2.0 KB  |  151 lines

  1. package com.zerog.util;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. public class QuotedStreamTokenizer {
  7.    // $FF: renamed from: in java.io.InputStream
  8.    private InputStream field_0;
  9.    private char quoteChar = '"';
  10.    private char delimiter = ' ';
  11.    private boolean delimiting = true;
  12.    private int type = -1;
  13.    public static final int NOTHING = -1;
  14.    public static final int WORDS = -10;
  15.    public static final int FULL_QUOTED = -11;
  16.    public static final int HALF_QUOTED = -12;
  17.    private boolean drained = false;
  18.    private boolean quoting = false;
  19.  
  20.    public QuotedStreamTokenizer(InputStream var1) {
  21.       new Integer(4);
  22.       new StringBuffer();
  23.       this.field_0 = var1;
  24.    }
  25.  
  26.    public int getType() {
  27.       new Integer(4);
  28.       new StringBuffer();
  29.       return this.type;
  30.    }
  31.  
  32.    public void setQuoteChar(char var1) {
  33.       new Integer(4);
  34.       new StringBuffer();
  35.       this.quoteChar = var1;
  36.    }
  37.  
  38.    public char getQuoteChar() {
  39.       new Integer(4);
  40.       new StringBuffer();
  41.       return this.quoteChar;
  42.    }
  43.  
  44.    public void setDelimiter(char var1) {
  45.       new Integer(4);
  46.       new StringBuffer();
  47.       this.delimiter = var1;
  48.    }
  49.  
  50.    public char getDelimiter() {
  51.       new Integer(4);
  52.       new StringBuffer();
  53.       return this.delimiter;
  54.    }
  55.  
  56.    public boolean isDelimiting() {
  57.       new Integer(4);
  58.       new StringBuffer();
  59.       return this.delimiting;
  60.    }
  61.  
  62.    public void setDelimiting(boolean var1) {
  63.       new Integer(4);
  64.       new StringBuffer();
  65.       this.delimiting = var1;
  66.    }
  67.  
  68.    public String getNextToken() {
  69.       new Integer(4);
  70.       new StringBuffer();
  71.       StringBuffer var1 = new StringBuffer();
  72.       boolean var2 = false;
  73.       if (this.drained) {
  74.          this.type = -1;
  75.          return null;
  76.       } else {
  77.          int var3;
  78.          try {
  79.             while((var3 = this.field_0.read()) != -1) {
  80.                if (var3 == 92) {
  81.                   if (var2) {
  82.                      var1.append("\\");
  83.                      var2 = false;
  84.                   } else {
  85.                      var2 = true;
  86.                   }
  87.                } else if (var3 == this.quoteChar) {
  88.                   if (var2) {
  89.                      var1.append("\"");
  90.                      var2 = false;
  91.                   } else {
  92.                      if (this.quoting) {
  93.                         this.type = -11;
  94.                         this.quoting = false;
  95.                         return var1.toString();
  96.                      }
  97.  
  98.                      this.quoting = true;
  99.                      if (var1.length() > 0) {
  100.                         this.type = -10;
  101.                         return var1.toString();
  102.                      }
  103.                   }
  104.                } else if (this.isDelimiting() && var3 == this.delimiter && !this.quoting) {
  105.                   if (var2) {
  106.                      var1.append("\\");
  107.                      var2 = false;
  108.                   }
  109.  
  110.                   if (var1.length() > 0) {
  111.                      this.type = -10;
  112.                      return var1.toString();
  113.                   }
  114.                } else {
  115.                   if (var2) {
  116.                      var1.append("\\");
  117.                      var2 = false;
  118.                   }
  119.  
  120.                   var1.append(String.valueOf((char)var3));
  121.                }
  122.             }
  123.          } catch (IOException var5) {
  124.             ((Throwable)var5).printStackTrace();
  125.          }
  126.  
  127.          this.drained = true;
  128.          if (this.quoting) {
  129.             this.type = -12;
  130.          } else {
  131.             this.type = -10;
  132.          }
  133.  
  134.          return var1.length() > 0 ? var1.toString() : null;
  135.       }
  136.    }
  137.  
  138.    public void close() {
  139.       new Integer(4);
  140.       new StringBuffer();
  141.       if (this.field_0 != null) {
  142.          try {
  143.             this.field_0.close();
  144.          } catch (IOException var2) {
  145.             ((Throwable)var2).printStackTrace();
  146.          }
  147.       }
  148.  
  149.    }
  150. }
  151.