Ejemplo n.º 1
0
  private void initBuffer() {
    CharInfo c;

    {
      c = new CharInfo();
      c.cp = 0;
      c.str = "B3";
      c.ctype = "O";
      c.start = -1;
      c.end = -1;
      buffer[0] = c;

      c = new CharInfo();
      c.cp = 0;
      c.str = "B2";
      c.ctype = "O";
      c.start = -1;
      c.end = -1;
      buffer[1] = c;

      c = new CharInfo();
      c.cp = 0;
      c.str = "B1";
      c.ctype = "O";
      c.start = -1;
      c.end = -1;
      buffer[2] = c;
    }
    end = 3;
    position = 3;
  }
Ejemplo n.º 2
0
  public CharInfo readChar() throws IOException {
    CharInfo c = new CharInfo();

    if (eos) {
      c.start = -1;
      c.end = -1;
      c.cp = -1;
    } else {
      c.start = reader.getPosition();
      c.cp = reader.read();
      c.end = reader.getPosition();
    }

    if (c.cp < 0) {
      eos = true;
      switch (eosCount) {
        case 0:
          c.str = "E1";
          c.ctype = "O";
          ++eosCount;
          break;
        case 1:
          c.str = "E2";
          c.ctype = "O";
          ++eosCount;
          break;
        case 2:
          c.str = "E3";
          c.ctype = "O";
          ++eosCount;
          break;
        default:
          return null;
      }
    } else {
      c.str = new String(Character.toChars(c.cp));
      c.ctype = getCharType(c.cp);
    }

    return c;
  }