Search in sources :

Example 41 with RecordDefinition

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;
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 42 with RecordDefinition

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();
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 43 with RecordDefinition

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);
    }
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 44 with RecordDefinition

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);
        }
    }
}
Also used : RecordWriter(com.revolsys.record.io.RecordWriter) Query(com.revolsys.record.query.Query) RecordReader(com.revolsys.record.io.RecordReader) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 45 with RecordDefinition

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;
            }
        }
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)189 FieldDefinition (com.revolsys.record.schema.FieldDefinition)38 Record (com.revolsys.record.Record)34 Geometry (com.revolsys.geometry.model.Geometry)20 CodeTable (com.revolsys.record.code.CodeTable)19 Query (com.revolsys.record.query.Query)18 LineString (com.revolsys.geometry.model.LineString)17 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)16 PathName (com.revolsys.io.PathName)13 ArrayList (java.util.ArrayList)12 DataType (com.revolsys.datatype.DataType)11 Identifier (com.revolsys.identifier.Identifier)11 RecordReader (com.revolsys.record.io.RecordReader)11 RecordStore (com.revolsys.record.schema.RecordStore)11 HashMap (java.util.HashMap)9 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)8 ArrayRecord (com.revolsys.record.ArrayRecord)8 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)6 Table (com.revolsys.gis.esri.gdb.file.capi.swig.Table)5 RecordWriter (com.revolsys.record.io.RecordWriter)5