org.peace_tools.workspace
Class JobList

java.lang.Object
  extended by org.peace_tools.workspace.JobList

public class JobList
extends java.lang.Object

A class to encapsulate information about a list of jobs that have already been configured in this work space. This class is instantiated from the work space class. This class is relatively straightforward in that it merely contains a list of Job objects. In addition, it facilitates marshalling and unmarshalling of job data.


Field Summary
private  java.util.ArrayList<Job> jobs
          The list of job objects that have been configured and added to this list.
private  long seqCounter
          Sequence counter that is maintained on a per-work space basis to generate unique/valid IDs for each new job entry added to this list.
 
Constructor Summary
JobList()
          The default constructor.
 
Method Summary
 void add(Job job)
          Method to add a new job entry to the job list.
static JobList create(org.w3c.dom.Element jobListNode)
          Helper method to utilize data from a DOM tree to create a suitable JobList entry.
 Job getjob(java.lang.String jobID)
          Obtain reference to a job object, given its work space wide unique job ID.
 java.util.ArrayList<Job> getJobs()
          Obtain the list of job objects that are currently available in a work space.
 void marshall(org.w3c.dom.Element workspace)
          Method to marshall the data stored in this object to become part of a DOM tree element passed in.
 void marshall(java.io.PrintWriter out)
          Method to marshall the data stored in this object directly to a XML fragment.
 void remove(Job job)
          Method to remove a job entry.
 java.lang.String reserveJobID()
          Reserves the next job ID for use in a job object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobs

private java.util.ArrayList<Job> jobs
The list of job objects that have been configured and added to this list. This list is populated either via the create method or new entries are added via the addjob() method in this class.


seqCounter

private long seqCounter
Sequence counter that is maintained on a per-work space basis to generate unique/valid IDs for each new job entry added to this list.

Constructor Detail

JobList

public JobList()
The default constructor. It merely initializes all the instance variables to their default initial value.

Method Detail

create

public static JobList create(org.w3c.dom.Element jobListNode)
                      throws java.lang.Exception
Helper method to utilize data from a DOM tree to create a suitable JobList entry. This method is typically used to create a suitable JobList entry using data from a given DOM element. For each Server entry this method uses the Job.create method to create suitable Job objects.

Parameters:
jobListNode - The DOM element to be used for creating the job list and to be used for creating the Job entries.
Returns:
The newly created JobList entry based on the DOM data.
Throws:
java.lang.Exception - This method throws an exception when errors occur during reading and processing elements from the DOM node.

reserveJobID

public java.lang.String reserveJobID()
Reserves the next job ID for use in a job object. This method is used only when a new job object is added by the user. job objects loaded from a file have their own job IDs.

Returns:
A new, unique (within the work space) job ID for use with a new job object instance.

getjob

public Job getjob(java.lang.String jobID)
Obtain reference to a job object, given its work space wide unique job ID. This method does a linear search on the jobList to locate the job entry (if you have 1000s of job entries in one workspace then you are missing the concept of a workspace).

Parameters:
jobID - The generated work space wide unique job ID. Note that checks are case sensitive.
Returns:
Reference to a job object whose jobID is the same as the supplied jobID. If a matching object was not found then this method returns null.

add

public void add(Job job)
Method to add a new job entry to the job list. This method adds the specified job to the job list and fires a WorkspaceEvent indicating the addition of the new entry to all listeners.

Parameters:
job - The new job entry to be added to the job list.

remove

public void remove(Job job)
Method to remove a job entry. This method removes the given job entry from the job list and fires a WorkspaceEvent indicating the removal of the job entry to all listeners.

Note: This method does not delete any of the files associated with the job. It simply removes the job entry from the work space.

Parameters:
job - The job entry to be removed from the job list.

getJobs

public java.util.ArrayList<Job> getJobs()
Obtain the list of job objects that are currently available in a work space.

Returns:
The list of job objects that are currently available in this work space.

marshall

public final void marshall(org.w3c.dom.Element workspace)
Method to marshall the data stored in this object to become part of a DOM tree element passed in. This method assumes that the element passed in corresponds to the parent Workspace node in the DOM tree.

Parameters:
workspace - The DOM element corresponding to the Workspace node that contains this entry.

marshall

public final void marshall(java.io.PrintWriter out)
Method to marshall the data stored in this object directly to a XML fragment. The XML fragment is guaranteed to be compatible with the PEACE work space configuration data. This method provides better control on the XML formatting to generate a more readable XML output when compared to the DOM tree.

Parameters:
out - The stream to which the XML must be serialized.