diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/OrderedProperty.java | 12 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/qe/OrderingList.java | 40 |
2 files changed, 50 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/OrderedProperty.java b/src/main/java/com/amazon/carbonado/info/OrderedProperty.java index fe53c60..2e54e81 100644 --- a/src/main/java/com/amazon/carbonado/info/OrderedProperty.java +++ b/src/main/java/com/amazon/carbonado/info/OrderedProperty.java @@ -18,7 +18,11 @@ package com.amazon.carbonado.info;
+import java.io.Externalizable;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
import org.cojen.util.WeakCanonicalSet;
@@ -30,7 +34,9 @@ import com.amazon.carbonado.util.Appender; *
* @author Brian S O'Neill
*/
-public class OrderedProperty<S extends Storable> implements Appender {
+public class OrderedProperty<S extends Storable> implements Serializable, Appender {
+ private static final long serialVersionUID = 1L;
+
static WeakCanonicalSet cCanonical = new WeakCanonicalSet();
/**
@@ -175,4 +181,8 @@ public class OrderedProperty<S extends Storable> implements Appender { app.append(mDirection.toCharacter());
mProperty.appendTo(app);
}
+
+ private Object readResolve() {
+ return get(mProperty, mDirection);
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/qe/OrderingList.java b/src/main/java/com/amazon/carbonado/qe/OrderingList.java index d100cc9..b6235ac 100644 --- a/src/main/java/com/amazon/carbonado/qe/OrderingList.java +++ b/src/main/java/com/amazon/carbonado/qe/OrderingList.java @@ -18,6 +18,12 @@ package com.amazon.carbonado.qe;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
import java.util.AbstractList;
import java.util.HashMap;
import java.util.HashSet;
@@ -40,7 +46,9 @@ import com.amazon.carbonado.info.StorableIntrospector; *
* @author Brian S O'Neill
*/
-public class OrderingList<S extends Storable> extends AbstractList<OrderedProperty<S>> {
+public class OrderingList<S extends Storable> extends AbstractList<OrderedProperty<S>>
+ implements Serializable
+{
private static final OrderingList EMPTY_LIST = new OrderingList();
private static final Map<Class, OrderingList> cCache;
@@ -347,4 +355,34 @@ public class OrderingList<S extends Storable> extends AbstractList<OrderedProper return node;
}
+
+ private Object writeReplace() {
+ return new Orderings(asArray());
+ }
+
+ private static class Orderings implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ private OrderedProperty<?>[] mOrderings;
+
+ // Required for Externalizable.
+ public Orderings() {
+ }
+
+ Orderings(OrderedProperty<?>[] orderings) {
+ mOrderings = orderings;
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(mOrderings);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ mOrderings = (OrderedProperty<?>[]) in.readObject();
+ }
+
+ private Object readResolve() {
+ return OrderingList.get(mOrderings);
+ }
+ }
}
|