org.eclipse.emf.ecore.util
Class EcoreEList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by org.eclipse.emf.common.util.BasicEList<E>
              extended by org.eclipse.emf.common.notify.impl.NotifyingListImpl<E>
                  extended by org.eclipse.emf.ecore.util.NotifyingInternalEListImpl<E>
                      extended by org.eclipse.emf.ecore.util.EcoreEList<E>
Type Parameters:
E -
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess, NotifyingList<E>, EList<E>, EStructuralFeature.Setting, InternalEList<E>, InternalEList.Unsettable<E>
Direct Known Subclasses:
EcoreEList.Generic, EDataTypeEList, EObjectEList

public abstract class EcoreEList<E>
extends NotifyingInternalEListImpl<E>
implements InternalEList.Unsettable<E>, EStructuralFeature.Setting

A notifying internal EList that implements InternalEList and EStructuralFeature.Setting. At least one of getEStructuralFeature() or getFeatureID() must be specialized since each delegates to the other and without specialization this will lead to stack overflow.

See Also:
Serialized Form

Nested Class Summary
static class EcoreEList.Dynamic<E>
           
static class EcoreEList.Generic<E>
          An Ecore EList with an implementation for exhibiting the appropriate feature behaviour as well as for tracking the unset state.
static class EcoreEList.UnmodifiableEList<E>
           
 
Nested classes/interfaces inherited from class org.eclipse.emf.common.util.BasicEList
BasicEList.BasicIndexOutOfBoundsException, BasicEList.EIterator<E1>, BasicEList.EListIterator<E1>, BasicEList.FastCompare<E>, BasicEList.NonResolvingEIterator<E1>, BasicEList.NonResolvingEListIterator<E1>
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.util.InternalEList
InternalEList.Unsettable<E>
 
Field Summary
protected  java.lang.Class<?> dataClass
           
protected  InternalEObject owner
           
 
Fields inherited from class org.eclipse.emf.common.util.BasicEList
data, size
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EcoreEList(java.lang.Class<?> dataClass, InternalEObject owner)
           
 
Method Summary
 boolean contains(java.lang.Object object)
          Resolve to compare objects but do not modify list
protected  NotificationImpl createNotification(int eventType, boolean oldValue, boolean newValue)
           
protected  NotificationImpl createNotification(int eventType, java.lang.Object oldObject, java.lang.Object newObject, int index, boolean wasSet)
          Creates a notification.
protected  void dispatchNotification(Notification notification)
          Dispatches a notification to the notifier of the list.
 java.lang.Object get(boolean resolve)
          Returns the value held by the feature of the object; it optionally resolves the value.
 EObject getEObject()
          Returns the object holding a value.
 EStructuralFeature getEStructuralFeature()
          Returns the specific feature holding a value for the object.
 java.lang.Object getFeature()
          Returns null.
 int getFeatureID()
          Returns Notification.NO_FEATURE_ID.
protected  EClassifier getFeatureType()
           
protected  EReference getInverseEReference()
           
protected  java.lang.Class<?> getInverseFeatureClass()
           
protected  int getInverseFeatureID()
           
 java.lang.Object getNotifier()
          Returns null.
protected  boolean hasInstanceClass()
           
protected  boolean hasManyInverse()
           
protected  boolean hasNavigableInverse()
           
protected  boolean hasProxies()
           
 int indexOf(java.lang.Object object)
          Returns the position of the first occurrence of the object in the list.
 NotificationChain inverseAdd(E object, NotificationChain notifications)
          Does nothing and returns the notifications.
 NotificationChain inverseRemove(E object, NotificationChain notifications)
          Does nothing and returns the notifications.
protected  boolean isContainment()
           
protected  boolean isEObject()
           
protected  boolean isInstance(java.lang.Object object)
           
protected  boolean isNotificationRequired()
          Returns false.
 boolean isSet()
          Returns whether the list is considered set, i.e., whether it's not empty.
 int lastIndexOf(java.lang.Object object)
          Returns the position of the last occurrence of the object in the list.
protected  java.lang.Object[] newData(int capacity)
          Returns new allocated data storage.
protected  E resolve(E object)
          Returns the resolved object from this list for the purpose of testing whether NotifyingListImpl.removeAll(Collection) applies to it.
protected  E resolve(int index, E object)
          Resolves the object at the index and returns the result.
protected  EObject resolve(int index, EObject eObject)
           
protected  EObject resolveProxy(EObject eObject)
           
 void set(java.lang.Object newValue)
          Set the value held by the feature of the object.
 java.lang.Object[] toArray()
          Returns an array containing all the objects in sequence.
<T> T[]
toArray(T[] array)
          Returns an array containing all the objects in sequence.
 void unset()
          Unsets the value held by the feature of the object.
protected  E validate(int index, E object)
          Validates a new content object and returns the validated object.
 
Methods inherited from class org.eclipse.emf.ecore.util.NotifyingInternalEListImpl
basicContains, basicContainsAll, basicIndexOf, basicIterator, basicLastIndexOf, basicList, basicListIterator, basicListIterator, basicToArray, basicToArray
 
Methods inherited from class org.eclipse.emf.common.notify.impl.NotifyingListImpl
addAllUnique, addAllUnique, addAllUnique, addAllUnique, addUnique, addUnique, basicAdd, basicRemove, basicSet, canContainNull, clear, createNotification, createNotificationChain, doAddAllUnique, doAddAllUnique, doAddAllUnique, doAddAllUnique, doAddUnique, doAddUnique, doClear, doMove, doRemove, doRemoveAll, doSetUnique, getFeatureID, hasInverse, hasShadow, move, remove, removeAll, setUnique, shadowAdd, shadowRemove, shadowSet
 
Methods inherited from class org.eclipse.emf.common.util.BasicEList
add, add, addAll, addAll, assign, basicGet, clone, containsAll, data, didAdd, didChange, didClear, didMove, didRemove, didSet, equalObjects, equals, get, getDuplicates, getNonDuplicates, grow, hashCode, isEmpty, isUnique, iterator, listIterator, listIterator, move, remove, retainAll, set, setData, shrink, size, toString, useEquals
 
Methods inherited from class java.util.AbstractList
removeRange, subList
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.ecore.util.InternalEList
addAllUnique, addAllUnique, addUnique, addUnique, basicAdd, basicContains, basicContainsAll, basicGet, basicIndexOf, basicIterator, basicLastIndexOf, basicList, basicListIterator, basicListIterator, basicRemove, basicToArray, basicToArray, setUnique
 
Methods inherited from interface org.eclipse.emf.common.util.EList
move, move
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, containsAll, equals, get, hashCode, isEmpty, iterator, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList
 

Field Detail

dataClass

protected final java.lang.Class<?> dataClass

owner

protected final InternalEObject owner
Constructor Detail

EcoreEList

public EcoreEList(java.lang.Class<?> dataClass,
                  InternalEObject owner)
Method Detail

newData

protected java.lang.Object[] newData(int capacity)
Description copied from class: BasicEList
Returns new allocated data storage. Clients may override this to create typed storage. The cost of type checking via a typed array is negligible.

Overrides:
newData in class BasicEList<E>
Returns:
new data storage.

validate

protected E validate(int index,
                     E object)
Description copied from class: BasicEList
Validates a new content object and returns the validated object. This implementation checks for null, if necessary and returns the argument object. Clients may throw additional types of runtime exceptions in order to handle constraint violations.

Overrides:
validate in class BasicEList<E>
Parameters:
index - the position of the new content.
object - the new content.
Returns:
the validated content.

isInstance

protected boolean isInstance(java.lang.Object object)

getNotifier

public java.lang.Object getNotifier()
Description copied from class: NotifyingListImpl
Returns null.

Specified by:
getNotifier in interface NotifyingList<E>
Overrides:
getNotifier in class NotifyingListImpl<E>
Returns:
null.

