use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Record method setValue.
/**
* Set the value of the field with the specified name.
*
* @param name The name of the field.
* @param value The new value.
*/
default boolean setValue(final CharSequence name, final Object value) {
final boolean updated = false;
final RecordDefinition recordDefinition = getRecordDefinition();
final int index = recordDefinition.getFieldIndex(name);
if (index != -1) {
return setValue(index, value);
} else {
if (Strings.contains(name, '.')) {
throw new IllegalArgumentException("name cannot contain a '.' " + name + "=" + value);
}
}
return updated;
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Record method toString.
static String toString(final Record record) {
final RecordDefinition recordDefinition = record.getRecordDefinition();
final StringBuilder s = new StringBuilder();
s.append(recordDefinition.getPath()).append("(\n");
for (int i = 0; i < recordDefinition.getFieldCount(); i++) {
final Object value = record.getValue(i);
if (value != null) {
final String fieldName = recordDefinition.getFieldName(i);
s.append(fieldName).append('=').append(value).append('\n');
}
}
s.append(')');
return s.toString();
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Record method setGeometryValue.
/**
* Set the value of the primary geometry field.
*
* @param geometry The primary geometry.
*/
default void setGeometryValue(final Geometry geometry) {
final RecordDefinition recordDefinition = getRecordDefinition();
final int index = recordDefinition.getGeometryFieldIndex();
if (index > -1) {
setValue(index, geometry);
}
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Records method copyRecords.
static void copyRecords(final RecordStore sourceRecordStore, final String sourceTableName, final RecordStore targetRecordStore, final String targetTableName) {
final Query query = new Query(sourceTableName);
try (RecordReader reader = sourceRecordStore.getRecords(query);
RecordWriter writer = targetRecordStore.newRecordWriter()) {
final RecordDefinition recordDefinition = targetRecordStore.getRecordDefinition(targetTableName);
for (final Record record : reader) {
final Record newRecord = recordDefinition.newRecord();
newRecord.setValuesAll(record);
writer.write(newRecord);
}
}
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class AbstractRecord method setValues.
@Override
public void setValues(final Object... values) {
if (values != null) {
int i = 0;
final RecordDefinition recordDefinition = getRecordDefinition();
for (final FieldDefinition fieldDefinition : recordDefinition.getFields()) {
if (i < values.length) {
final Object value = values[i];
setValue(fieldDefinition, value);
i++;
} else {
return;
}
}
}
}
Aggregations