unsw.cse.mica.tools.proxy
Class ProxySet

java.lang.Object
  extended by java.util.Observable
      extended by unsw.cse.mica.tools.proxy.ProxySet
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.Set

public abstract class ProxySet
extends java.util.Observable
implements java.util.Set

A Proxy Set is a collection of proxy objects that reside on the server. An update request can be sent to the server to make the Proxy objects within this set update themselves, with new objects added and old ones removed. The set is defined using a MicaQL query.

Author:
Mark Reid

Constructor Summary
ProxySet()
           
 
Method Summary
 boolean add(java.lang.Object obj)
          Adding an Proxy object to a ProxySet will write that object, as a Mob, to the server.
 boolean addAll(java.util.Collection collection)
          Add a collection of Proxy objects to this set, writing any new objects to the server.
 void addMob(Mob m)
          This method wraps the given Mob in a Proxy object and adds it to this set.
 void clear()
          Clear the set by asking each proxy's mob to be deleted from the server.
 boolean contains(java.lang.Object proxy)
           
 boolean containsAll(java.util.Collection collection)
           
 Proxy createMember()
          Create a new Proxy object for this set whose Mob has the same type as getType().
abstract  Proxy createMember(Mob mob)
           
 void deleteMob(Mob m)
          Deletes the Proxy that contains this Mob from the set.
 Proxy get(java.lang.String name)
          Get the Proxy in this set with the given name.
abstract  java.lang.String getType()
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 void refresh()
          Clears the current collection of proxies and rereads all of them from the server.
 boolean remove(java.lang.Object proxy)
          Removes the given proxy object from this ProxySet, if it exists, and also sends a request to the server to delete the Mob corresponding to the Proxy object deleted.
 boolean removeAll(java.util.Collection collection)
           
 boolean retainAll(java.util.Collection collection)
           
 void setAgent(ProxyAgent agent)
           
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] arg0)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

ProxySet

public ProxySet()
Method Detail

getType

public abstract java.lang.String getType()

createMember

public abstract Proxy createMember(Mob mob)

createMember

public Proxy createMember()
Create a new Proxy object for this set whose Mob has the same type as getType(). This method simply calls the abstract method createMemeber(Mob m) with a new, empty, typed mob.


setAgent

public void setAgent(ProxyAgent agent)

get

public Proxy get(java.lang.String name)
Get the Proxy in this set with the given name.

Parameters:
name - A mob name for the Proxy to get.
Returns:
A Proxy object for the given name if it exists, or null otherwise.

add

public boolean add(java.lang.Object obj)
Adding an Proxy object to a ProxySet will write that object, as a Mob, to the server.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Returns:
true iff the object did not already exist in this set and was sucessfully added.

addMob

public void addMob(Mob m)
This method wraps the given Mob in a Proxy object and adds it to this set.

Parameters:
m - The Mob to add.

deleteMob

public void deleteMob(Mob m)
Deletes the Proxy that contains this Mob from the set.

Parameters:
m - The Mob whose Proxy should be deleted from this set.

addAll

public boolean addAll(java.util.Collection collection)
Add a collection of Proxy objects to this set, writing any new objects to the server.

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set
Returns:
true iff a new element was added to this set.

clear

public void clear()
Clear the set by asking each proxy's mob to be deleted from the server. Each time this is successful, remove the proxy from the map

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set

remove

public boolean remove(java.lang.Object proxy)
Removes the given proxy object from this ProxySet, if it exists, and also sends a request to the server to delete the Mob corresponding to the Proxy object deleted.

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Parameters:
proxy - the Proxy object to be deleted from this set and the server
Returns:
true iff the Proxy was removed

removeAll

public boolean removeAll(java.util.Collection collection)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection collection)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set

contains

public boolean contains(java.lang.Object proxy)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set

containsAll

public boolean containsAll(java.util.Collection collection)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.Set

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.Set

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] arg0)
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

refresh

public void refresh()
Clears the current collection of proxies and rereads all of them from the server.