|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PIMCollection<E>
PIM version of java.util.Collection, which can only handle PIM objects (Catalog, Category, Item, Hierarchy, Spec, LookupTable etc.).
Implements a "lazy lookup", for performance reasons. This means that the collection keeps hold of objects by their internal ID only, and does not try to resolve the ID to a real object until the last possible moment. Thus, a PIMCollection is a collection of IDs, not objects, and we refer to these IDs as the elements in the collection.
The advantage here is greater performance, the cost is that in a large dynamic system, the contents of the collection may actually be different, for example if an object has been deleted since the collection was created.
This means that the behavior of this class is different than java.util.Collection.
Delete versus remove: an object is said to be deleted if the actual object corresponding to its ID in a PIMCollection is deleted, by a process outside the control of the PIMCollection; an object is said to be removed if it is the argument to an invocation of the remove() method and the method succeeds. If an object is deleted, the size of the PIMCollection is not changed, whereas if an object is removed the size of the PIMCollection is reduced by 1. Note that the fact that an object is removed from a PIMCollection does not imply that the actual object referenced by the ID in the PIMCollection is deleted.
IMPORTANT WARNING: This collection provides a moment in time view of the collection, which will allow you to access those objects in the collection for as long as they still exist in the underlying database. If underlying objects change, you may experience unexpected results, such as fewer iterations than expected, or nulls where you did not expect them.
Also, toArray() is not recommended for general use for performance reasons, as it will resolve every object in the Collection. It will be VERY slow on large collections. We recommend using PIMCollection.iterator() instead.
Field Summary | |
---|---|
static java.lang.String |
copyright
|
Method Summary | ||
---|---|---|
boolean |
add(E o)
Add the ID of the specified PIM object to this PIM collection. |
|
boolean |
addAll(java.util.Collection<? extends E> c)
Add all the elements in the specified collection to this collection. |
|
void |
clear()
Remove all the elements from this collection, making it empty. |
|
boolean |
contains(java.lang.Object o)
Check if the object o is in the collection. |
|
boolean |
containsAll(java.util.Collection<?> c)
Check if all the elements of Collection c are within this PIMCollection. |
|
boolean |
equals(java.lang.Object o)
Checks that the PIMCollection appears to contains the same elements as the specified PIMCollection. |
|
int |
hashCode()
A shallow hashcode method which only looks at the elements in this collection. |
|
boolean |
isEmpty()
Test whether this collection is empty. |
|
java.util.Iterator<E> |
iterator()
Get an iterator over the elements in this Collection. |
|
boolean |
remove(java.lang.Object o)
Remove a single instance of the ID of the specified object from this PIM collection. |
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all the elements in the specified collection from this collection. |
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only those elements in this collection that are elements of the specified collection (i.e. |
|
int |
size()
Return the current number of elements in the collection, regardless of whether all the IDs can be resolved. |
|
java.lang.Object[] |
toArray()
Retrieve the whole collection as an array. |
|
|
toArray(T[] a)
Unsupported method. |
Field Detail |
---|
static final java.lang.String copyright
Method Detail |
---|
int size()
size
in interface java.util.Collection<E>
Collection.size()
boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
Collection.isEmpty()
boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
o
- the object to check for presence in the collection
java.lang.NullPointerException
- if o is null
PIMInternalException
- if the object is not a valid PIM object type*
java.util.Iterator<E> iterator()
iterator
in interface java.util.Collection<E>
iterator
in interface java.lang.Iterable<E>
Collection.iterator()
java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
Collection.toArray()
<T> T[] toArray(T[] a)
This method will not work, because you cannot change the type of a PIM Object
toArray
in interface java.util.Collection<E>
java.lang.ArrayStoreException
- This exception will be thrown in all conditions.Collection.toArray(java.lang.Object[])
boolean add(E o)
add
in interface java.util.Collection<E>
o
- the PIM object to be added
java.lang.ClassCastException
- if the type of the object to add is not PIMObject
java.lang.NullPointerException
- if the object to add is nullCollection.add(java.lang.Object)
boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
o
- the object to be removed.
java.lang.ClassCastException
- if the type of the object to add is not PIMObject
java.lang.NullPointerException
- if the object to add is nullCollection.remove(java.lang.Object)
boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
c
- the collection to check against this collection
java.lang.NullPointerException
- if c is null or c contains a null entry
PIMInternalException
- if c is not a PIMCollection or if it contains an object that
is not a valid PIM ObjectCollection.containsAll(java.util.Collection)
boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
c
- the collection to add to this collection
java.lang.ClassCastException
- if the type of any element to add is not PIMObject
java.lang.NullPointerException
- if c is null or c contains a null entry
PIMInternalException
- if c is not a PIMCollection or if it contains an object that
is not a valid PIM ObjectCollection.addAll(java.util.Collection)
boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
c
- the collection to remove from this collection
java.lang.ClassCastException
- if the type of any element to remove is not PIMObject
java.lang.NullPointerException
- if c is null or c contains a null entry
PIMInternalException
- if c is not a PIMCollection or if it contains an object that
is not a valid PIM ObjectCollection.removeAll(java.util.Collection)
boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
c
- the collection to retain in this collection
java.lang.ClassCastException
- if the type of any element to retain is not PIMObject
java.lang.NullPointerException
- if c is null or c contains a null entry
PIMInternalException
- if c is not a PIMCollection or if it contains an object that
is not a valid PIM ObjectCollection.retainAll(java.util.Collection)
void clear()
clear
in interface java.util.Collection<E>
Collection.clear()
boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in class java.lang.Object
Object.equals(java.lang.Object)
int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in class java.lang.Object
Collection.hashCode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |