/** * Create a record by reader all its fields using reader * * @param reader to be used. * @throws IOException */ Record(FieldReader reader) throws IOException { while (reader.hasField()) { String field = reader.getField(); // System.err.print("field = " + field); if (field.isEmpty()) { rfields.add(null); fieldTypes.add(types.voidType()); // System.err.println(" void"); } else if (field.matches("^[+-]?[0-9]+$")) { rfields.add(values.integer(field)); fieldTypes.add(types.integerType()); // System.err.println(" int"); } else if (field.matches("[+-]?[0-9]+\\.[0-9]*")) { rfields.add(values.real(field)); fieldTypes.add(types.realType()); // System.err.println(" real"); } else if (field.equals("true") || field.equals("false")) { rfields.add(values.bool(field.equals("true"))); fieldTypes.add(types.boolType()); // System.err.println(" bool"); } else { rfields.add(values.string(field)); fieldTypes.add(types.stringType()); // System.err.println(" str"); } } }
private List<Record> loadRecords(Reader stream) throws IOException { FieldReader reader = new FieldReader(stream, separator); List<Record> records = new ArrayList<Record>(); while (reader.hasRecord()) { // TODO: Record should not read from reader. records.add(new Record(reader)); } return records; }