getFeature

public java.lang.Object getFeature()
Description copied from class: NotifyingListImpl
Returns null.

Specified by:
getFeature in interface NotifyingList<E>
Overrides:
getFeature in class NotifyingListImpl<E>
Returns:
null.
See Also:
Notification.getFeature()

getFeatureID

public int getFeatureID()
Description copied from class: NotifyingListImpl
Returns Notification.NO_FEATURE_ID.

Specified by:
getFeatureID in interface NotifyingList<E>
Overrides:
getFeatureID in class NotifyingListImpl<E>
Returns:
Notification.NO_FEATURE_ID.
See Also:
Notification.getFeatureID(java.lang.Class)

getEStructuralFeature

public EStructuralFeature getEStructuralFeature()
Description copied from interface: EStructuralFeature.Setting
Returns the specific feature holding a value for the object.

Specified by:
getEStructuralFeature in interface EStructuralFeature.Setting
Returns:
the specific feature holding a value for the object.

getFeatureType

protected EClassifier getFeatureType()

getInverseEReference

protected EReference getInverseEReference()

getInverseFeatureID

protected int getInverseFeatureID()

getInverseFeatureClass

protected java.lang.Class<?> getInverseFeatureClass()

hasManyInverse

protected boolean hasManyInverse()

hasNavigableInverse

protected boolean hasNavigableInverse()

isEObject

protected boolean isEObject()

isContainment

protected boolean isContainment()

hasProxies

protected boolean hasProxies()

hasInstanceClass

protected boolean hasInstanceClass()

resolve

protected E resolve(int index,
                    E object)
Description copied from class: BasicEList
Resolves the object at the index and returns the result. This implementation simply returns the object; clients can use this to transform objects as they are fetched.

Overrides:
resolve in class BasicEList<E>
Parameters:
index - the position of the content.
object - the content.
Returns:
the resolved object.

resolve

protected EObject resolve(int index,
                          EObject eObject)

resolve

protected E resolve(E object)
Description copied from class: NotifyingListImpl
Returns the resolved object from this list for the purpose of testing whether NotifyingListImpl.removeAll(Collection) applies to it.

Overrides:
resolve in class NotifyingListImpl<E>
Parameters:
object - the object to be resolved.
Returns:
the resolved object from this list for the purpose of testing whether removeAll applies to it.

resolveProxy

protected EObject resolveProxy(EObject eObject)

toArray

public java.lang.Object[] toArray()
Description copied from class: BasicEList
Returns an array containing all the objects in sequence. Clients may override newData to create typed storage in this case.

Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.List<E>
Overrides:
toArray in class BasicEList<E>
Returns:
an array containing all the objects in sequence.
See Also:
BasicEList.newData(int)

toArray

public <T> T[] toArray(T[] array)
Description copied from class: BasicEList
Returns an array containing all the objects in sequence.

Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.List<E>
Overrides:
toArray in class BasicEList<E>
Parameters:
array - the array that will be filled and returned, if it's big enough; otherwise, a suitably large array of the same type will be allocated and used instead.
Returns:
an array containing all the objects in sequence.
See Also:
BasicEList.newData(int)

createNotification

protected NotificationImpl createNotification(int eventType,
                                              java.lang.Object oldObject,
                                              java.lang.Object newObject,
                                              int index,
                                              boolean wasSet)
Description copied from class: NotifyingListImpl
Creates a notification.

Overrides:
createNotification in class NotifyingListImpl<E>
Parameters:
eventType - the type of change that has occurred.
oldObject - the value of the notifier's feature before the change occurred.
newObject - the value of the notifier's feature after the change occurred.
index - the position at which the change occurred.
Returns:
a new notification.

createNotification

protected NotificationImpl createNotification(int eventType,
                                              boolean oldValue,
                                              boolean newValue)

dispatchNotification

protected void dispatchNotification(Notification notification)
Description copied from class: NotifyingListImpl
Dispatches a notification to the notifier of the list.

