Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.scopemvc.model.collection
Class SetModel  view SetModel download SetModel.java

java.lang.Object
  extended byorg.scopemvc.model.basic.BasicModel
      extended byorg.scopemvc.model.collection.SetModel
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, org.scopemvc.core.ModelChangeEventSource, org.scopemvc.core.ModelChangeListener, org.scopemvc.core.ModelChangeTypes, java.util.Set

public class SetModel
extends org.scopemvc.model.basic.BasicModel
implements java.util.Set

A BasicModel wrapper for an Set that can propogate changes to contained Models up the Model hierarchy. The set itself is exposed via the "set" property, however, changes to this underlying set must be made through this class's public API in order to maintain the event propogation.

By default SetModel registers itself as a listener to Models that are added to the list and deregisters when those Models are removed. This behaviour can be changed at creation so that ModelChangeEvent propogation from contained models is disabled.

Version:
$Revision: 1.6 $

Field Summary
protected  java.util.Set contents
           
private static org.apache.commons.logging.Log LOG
           
protected  boolean propogateModelChanges
           
static org.scopemvc.core.Selector SET
           
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
SetModel()
           
SetModel(boolean inPropogateModelChanges)
           
SetModel(boolean inPropogateModelChanges, java.util.Set inSet)
           
SetModel(java.util.Set inSet)
           
 
Method Summary
 boolean add(java.lang.Object o)
          Adds the specified element to the set if it is not already present (optional operation).
 boolean addAll(java.util.Collection c)
          Adds all of the elements of the given collection to this set (optional operation).
 void clear()
          Removes all elements from this set (optional operation).
 boolean contains(java.lang.Object arg0)
          Returns true if the set contains the specified element.
 boolean containsAll(java.util.Collection arg0)
          Returns true if this set contains all elements in the specified collection.
 boolean equals(java.lang.Object o)
          Compares the specified object to this for equality.
 java.util.Set getSet()
           
 int getSize()
           
 int hashCode()
          Returns the hash code for this set.
 boolean isEmpty()
          Returns true if the set contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the set.
 void modelChanged(org.scopemvc.core.ModelChangeEvent inEvent)
           Handle changes to children ModelChangeEventSources by firing a change event from this (and propogating the original Selector).
 boolean remove(java.lang.Object o)
          Removes the specified element from this set (optional operation).
 boolean removeAll(java.util.Collection c)
          Removes from this set all elements contained in the specified collection (optional operation).
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this set that are also in the specified collection (optional operation).
 void setSet(java.util.Set inContents)
          Set contents to the passed Object list and fire a ModelChangeEvent.
 int size()
          Returns the number of elements in the set.
 java.lang.Object[] toArray()
          Returns an array containing the elements of this set.
 java.lang.Object[] toArray(java.lang.Object[] arg0)
          Returns an array containing the elements of this set, of the same runtime type of the argument.
 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, 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

SET

public static final org.scopemvc.core.Selector SET

contents

protected java.util.Set 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

SetModel

public SetModel()

SetModel

public SetModel(java.util.Set inSet)

SetModel

public SetModel(boolean inPropogateModelChanges)

SetModel

public SetModel(boolean inPropogateModelChanges,
                java.util.Set inSet)
Method Detail

setSet

public void setSet(java.util.Set inContents)
Set contents to the passed Object list and fire a ModelChangeEvent.


getSet

public java.util.Set getSet()

getSize

public int getSize()

modelChanged

public void modelChanged(org.scopemvc.core.ModelChangeEvent inEvent)
Description copied from class: org.scopemvc.model.basic.BasicModel

Handle changes to children ModelChangeEventSources by firing a change event from this (and propogating the original Selector). If the event's source is no longer a child property of this parent then there is no need to continue propogating the event.

Specified by:
modelChanged in interface org.scopemvc.core.ModelChangeEventSource

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()).


size

public int size()
Description copied from interface: java.util.Set
Returns the number of elements in the set. If there are more than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE. This is the cardinality of the set.

Specified by:
size in interface java.util.Set

isEmpty

public boolean isEmpty()
Description copied from interface: java.util.Set
Returns true if the set contains no elements.

Specified by:
isEmpty in interface java.util.Set

contains

public boolean contains(java.lang.Object arg0)
Description copied from interface: java.util.Set
Returns true if the set contains the specified element. In other words, this looks for o == null ? e == null : o.equals(e).

Specified by:
contains in interface java.util.Set

iterator

public java.util.Iterator iterator()
Description copied from interface: java.util.Set
Returns an iterator over the set. The iterator has no specific order, unless further specified.

Specified by:
iterator in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Description copied from interface: java.util.Set
Returns an array containing the elements of this set. If the set makes a guarantee about iteration order, the array has the same order. The array is distinct from the set; modifying one does not affect the other.

Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] arg0)
Description copied from interface: java.util.Set
Returns an array containing the elements of this set, of the same runtime type of the argument. If the given set is large enough, it is reused, and null is inserted in the first unused slot. Otherwise, reflection is used to build a new array. If the set makes a guarantee about iteration order, the array has the same order. The array is distinct from the set; modifying one does not affect the other.

Specified by:
toArray in interface java.util.Set

containsAll

public boolean containsAll(java.util.Collection arg0)
Description copied from interface: java.util.Set
Returns true if this set contains all elements in the specified collection. If the argument is also a set, this is the subset relationship.

Specified by:
containsAll in interface java.util.Set

add

public boolean add(java.lang.Object o)
Description copied from interface: java.util.Set
Adds the specified element to the set if it is not already present (optional operation). In particular, the comparison algorithm is o == null ? e == null : o.equals(e). Sets need not permit all values, and may document what exceptions will be thrown if a value is not permitted.

Specified by:
add in interface java.util.Set

remove

public boolean remove(java.lang.Object o)
Description copied from interface: java.util.Set
Removes the specified element from this set (optional operation). If an element e exists, o == null ? e == null : o.equals(e), it is removed from the set.

Specified by:
remove in interface java.util.Set

addAll

public boolean addAll(java.util.Collection c)
Description copied from interface: java.util.Set
Adds all of the elements of the given collection to this set (optional operation). If the argument is also a Set, this returns the mathematical union of the two. The behavior is unspecified if the set is modified while this is taking place.

Specified by:
addAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection c)
Description copied from interface: java.util.Set
Retains only the elements in this set that are also in the specified collection (optional operation). If the argument is also a set, this performs the intersection of the two sets.

Specified by:
retainAll in interface java.util.Set

removeAll

public boolean removeAll(java.util.Collection c)
Description copied from interface: java.util.Set
Removes from this set all elements contained in the specified collection (optional operation). If the argument is a set, this returns the asymmetric set difference of the two sets.

Specified by:
removeAll in interface java.util.Set

clear

public void clear()
Description copied from interface: java.util.Set
Removes all elements from this set (optional operation). This set will be empty afterwords, unless an exception occurs.

Specified by:
clear in interface java.util.Set

equals

public boolean equals(java.lang.Object o)
Description copied from interface: java.util.Set
Compares the specified object to this for equality. For sets, the object must be a set, the two must have the same size, and every element in one must be in the other.

Specified by:
equals in interface java.util.Set

hashCode

public int hashCode()
Description copied from interface: java.util.Set
Returns the hash code for this set. In order to satisfy the contract of equals, this is the sum of the hashcode of all elements in the set.

Specified by:
hashCode in interface java.util.Set