This is an automated email from the ASF dual-hosted git repository. doebele pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/empire-db.git
View the commit online: https://github.com/apache/empire-db/commit/831e97aef1b6e56e482ac1d72eba9c0450a1c12f The following commit(s) were added to refs/heads/master by this push: new 831e97a EMPIREDB-319 improvement 831e97a is described below commit 831e97aef1b6e56e482ac1d72eba9c0450a1c12f Author: Rainer Döbele <[email protected]> AuthorDate: Wed Nov 20 16:07:05 2019 +0100 EMPIREDB-319 improvement --- .../main/java/org/apache/empire/db/DBRecord.java | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java index 54a64a4..407cf73 100644 --- a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java +++ b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java @@ -574,32 +574,30 @@ public class DBRecord extends DBRecordData implements Record, Cloneable * Modifies a column value bypassing all checks made by setValue. * Use this to explicitly set invalid values i.e. for temporary storage. * - * @param i index of the column + * @param index index of the column * @param value the column value */ - protected void modifyValue(int i, Object value, boolean fireChangeEvent) + protected void modifyValue(int index, Object value, boolean fireChangeEvent) { // Check valid if (state == State.Invalid) throw new ObjectNotValidException(this); - // must have been fetched - if (fields[i]==ObjectUtils.NO_VALUE) - throw new FieldValueNotFetchedException(getColumn(i)); - // Init original values + if (index < 0 || index >= fields.length) + throw new InvalidArgumentException("index", index); + // modified state array if (modified == null) - { // Save all original values - modified = new boolean[fields.length]; + { modified = new boolean[fields.length]; for (int j = 0; j < fields.length; j++) modified[j] = false; } - // Set Value and Modified - fields[i] = value; - modified[i] = true; - // Set State + // set value and modified + fields[index] = value; + modified[index] = true; + // set record state if (state.isLess(State.Modified)) changeState(State.Modified); - // field changed + // field changed event if (fireChangeEvent) - onFieldChanged(i); + onFieldChanged(index); } /** @@ -644,9 +642,12 @@ public class DBRecord extends DBRecordData implements Record, Cloneable // Strings special if ((value instanceof String) && ((String)value).length()==0) value = null; - // Has Value changed? + // Is value valid Object current = fields[index]; - if (current!=ObjectUtils.NO_VALUE && ObjectUtils.compareEqual(current, value)) + if (current==ObjectUtils.NO_VALUE) + throw new FieldValueNotFetchedException(getColumn(index)); + // Has Value changed? + if (ObjectUtils.compareEqual(current, value)) return; // no change // Field has changed DBColumn column = rowset.getColumn(index);