Overrides:
dispatchNotification in class NotifyingListImpl<E>
Parameters:
notification - the notification to dispatch.

isNotificationRequired

protected boolean isNotificationRequired()
Description copied from class: NotifyingListImpl
Returns false.

Overrides:
isNotificationRequired in class NotifyingListImpl<E>
Returns:
false.

inverseAdd

public NotificationChain inverseAdd(E object,
                                    NotificationChain notifications)
Description copied from class: NotifyingListImpl
Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.

Overrides:
inverseAdd in class NotifyingListImpl<E>
Parameters:
object - the object that's been added to the list.
notifications - the chain of accumulating notifications.
Returns:
the notifications.

inverseRemove

public NotificationChain inverseRemove(E object,
                                       NotificationChain notifications)
Description copied from class: NotifyingListImpl
Does nothing and returns the notifications. Clients can override this to update the inverse of a bidirectional relation.

Overrides:
inverseRemove in class NotifyingListImpl<E>
Parameters:
object - the object that's been remove from the list.
notifications - the chain of accumulating notifications.
Returns:
the notifications.

contains

public boolean contains(java.lang.Object object)
Resolve to compare objects but do not modify list

Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.List<E>
Overrides:
contains in class BasicEList<E>
Parameters:
object - the object in question.
Returns:
whether the list contains the object.
See Also:
BasicEList.useEquals()

indexOf

public int indexOf(java.lang.Object object)
Description copied from class: BasicEList
Returns the position of the first occurrence of the object in the list. This implementation uses either equals or "==" depending on useEquals.

Specified by:
indexOf in interface java.util.List<E>
Overrides:
indexOf in class BasicEList<E>
Parameters:
object - the object in question.
Returns:
the position of the first occurrence of the object in the list.

lastIndexOf

public int lastIndexOf(java.lang.Object object)
Description copied from class: BasicEList
Returns the position of the last occurrence of the object in the list. This implementation uses either equals or "==" depending on useEquals.

Specified by:
lastIndexOf in interface java.util.List<E>
Overrides:
lastIndexOf in class BasicEList<E>
Parameters:
object - the object in question.
Returns:
the position of the last occurrence of the object in the list.

getEObject

public EObject getEObject()
Description copied from interface: EStructuralFeature.Setting
Returns the object holding a value.

Specified by:
getEObject in interface EStructuralFeature.Setting
Returns:
the object holding a value.

get

public java.lang.Object get(boolean resolve)
Description copied from interface: EStructuralFeature.Setting
Returns the value held by the feature of the object; it optionally resolves the value.

Specified by:
get in interface EStructuralFeature.Setting
Parameters:
resolve - whether to resolve.
Returns:
the value held by the feature of the object.
See Also:
EObject.eGet(EStructuralFeature, boolean)

set

public void set(java.lang.Object newValue)
Description copied from interface: EStructuralFeature.Setting
Set the value held by the feature of the object. If the new value is this setting itself, or is modified as a side effect of modifying this setting (i.e., if it is a view on the setting), the behavior is undefined and will likely result in simply clearing the list.

Specified by:
set in interface EStructuralFeature.Setting
Parameters:
newValue - the newValue.
See Also:
EObject.eSet(EStructuralFeature, Object)

isSet

public boolean isSet()
Description copied from class: NotifyingListImpl
Returns whether the list is considered set, i.e., whether it's not empty. A derived implementation may model this state directly.

Specified by:
isSet in interface EStructuralFeature.Setting
Specified by:
isSet in interface InternalEList.Unsettable<E>
Overrides:
isSet in class NotifyingListImpl<E>
Returns:
whether the list is considered set.
See Also:
EObject.eIsSet(EStructuralFeature)

unset

public void unset()
Description copied from interface: EStructuralFeature.Setting
Unsets the value held by the feature of the object.

Specified by:
unset in interface EStructuralFeature.Setting
Specified by:
unset in interface InternalEList.Unsettable<E>
See Also:
EObject.eUnset(EStructuralFeature)

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.