Search in sources :

Example 36 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class Record method compareValue.

default int compareValue(final CharSequence fieldName, final Object value) {
    final FieldDefinition fieldDefinition = getFieldDefinition(fieldName);
    if (fieldDefinition == null) {
        return -1;
    } else {
        final int fieldIndex = fieldDefinition.getIndex();
        final Object fieldValue = getValue(fieldIndex);
        return CompareUtil.compare(fieldValue, value);
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition)

Example 37 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class Record method validateField.

default void validateField(final int fieldIndex) {
    final FieldDefinition field = getFieldDefinition(fieldIndex);
    if (field != null) {
        final Object value = getValue(fieldIndex);
        field.validate(this, value);
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition)

Example 38 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class Record method setValues.

default void setValues(final Record record) {
    if (record != null) {
        final List<FieldDefinition> idFields = getRecordDefinition().getIdFields();
        final List<FieldDefinition> fields = getFieldDefinitions();
        for (final FieldDefinition fieldDefintion : fields) {
            if (!idFields.contains(fieldDefintion)) {
                final String name = fieldDefintion.getName();
                final Object value = record.getValue(name);
                fieldDefintion.setValue(this, value);
            }
        }
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition)

Example 39 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class Record method setValues.

default void setValues(final Map<? extends CharSequence, ? extends Object> values, final Collection<? extends CharSequence> fieldNames) {
    for (final CharSequence fieldName : fieldNames) {
        final Object newValue = values.get(fieldName);
        final FieldDefinition fieldDefinition = getFieldDefinition(fieldName);
        if (fieldDefinition != null) {
            fieldDefinition.setValue(this, newValue);
        }
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition)

Example 40 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition 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

FieldDefinition (com.revolsys.record.schema.FieldDefinition)133 RecordDefinition (com.revolsys.record.schema.RecordDefinition)38 DataType (com.revolsys.datatype.DataType)32 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)23 JdbcFieldDefinition (com.revolsys.jdbc.field.JdbcFieldDefinition)19 PathName (com.revolsys.io.PathName)15 Record (com.revolsys.record.Record)15 ArrayList (java.util.ArrayList)15 Geometry (com.revolsys.geometry.model.Geometry)13 CodeTable (com.revolsys.record.code.CodeTable)9 Query (com.revolsys.record.query.Query)8 LineString (com.revolsys.geometry.model.LineString)7 ArrayRecord (com.revolsys.record.ArrayRecord)7 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)7 SQLException (java.sql.SQLException)7 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)4 IOException (java.io.IOException)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 BadLocationException (javax.swing.text.BadLocationException)4