From 526c529f4ab9d7be1604d573efbcc8b478f6c8ba Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sat, 13 Jan 2007 20:01:54 +0000 Subject: Fix for getting supplied filter values when duplicate property filters exist. --- .../com/amazon/carbonado/filter/FilterValues.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/amazon') diff --git a/src/main/java/com/amazon/carbonado/filter/FilterValues.java b/src/main/java/com/amazon/carbonado/filter/FilterValues.java index b9d3f5a..331ee3f 100644 --- a/src/main/java/com/amazon/carbonado/filter/FilterValues.java +++ b/src/main/java/com/amazon/carbonado/filter/FilterValues.java @@ -525,14 +525,15 @@ public class FilterValues implements Appender { } FilterValues prevValues = mPrevValues; - int blankCount; - if (prevValues == null || (blankCount= prevValues.mCurrentProperty.getBlankCount()) == 0) { + if (prevValues == null) { return NO_VALUES; } int i = list.getPreviousRemaining() + 1; - int valuesPos = Math.min(i, blankCount); + // Array is sized assuming that no constants are encountered and all + // filters are assigned values. Array is trimmed later if necessary. + int valuesPos = i; Object[] values = new Object[valuesPos]; FilterValues filterValues = this; @@ -588,8 +589,17 @@ public class FilterValues implements Appender { } values[--valuesPos] = value; - if (valuesPos <= 0) { - break; + } + + if (valuesPos != 0) { + // Trim array. + int newValuesSize = values.length - valuesPos; + if (newValuesSize == 0) { + values = NO_VALUES; + } else { + Object[] newValues = new Object[newValuesSize]; + System.arraycopy(values, valuesPos, newValues, 0, newValuesSize); + values = newValues; } } -- cgit v1.2.3