org.apache.cayenne.access
Class ToManyList

java.lang.Object
  extended by org.apache.cayenne.access.ToManyList
All Implemented Interfaces:
Serializable, Iterable, Collection, List, ValueHolder

public class ToManyList
extends Object
implements List, Serializable, ValueHolder

A list that holds objects for to-many relationships. All operations, except for resolving the list from DB, are not synchronized. The safest way to implement custom synchronization is to synchronize on parent ObjectStore.

Author:
Andrus Adamchik
See Also:
Serialized Form

Constructor Summary
ToManyList(Persistent source, String relationship)
          Creates ToManyList.
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 boolean equals(Object o)
           
 Object get(int index)
           
 String getRelationship()
          Returns a name of relationship for this list.
 Persistent getRelationshipOwner()
           
 Object getValue()
          Returns an object stored by this ValueHolder.
 Object getValueDirectly()
          Retrieves ValueHolder value without triggering fault resolution.
 int hashCode()
           
 int indexOf(Object o)
           
 void invalidate()
          Turns a ValueHolder into a fault.
 boolean isEmpty()
           
 boolean isFault()
          Returns true if the internal value is not yet resolved.
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 void setObjectList(List objectList)
           
 Object setValue(Object value)
          Sets an object stored by this ValueHolder.
 Object setValueDirectly(Object value)
          Sets ValueHolder vaue without triggering fault resolution.
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToManyList

public ToManyList(Persistent source,
                  String relationship)
Creates ToManyList.

Since:
1.1
Method Detail

getRelationshipOwner

public Persistent getRelationshipOwner()
Since:
1.2

getRelationship

public String getRelationship()
Returns a name of relationship for this list.

Since:
1.1

setObjectList

public void setObjectList(List objectList)

getValue

public Object getValue()
                throws CayenneRuntimeException
Description copied from interface: ValueHolder
Returns an object stored by this ValueHolder.

Specified by:
getValue in interface ValueHolder
Throws:
CayenneRuntimeException

invalidate

public void invalidate()
Description copied from interface: ValueHolder
Turns a ValueHolder into a fault.

Specified by:
invalidate in interface ValueHolder

isFault

public boolean isFault()
Description copied from interface: ValueHolder
Returns true if the internal value is not yet resolved.

Specified by:
isFault in interface ValueHolder

getValueDirectly

public Object getValueDirectly()
                        throws CayenneRuntimeException
Description copied from interface: ValueHolder
Retrieves ValueHolder value without triggering fault resolution.

Specified by:
getValueDirectly in interface ValueHolder
Throws:
CayenneRuntimeException

setValueDirectly

public Object setValueDirectly(Object value)
                        throws CayenneRuntimeException
Description copied from interface: ValueHolder
Sets ValueHolder vaue without triggering fault resolution.

Specified by:
setValueDirectly in interface ValueHolder
Throws:
CayenneRuntimeException

setValue

public Object setValue(Object value)
                throws CayenneRuntimeException
Description copied from interface: ValueHolder
Sets an object stored by this ValueHolder.

Specified by:
setValue in interface ValueHolder
Parameters:
value - a new value of the ValueHolder.
Returns:
a previous value saved in the ValueHolder.
Throws:
CayenneRuntimeException

add

public boolean add(Object o)
Specified by:
add in interface Collection
Specified by:
add in interface List

add

public void add(int index,
                Object element)
Specified by:
add in interface List

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection
Specified by:
contains in interface List

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object

get

public Object get(int index)
Specified by:
get in interface List

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface List

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.