Esempio n. 1
0
  public Double read(ShortTermMemoryReader reader) throws RowColumnReaderException {
    try {
      IntegerReadService.removeSpaces(reader);
      char c = (char) reader.read();
      if (Character.isDigit(c) || c == '-' || c == '+') {
        StringBuilder sb = new StringBuilder();
        sb.append(c);
        IntegerReadService.readDigitStar(reader, sb);
        c = (char) reader.read();
        if (c == '.') {
          sb.append(c);
          IntegerReadService.readDigitStar(reader, sb);
          c = (char) reader.read();
        }

        if (c == 'e' || c == 'E') {
          sb.append(c);
          c = (char) reader.read();
          if (c == '-' || c == '+') {
            sb.append(c);
          } else {
            IntegerReadService.back(c, reader);
          }
          IntegerReadService.readDigitStar(reader, sb);
        } else {
          IntegerReadService.back(c, reader);
        }
        return Double.parseDouble(sb.toString());
      }
      throw new Exception("Unexpected symbol " + c);
    } catch (Exception e) {
      throw reader.getException("Double Parser Error " + e.getMessage());
    }
  }
Esempio n. 2
0
 public static void removeSpaces(ShortTermMemoryReader reader) throws IOException {
   char c = (char) reader.read();
   while (Character.isSpaceChar(c)) {
     c = (char) reader.read();
   }
   back(c, reader);
 }
Esempio n. 3
0
 public static void readDigitStar(ShortTermMemoryReader reader, StringBuilder sb)
     throws IOException {
   char c = (char) reader.read();
   while (Character.isDigit(c)) {
     sb.append(c);
     c = (char) reader.read();
   }
   back(c, reader);
 }