From 90bd381e91c873af5956da9e5f0cfa2b29675633 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 11 Oct 2007 21:00:12 +0000 Subject: Support sorting of arrays. --- .../synthetic/SyntheticStorableReferenceBuilder.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/synthetic') diff --git a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java index f9db620..4fddcd5 100644 --- a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java +++ b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java @@ -29,6 +29,7 @@ import java.util.Set; import com.amazon.carbonado.Storable; import com.amazon.carbonado.SupportException; +import com.amazon.carbonado.cursor.SortedCursor; import com.amazon.carbonado.info.Direction; import com.amazon.carbonado.info.StorableInfo; import com.amazon.carbonado.info.StorableIntrospector; @@ -219,18 +220,14 @@ public class SyntheticStorableReferenceBuilder mSyntheticClass = mBuilder.getStorableClass(); // We need a comparator which follows the same order as the generated - // storable. We can't construct it until we get here - { - BeanComparator bc = BeanComparator.forClass(mSyntheticClass); - Iterator props = mPrimaryKey.getProperties(); - while (props.hasNext()) { - String prop = props.next(); - // BeanComparator knows how to handle the '+' or '-' prefix. - bc = bc.orderBy(prop); - bc = bc.caseSensitive(); - } - mComparator = bc; + // storable. We can't construct it until we get here. + String[] orderBy = new String[mPrimaryKey.getPropertyCount()]; + int i=0; + Iterator it = mPrimaryKey.getProperties(); + while (it.hasNext()) { + orderBy[i++] = it.next(); } + mComparator = SortedCursor.createComparator(mSyntheticClass, orderBy); } return mSyntheticClass; } -- cgit v1.2.3