com.transjam.client
Class ModelProxy
java.lang.Object
|
+--java.util.Observable
|
+--com.transjam.client.ModelProxy
- All Implemented Interfaces:
- java.util.Observer
- public abstract class ModelProxy
- extends java.util.Observable
- implements java.util.Observer
Interface for controlling a Model in a collaborative system.
This Proxy sits between the Delegate and the actual Model.
When the local Model is changed it will call notifyObservers()
which will call the update() method. The update() method will send a
modifyThing() message to the server if owned.
When the Proxy receives a modifyThing messages for the server, it decodes
it and applies it to the local model if NOT owned.
This one-way messaging prevents endless updates in a loop.
- Author:
- (C) 1997-2001 Phil Burk, SoftSynth.com, All Rights Reserved
Constructor Summary |
ModelProxy(Client pClient,
java.util.Observable pModel,
java.lang.String pThingName)
|
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 |
ModelProxy
public ModelProxy(Client pClient,
java.util.Observable pModel,
java.lang.String pThingName)
throws java.io.IOException
serverDeniedLock
public void serverDeniedLock(int uid)
throws java.io.IOException
serverAskedForLock
public void serverAskedForLock()
throws java.io.IOException
encodeModelData
public abstract java.lang.String encodeModelData()
throws java.io.IOException
- Encode note information for server as a String.
decodeModelData
public abstract void decodeModelData(java.lang.String noteInfo)
throws java.io.IOException
- Decode note information from server and set Model.
start
public void start()
throws java.io.IOException
stop
public void stop()
throws java.io.IOException
requestLock
public void requestLock()
unlock
public void unlock()
update
public void update(java.util.Observable o,
java.lang.Object arg)
- Called by model when it changes so that we can update corresponding Thing on server.
- Specified by:
update
in interface java.util.Observer
getOwnerName
public java.lang.String getOwnerName()
- On networked systems, things may be owned by other persons.
- Returns:
- name of owner or "nobody" if networked.
getOwnerID
public int getOwnerID()
- Returns:
- user ID of owner. 0 if unowned.
isOwned
public boolean isOwned()
getModel
public java.util.Observable getModel()
getThingName
public java.lang.String getThingName()
getClient
public Client getClient()
modifyThing
public void modifyThing()
changed
public void changed()