visualmodeler
Class ResourceModel

Object
  |
  +--Observable
        |
        +--visualmodeler.ResourceModel

public class ResourceModel
extends Observable

ResourceModels stores and creates the resource objects

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

Constructor Summary
ResourceModel()
          Allocates a new ResourceModel object
 
Method Summary
 void createResource(int num, boolean random)
          Creates resources based on a specific number
 String generateCode(String indent)
          Generates a specific Java code for the creation of grid resources
 Vector getAllResourceName()
          Gets the name of all resources
 int getResourceCounter()
          Gets the resource counter
 int getTotalResource()
          Gets the total number of resources
 boolean hasChanged()
          Checks whether one of grid resource properties has changed or not
 void loadXml(org.w3c.dom.NodeList nodeList)
          Loads a specific XML code regarding to grid resource
 void newValue()
          Removes all previous values and starts from fresh
 void removeAllResource()
          Removes all the resources available
 void removeResource(int index)
          Removes a resource for a particular given location number
 String saveFile(String indent)
          Saves grid resource properties into XML format
 void showProperty(int index)
          Shows the property of a particular grid resource
 void showProperty(String value)
          Shows the property of a particular grid resource
 
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

ResourceModel

public ResourceModel()
Allocates a new ResourceModel object

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

getAllResourceName

public Vector getAllResourceName()
Gets the name of all resources

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

getResourceCounter

public int getResourceCounter()
Gets the resource counter

Returns:
resource counter
Pre Condition:
$none
Post Condition:
$result > 0

getTotalResource

public int getTotalResource()
Gets the total number of resources

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

createResource

public void createResource(int num,
                           boolean random)
Creates resources based on a specific number

Parameters:
num - number of resources to be created
random - true if the resource properties need to be random, false otherwise
Pre Condition:
num >= 0
Post Condition:
$none

removeAllResource

public void removeAllResource()
Removes all the resources available

Pre Condition:
$none
Post Condition:
$none

removeResource

public void removeResource(int index)
Removes a resource for a particular given location number

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

showProperty

public void showProperty(int index)
Shows the property of a particular grid resource

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

showProperty

public void showProperty(String value)
Shows the property of a particular grid resource

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

generateCode

public String generateCode(String indent)
Generates a specific Java code for the creation of grid resources

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

saveFile

public String saveFile(String indent)
Saves grid resource properties into XML format

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

hasChanged

public boolean hasChanged()
Checks whether one of grid resource properties has changed or not

Overrides:
hasChanged in class Observable
Returns:
true if it has changed, false otherwise
Pre Condition:
$none
Post Condition:
$none

newValue

public void newValue()
Removes all previous values and starts from fresh

Pre Condition:
$none
Post Condition:
$none

loadXml

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

Parameters:
nodeList - a NodeList object
Throws:
Exception - if error occurs during loading XML
Pre Condition:
nodeList != null
Post Condition:
$none