visualmodeler
Class UserModel

Object
  extended byObservable
      extended byvisualmodeler.UserModel

public class UserModel
extends Observable

UserModel stores and creates the user objects

Version:
1.1
Author:
Anthony Sulistio and Chee Shin Yeo
Invariant:
$none

Constructor Summary
UserModel()
          Allocates a new UserModel object
 
Method Summary
 void createUser(int num, boolean random)
          Creates a given number of grid users
 String generateCode(String indent)
          Generates a Java code regarding to grid users
 Vector getAllUserName()
          Gets all grid user names
 int getTotalUser()
          Gets the total number of grid users
 int getUserCounter()
          Gets the grid user counter
 boolean hasChanged()
          Checks whether the properties of grid user has changed or not
 void loadXml(org.w3c.dom.NodeList nodeList)
          Loads a XML code regarding to grid users
 void newValue()
          Deletes all existing values and starts fresh
 void removeAllUser()
          Removes all grid users
 void removeUser(int index)
          Remoes a grid user at a given location in a data structure
 String saveFile(String indent)
          Generates a XML code regarding to grid users
 void showProperty(int index)
          Shows the dialog properties of a given grid user
 void showProperty(String value)
          Shows the dialog properties of a given grid user
 
Methods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserModel

public UserModel()
Allocates a new UserModel object

Pre Condition:
$none
Post Condition:
$none
Method Detail

getAllUserName

public Vector getAllUserName()
Gets all grid user names

Returns:
a list of names in Vector object
Pre Condition:
$none
Post Condition:
$result != null

getUserCounter

public int getUserCounter()
Gets the grid user counter

Returns:
a counter
Pre Condition:
$none
Post Condition:
$result >= 0

getTotalUser

public int getTotalUser()
Gets the total number of grid users

Returns:
total number
Pre Condition:
$none
Post Condition:
$result >= 0

createUser

public void createUser(int num,
                       boolean random)
Creates a given number of grid users

Parameters:
num - how many grid users to be created
random - a flag to indicate whether random values are needed or not
Pre Condition:
num >= 0
Post Condition:
$none

removeAllUser

public void removeAllUser()
Removes all grid users

Pre Condition:
$none
Post Condition:
$none

removeUser

public void removeUser(int index)
Remoes a grid user at a given location in a data structure

Parameters:
index - location in a data structure
Pre Condition:
index >= 0
Post Condition:
$none

showProperty

public void showProperty(int index)
Shows the dialog properties of a given grid user

Parameters:
index - location in a data structure
Pre Condition:
index >= 0
Post Condition:
$none

showProperty

public void showProperty(String value)
Shows the dialog properties of a given grid user

Parameters:
value - a grid user name
Pre Condition:
value != null
Post Condition:
$none

generateCode

public String generateCode(String indent)
Generates a Java code regarding to grid users

Parameters:
indent - indentation
Returns:
a Java code in String object
Pre Condition:
indent != null
Post Condition:
$result != null

saveFile

public String saveFile(String indent)
Generates a XML code regarding to grid users

Parameters:
indent - indentation
Returns:
a XML code in String object
Pre Condition:
indent != null
Post Condition:
$result != null

hasChanged

public boolean hasChanged()
Checks whether the properties of grid user has changed or not

Returns:
true if it has changed, false otherwise
Pre Condition:
$none
Post Condition:
$none

newValue

public void newValue()
Deletes all existing values and starts fresh

Pre Condition:
$none
Post Condition:
$none

loadXml

public void loadXml(org.w3c.dom.NodeList nodeList)
             throws Exception
Loads a XML code regarding to grid users

Parameters:
nodeList - a NodeList object
Throws:
Exception - if error occurs on reading or parsing XML code
Pre Condition:
nodeList != null
Post Condition:
$none