summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java')
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java322
1 files changed, 146 insertions, 176 deletions
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java
index 59e135b..3a2bcaf 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/ArrayFault.java
@@ -25,195 +25,165 @@ import java.util.ListIterator;
import net.wotonomy.foundation.NSArray;
/**
-* A class that extends NSArray to intercept any accessor calls
-* in order to defer loading until the last possible moment.<br><br>
-*
-* Because ArrayFault inherits from NSArray which implements
-* List which implements Collection, data objects may declare
-* their relationships to be of type NSArray, List, or Collection.<br><br>
-*
-* This class should be returned by implementations of
-* EOObjectStore.arrayFaultForSourceGlobalID().
-*/
-public class ArrayFault extends NSArray
-{
- private EOEditingContext editingContext;
- private EOGlobalID sourceID;
- private String relationshipKey;
- private boolean fetched;
-
- public ArrayFault(
- EOGlobalID aSourceID,
- String aRelationshipKey,
- EOEditingContext aContext )
- {
- super();
- editingContext = aContext;
- sourceID = aSourceID;
- relationshipKey = aRelationshipKey;
- fetched = false;
- }
-
- public boolean isFetched()
- {
- return fetched;
- }
-
- protected void fireFault()
- {
- if ( !fetched )
- {
+ * A class that extends NSArray to intercept any accessor calls in order to
+ * defer loading until the last possible moment.<br>
+ * <br>
+ *
+ * Because ArrayFault inherits from NSArray which implements List which
+ * implements Collection, data objects may declare their relationships to be of
+ * type NSArray, List, or Collection.<br>
+ * <br>
+ *
+ * This class should be returned by implementations of
+ * EOObjectStore.arrayFaultForSourceGlobalID().
+ */
+public class ArrayFault extends NSArray {
+ private EOEditingContext editingContext;
+ private EOGlobalID sourceID;
+ private String relationshipKey;
+ private boolean fetched;
+
+ public ArrayFault(EOGlobalID aSourceID, String aRelationshipKey, EOEditingContext aContext) {
+ super();
+ editingContext = aContext;
+ sourceID = aSourceID;
+ relationshipKey = aRelationshipKey;
+ fetched = false;
+ }
+
+ public boolean isFetched() {
+ return fetched;
+ }
+
+ protected void fireFault() {
+ if (!fetched) {
//new net.wotonomy.ui.swing.util.StackTraceInspector();
//System.out.println( "ArrayFault.fireFault: before:" + this );
- fetched = true;
- super.protectedAddAll(
- editingContext.parentObjectStore().objectsForSourceGlobalID(
- sourceID,
- relationshipKey,
- editingContext ) );
+ fetched = true;
+ super.protectedAddAll(editingContext.parentObjectStore().objectsForSourceGlobalID(sourceID, relationshipKey,
+ editingContext));
//System.out.println( "ArrayFault.fireFault: after:" + this );
- }
- }
-
- public Object clone()
- {
- fireFault();
- return super.clone();
- }
-
- public boolean contains(Object elem)
- {
- fireFault();
- return super.contains( elem );
- }
-
- public boolean equals(Object o)
- {
- fireFault();
- return super.equals( o );
- }
-
- public Object get(int index)
- {
- fireFault();
- return super.get( index );
- }
-
- /**
- * Overridden to return the identity hash.
- * This somewhat violates the List contract,
- * but otherwise calling hash code would
- * fire the fault. Bottom line: don't use
- * array faults as keys in hash maps.
- */
- public int hashCode()
- {
- return System.identityHashCode( this );
- }
-
- public int indexOf(Object o)
- {
- fireFault();
- return super.indexOf( o );
- }
-
- public boolean isEmpty()
- {
- fireFault();
- return super.isEmpty();
- }
-
- public Iterator iterator()
- {
- fireFault();
- return super.iterator();
- }
-
- public int lastIndexOf(Object o)
- {
- fireFault();
- return super.lastIndexOf( o );
- }
-
- public ListIterator listIterator()
- {
- fireFault();
- return super.listIterator();
- }
-
- public ListIterator listIterator(int index)
- {
- fireFault();
- return super.listIterator( index );
- }
-
- public int size()
- {
- fireFault();
- return super.size();
- }
-
- public List subList(int fromIndex, int toIndex)
- {
- fireFault();
- return super.subList( fromIndex, toIndex );
- }
-
- public Object[] toArray()
- {
- fireFault();
- return super.toArray();
- }
-
- public Object[] toArray(Object[] a)
- {
- fireFault();
- return super.toArray( a );
- }
-
- /**
- * Overridden to display information about
- * the fault only if not fetched.
- * Calls to super if fetched.
- */
- public String toString()
- {
- if ( isFetched() )
- {
- return super.toString();
- }
- return "[ArrayFault@"+Integer.toHexString( System.identityHashCode( this ) )+":"+sourceID+":"+relationshipKey+"]";
- }
+ }
+ }
+
+ public Object clone() {
+ fireFault();
+ return super.clone();
+ }
+
+ public boolean contains(Object elem) {
+ fireFault();
+ return super.contains(elem);
+ }
+
+ public boolean equals(Object o) {
+ fireFault();
+ return super.equals(o);
+ }
+
+ public Object get(int index) {
+ fireFault();
+ return super.get(index);
+ }
+
+ /**
+ * Overridden to return the identity hash. This somewhat violates the List
+ * contract, but otherwise calling hash code would fire the fault. Bottom line:
+ * don't use array faults as keys in hash maps.
+ */
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ public int indexOf(Object o) {
+ fireFault();
+ return super.indexOf(o);
+ }
+
+ public boolean isEmpty() {
+ fireFault();
+ return super.isEmpty();
+ }
+
+ public Iterator iterator() {
+ fireFault();
+ return super.iterator();
+ }
+
+ public int lastIndexOf(Object o) {
+ fireFault();
+ return super.lastIndexOf(o);
+ }
+
+ public ListIterator listIterator() {
+ fireFault();
+ return super.listIterator();
+ }
+
+ public ListIterator listIterator(int index) {
+ fireFault();
+ return super.listIterator(index);
+ }
+
+ public int size() {
+ fireFault();
+ return super.size();
+ }
+
+ public List subList(int fromIndex, int toIndex) {
+ fireFault();
+ return super.subList(fromIndex, toIndex);
+ }
+
+ public Object[] toArray() {
+ fireFault();
+ return super.toArray();
+ }
+
+ public Object[] toArray(Object[] a) {
+ fireFault();
+ return super.toArray(a);
+ }
+
+ /**
+ * Overridden to display information about the fault only if not fetched. Calls
+ * to super if fetched.
+ */
+ public String toString() {
+ if (isFetched()) {
+ return super.toString();
+ }
+ return "[ArrayFault@" + Integer.toHexString(System.identityHashCode(this)) + ":" + sourceID + ":"
+ + relationshipKey + "]";
+ }
}
/*
- * $Log$
- * Revision 1.2 2006/02/16 16:47:14 cgruber
- * Move some classes in to "internal" packages and re-work imports, etc.
+ * $Log$ Revision 1.2 2006/02/16 16:47:14 cgruber Move some classes in to
+ * "internal" packages and re-work imports, etc.
*
- * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
+ * Also use UnsupportedOperationExceptions where appropriate, instead of
+ * WotonomyExceptions.
*
- * Revision 1.1 2006/02/16 13:19:57 cgruber
- * Check in all sources in eclipse-friendly maven-enabled packages.
+ * Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in
+ * eclipse-friendly maven-enabled packages.
*
- * Revision 1.5 2003/12/18 15:37:38 mpowers
- * Changes to retain ability to work with objects that don't necessarily
- * implement EOEnterpriseObject. I would still like to preserve this case
- * for general usage, however the access package is free to assume that
- * those objects will be EOs and cast appropriately.
+ * Revision 1.5 2003/12/18 15:37:38 mpowers Changes to retain ability to work
+ * with objects that don't necessarily implement EOEnterpriseObject. I would
+ * still like to preserve this case for general usage, however the access
+ * package is free to assume that those objects will be EOs and cast
+ * appropriately.
*
- * Revision 1.4 2003/08/19 01:53:12 chochos
- * EOObjectStore had some incompatible return types (Object instead of EOEnterpriseObject, in fault methods mostly). It's internally consistent but I hope it doesn't break anything based on this, even though fault methods mostly throw exceptions for now.
+ * Revision 1.4 2003/08/19 01:53:12 chochos EOObjectStore had some incompatible
+ * return types (Object instead of EOEnterpriseObject, in fault methods mostly).
+ * It's internally consistent but I hope it doesn't break anything based on
+ * this, even though fault methods mostly throw exceptions for now.
*
- * Revision 1.3 2002/10/24 18:17:37 mpowers
- * ArrayFaults are now read-only.
+ * Revision 1.3 2002/10/24 18:17:37 mpowers ArrayFaults are now read-only.
*
- * Revision 1.2 2001/05/06 22:22:55 mpowers
- * Debugging.
+ * Revision 1.2 2001/05/06 22:22:55 mpowers Debugging.
*
- * Revision 1.1 2001/05/05 23:05:42 mpowers
- * Implemented Array Faults.
+ * Revision 1.1 2001/05/05 23:05:42 mpowers Implemented Array Faults.
*
*
*/
-