use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class Json method toString.
public static String toString(final RecordDefinition recordDefinition, final List<? extends Map<String, Object>> list) {
final StringWriter writer = new StringWriter();
final JsonRecordWriter recordWriter = new JsonRecordWriter(recordDefinition, writer);
for (final Map<String, Object> map : list) {
final Record object = new ArrayRecord(recordDefinition);
object.setValues(map);
recordWriter.write(object);
}
recordWriter.close();
return writer.toString();
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class Json method toString.
public static String toString(final RecordDefinition recordDefinition, final Map<String, ? extends Object> parameters) {
final Record object = new ArrayRecord(recordDefinition);
object.setValues(parameters);
return toString(object);
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class ShapefileRecordStore method newRecord.
@Override
public Record newRecord(final RecordDefinition recordDefinition) {
final String typePath = recordDefinition.getPath();
final RecordDefinition savedRecordDefinition = getRecordDefinition(typePath);
if (savedRecordDefinition == null) {
return new ArrayRecord(recordDefinition);
} else {
return new ArrayRecord(savedRecordDefinition);
}
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class RecordWriterPerformanceTest method newRecord.
private static Record newRecord(final RecordDefinition recordDefinition, final int index) {
final Record record = new ArrayRecord(recordDefinition);
record.setValue("boolean", index % 2 == 0);
record.setValue("byte", index % 256 + Byte.MIN_VALUE);
record.setValue("short", index % 65536 + Short.MIN_VALUE);
record.setValue("int", index);
record.setValue("long", index);
record.setValue("float", index + index % 1000 / 1000.0);
record.setValue("double", index + index % 1000 / 1000.0);
record.setValue("string", "String with some special characters " + index + "\\/\"'\t\n\r");
final Calendar calendar = new GregorianCalendar();
calendar.set(2016, 11, index % 28 + 1, 0, 0);
final Date date = new Date(calendar.getTimeInMillis());
record.setValue("date", date);
calendar.set(Calendar.MINUTE, index % 60);
final java.util.Date dateTime = new java.util.Date(calendar.getTimeInMillis());
record.setValue("dateTime", dateTime);
calendar.set(Calendar.MILLISECOND, index % 1000);
final Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
record.setValue("timestamp", timestamp);
record.setValue("geometry", new PointDoubleXY(index, index * 2));
return record;
}
use of com.revolsys.record.ArrayRecord in project com.revolsys.open by revolsys.
the class RecordIoTestSuite method doRecordReadTest.
private static void doRecordReadTest(final PathResource resource, final ArrayRecord record) {
if (RecordReader.isReadable(resource)) {
final RecordReaderFactory recordReaderFactory = IoFactory.factory(RecordReaderFactory.class, resource);
try (RecordReader recordReader = RecordReader.newRecordReader(resource)) {
final ClockDirection polygonRingDirection = recordReader.getPolygonRingDirection();
final List<Record> records = recordReader.toList();
Assert.assertEquals("Record Count", 1, records.size());
final Record actualRecord = records.get(0);
if (recordReaderFactory.isCustomFieldsSupported() && !(recordReader instanceof GeometryRecordReader)) {
for (final String fieldName : record.getRecordDefinition().getFieldNames()) {
if (!fieldName.equals("GEOMETRY")) {
final Object expectedValue = record.getValue(fieldName);
final Object actualValue = actualRecord.getValue(fieldName);
final boolean equals = DataType.equal(expectedValue, actualValue);
com.revolsys.geometry.util.Assert.equals(fieldName, equals, expectedValue, actualValue);
}
}
}
if (recordReaderFactory.isGeometrySupported()) {
final Geometry expectedGeometry = record.getGeometry();
final Geometry actualGeometry = actualRecord.getGeometry();
assertGeometry(polygonRingDirection, expectedGeometry, actualGeometry);
}
}
} else {
Logs.debug(RecordIoTestSuite.class, "Reading geometry not supported for: " + resource.getFileNameExtension());
}
}
Aggregations