|
|||||||||
| Home >> All >> org >> scopemvc >> model >> [ collection overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.scopemvc.model.collection
Class ArrayModel

java.lang.Objectorg.scopemvc.model.basic.BasicModel
org.scopemvc.model.collection.ArrayModel
- All Implemented Interfaces:
- java.util.Collection, java.lang.Iterable, java.util.List, org.scopemvc.core.ModelChangeEventSource, org.scopemvc.core.ModelChangeListener, org.scopemvc.core.ModelChangeTypes
- public class ArrayModel
- extends org.scopemvc.model.basic.BasicModel
- implements java.util.List
- extends org.scopemvc.model.basic.BasicModel
A BasicModel wrapper for an Object[] that
can propogate changes to contained Models up the Model
hierarchy, and implements the java.util.List interface.
The array itself is exposed via the "array" property, however,
changes to this array must be made through the public API
in order to maintain the model change propogation.
By default ArrayModel registers itself as a listener to Models that are added to the array and deregisters when those Models are removed. This behaviour can be changed at creation so that ModelChangeEvent propogation is disabled.
- Version:
- $Revision: 1.4 $ $Date: 2002/01/26 09:46:20 $
| Field Summary | |
static org.scopemvc.core.Selector |
ARRAY
|
protected java.lang.Object[] |
contents
|
private static org.apache.commons.logging.Log |
LOG
|
protected boolean |
propogateModelChanges
|
protected static java.lang.String |
TO_STRING_SEPARATOR
|
protected static int |
TO_STRING_SEPARATOR_LENGTH
|
| Fields inherited from class org.scopemvc.model.basic.BasicModel |
|
| Fields inherited from interface org.scopemvc.core.ModelChangeTypes |
ACCESS_CHANGED, VALUE_ADDED, VALUE_CHANGED, VALUE_REMOVED |
| Constructor Summary | |
ArrayModel()
|
|
ArrayModel(boolean inPropogateModelChanges)
|
|
ArrayModel(boolean inPropogateModelChanges,
int inSize)
|
|
ArrayModel(boolean inPropogateModelChanges,
java.lang.Object[] inArray)
|
|
ArrayModel(int inSize)
|
|
ArrayModel(java.lang.Object[] inArray)
|
|
| Method Summary | |
void |
add(int index,
java.lang.Object element)
Insert an element into the list at a given position (optional operation). |
boolean |
add(java.lang.Object o)
Add an element to the end of the list (optional operation). |
boolean |
addAll(java.util.Collection c)
Add the contents of a collection to the end of the list (optional operation). |
boolean |
addAll(int index,
java.util.Collection c)
Insert the contents of a collection into the list at a given position (optional operation). |
void |
clear()
Clear the list, such that a subsequent call to isEmpty() would return true (optional operation). |
boolean |
contains(java.lang.Object o)
Test whether this list contains a given object as one of its elements. |
boolean |
containsAll(java.util.Collection c)
Test whether this list contains every element in a given collection. |
boolean |
equals(java.lang.Object o)
Test whether this list is equal to another object. |
java.lang.Object |
get(int index)
Get the element at a given index in this list. |
java.lang.Object[] |
getArray()
|
int |
getIndexOf(java.lang.Object inValue)
Deprecated. see indexOf |
int |
getSize()
Expose size as a JavaBeans property. |
int |
hashCode()
Obtains a hash code for this list. |
int |
indexOf(java.lang.Object o)
Obtain the first index at which a given object is to be found in this list. |
boolean |
isEmpty()
Test whether this list is empty, that is, if size() == 0. |
java.util.Iterator |
iterator()
Obtain an Iterator over this list, whose sequence is the list order. |
int |
lastIndexOf(java.lang.Object o)
Obtain the last index at which a given object is to be found in this list. |
java.util.ListIterator |
listIterator()
Obtain a ListIterator over this list, starting at the beginning. |
java.util.ListIterator |
listIterator(int index)
Obtain a ListIterator over this list, starting at a given position. |
java.lang.Object |
remove(int index)
Remove the element at a given position in this list (optional operation). |
boolean |
remove(java.lang.Object o)
Remove the first occurence of an object from this list (optional operation). |
boolean |
removeAll(java.util.Collection c)
Remove all elements of a given collection from this list (optional operation). |
boolean |
retainAll(java.util.Collection c)
Remove all elements of this list that are not contained in a given collection (optional operation). |
java.lang.Object |
set(int index,
java.lang.Object element)
Replace an element of this list with another object (optional operation). |
void |
setArray(java.lang.Object[] inContents)
Set contents to the passed Object array and fire a ModelChangeEvent. |
int |
size()
Get the number of elements in this list. |
java.util.List |
subList(int fromIndex,
int toIndex)
Obtain a List view of a subsection of this list, from fromIndex (inclusive) to toIndex (exclusive). |
java.lang.Object[] |
toArray()
Copy the current contents of this list into an array. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Copy the current contents of this list into an array. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class org.scopemvc.model.basic.BasicModel |
addModelChangeListener, fireModelChange, listenNewSubmodel, makeActive, modelChanged, removeModelChangeListener, unlistenOldSubmodel |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
LOG
private static final org.apache.commons.logging.Log LOG
ARRAY
public static final org.scopemvc.core.Selector ARRAY
contents
protected java.lang.Object[] contents
propogateModelChanges
protected boolean propogateModelChanges
TO_STRING_SEPARATOR
protected static final java.lang.String TO_STRING_SEPARATOR
- See Also:
- Constant Field Values
TO_STRING_SEPARATOR_LENGTH
protected static final int TO_STRING_SEPARATOR_LENGTH
| Constructor Detail |
ArrayModel
public ArrayModel()
ArrayModel
public ArrayModel(java.lang.Object[] inArray)
ArrayModel
public ArrayModel(int inSize)
ArrayModel
public ArrayModel(boolean inPropogateModelChanges)
ArrayModel
public ArrayModel(boolean inPropogateModelChanges,
int inSize)
ArrayModel
public ArrayModel(boolean inPropogateModelChanges,
java.lang.Object[] inArray)
| Method Detail |
setArray
public void setArray(java.lang.Object[] inContents)
- Set contents to the passed Object array and fire a ModelChangeEvent.
getArray
public java.lang.Object[] getArray()
getSize
public int getSize()
- Expose size as a JavaBeans property.
getIndexOf
public int getIndexOf(java.lang.Object inValue)
- Deprecated. see indexOf
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
iterator
public java.util.Iterator iterator()
- Description copied from interface:
java.util.List - Obtain an Iterator over this list, whose sequence is the list order.
- Specified by:
iteratorin interfacejava.util.List
size
public int size()
- Description copied from interface:
java.util.List - Get the number of elements in this list. If the list contains more
than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.
- Specified by:
sizein interfacejava.util.List
isEmpty
public boolean isEmpty()
- Description copied from interface:
java.util.List - Test whether this list is empty, that is, if size() == 0.
- Specified by:
isEmptyin interfacejava.util.List
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Description copied from interface:
java.util.List - Copy the current contents of this list into an array. If the array passed
as an argument has length less than that of this list, an array of the
same run-time type as a, and length equal to the length of this list, is
allocated using Reflection. Otherwise, a itself is used. The elements of
this list are copied into it, and if there is space in the array, the
following element is set to null. The resultant array is returned.
Note: The fact that the following element is set to null is only useful
if it is known that this list does not contain any null elements.
- Specified by:
toArrayin interfacejava.util.List
contains
public boolean contains(java.lang.Object o)
- Description copied from interface:
java.util.List - Test whether this list contains a given object as one of its elements.
This is defined as the existence of an element e such that
o == null ? e == null : o.equals(e).- Specified by:
containsin interfacejava.util.List
remove
public boolean remove(java.lang.Object o)
- Description copied from interface:
java.util.List - Remove the first occurence of an object from this list (optional
operation). That is, remove the first element e such that
o == null ? e == null : o.equals(e).- Specified by:
removein interfacejava.util.List
toArray
public java.lang.Object[] toArray()
- Description copied from interface:
java.util.List - Copy the current contents of this list into an array.
- Specified by:
toArrayin interfacejava.util.List
addAll
public boolean addAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Add the contents of a collection to the end of the list (optional
operation). This operation is undefined if this list is modified
during the operation (for example, if you try to insert a list into
itself).
- Specified by:
addAllin interfacejava.util.List
add
public boolean add(java.lang.Object o)
- Description copied from interface:
java.util.List - Add an element to the end of the list (optional operation). If the list
imposes restraints on what can be inserted, such as no null elements,
this should be documented.
- Specified by:
addin interfacejava.util.List
removeAll
public boolean removeAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Remove all elements of a given collection from this list (optional
operation). That is, remove every element e such that c.contains(e).
- Specified by:
removeAllin interfacejava.util.List
containsAll
public boolean containsAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Test whether this list contains every element in a given collection.
- Specified by:
containsAllin interfacejava.util.List
clear
public void clear()
- Description copied from interface:
java.util.List - Clear the list, such that a subsequent call to isEmpty() would return
true (optional operation).
- Specified by:
clearin interfacejava.util.List
addAll
public boolean addAll(int index,
java.util.Collection c)
- Description copied from interface:
java.util.List - Insert the contents of a collection into the list at a given position
(optional operation). Shift all elements at that position to the right
by the number of elements inserted. This operation is undefined if
this list is modified during the operation (for example, if you try
to insert a list into itself).
- Specified by:
addAllin interfacejava.util.List
hashCode
public int hashCode()
- Description copied from interface:
java.util.List - Obtains a hash code for this list. In order to obey the general
contract of the hashCode method of class Object, this value is
calculated as follows:
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode()); }This ensures that the general contract of Object.hashCode() is adhered to.
- Specified by:
hashCodein interfacejava.util.List
retainAll
public boolean retainAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Remove all elements of this list that are not contained in a given
collection (optional operation). That is, remove every element e such
that !c.contains(e).
- Specified by:
retainAllin interfacejava.util.List
set
public java.lang.Object set(int index, java.lang.Object element)
- Description copied from interface:
java.util.List - Replace an element of this list with another object (optional operation).
- Specified by:
setin interfacejava.util.List
equals
public boolean equals(java.lang.Object o)
- Description copied from interface:
java.util.List - Test whether this list is equal to another object. A List is defined to be
equal to an object if and only if that object is also a List, and the two
lists have the same sequence. Two lists l1 and l2 are equal if and only
if
l1.size() == l2.size(), and for every integer n between 0 andl1.size() - 1inclusive,l1.get(n) == null ? l2.get(n) == null : l1.get(n).equals(l2.get(n)).- Specified by:
equalsin interfacejava.util.List
remove
public java.lang.Object remove(int index)
- Description copied from interface:
java.util.List - Remove the element at a given position in this list (optional operation).
Shifts all remaining elements to the left to fill the gap.
- Specified by:
removein interfacejava.util.List
get
public java.lang.Object get(int index)
- Description copied from interface:
java.util.List - Get the element at a given index in this list.
- Specified by:
getin interfacejava.util.List
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Description copied from interface:
java.util.List - Obtain the last index at which a given object is to be found in this
list.
- Specified by:
lastIndexOfin interfacejava.util.List
add
public void add(int index,
java.lang.Object element)
- Description copied from interface:
java.util.List - Insert an element into the list at a given position (optional operation).
This shifts all existing elements from that position to the end one
index to the right. This version of add has no return, since it is
assumed to always succeed if there is no exception.
- Specified by:
addin interfacejava.util.List
listIterator
public java.util.ListIterator listIterator(int index)
- Description copied from interface:
java.util.List - Obtain a ListIterator over this list, starting at a given position.
A first call to next() would return the same as get(index), and a
first call to previous() would return the same as get(index - 1).
- Specified by:
listIteratorin interfacejava.util.List
indexOf
public int indexOf(java.lang.Object o)
- Description copied from interface:
java.util.List - Obtain the first index at which a given object is to be found in this
list.
- Specified by:
indexOfin interfacejava.util.List
listIterator
public java.util.ListIterator listIterator()
- Description copied from interface:
java.util.List - Obtain a ListIterator over this list, starting at the beginning.
- Specified by:
listIteratorin interfacejava.util.List
subList
public java.util.List subList(int fromIndex, int toIndex)
- Description copied from interface:
java.util.List - Obtain a List view of a subsection of this list, from fromIndex
(inclusive) to toIndex (exclusive). If the two indices are equal, the
sublist is empty. The returned list should be modifiable if and only
if this list is modifiable. Changes to the returned list should be
reflected in this list. If this list is structurally modified in
any way other than through the returned list, the result of any subsequent
operations on the returned list is undefined.
- Specified by:
subListin interfacejava.util.List
|
|||||||||
| Home >> All >> org >> scopemvc >> model >> [ collection overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC