org.bibalex.daf.handlers.statusdatahandler
Class FileLevelInfoHandler

java.lang.Object
  extended by org.bibalex.daf.handlers.statusdatahandler.FileLevelInfoHandler

public class FileLevelInfoHandler
extends java.lang.Object

Contains methods to read and write FileLevelInfo to and from file, String and Nodes.

Author:
Shehab.Kamal

Field Summary
 java.util.ArrayList<FileLevelInfo> information
          Holds the elements defined within this section
 
Constructor Summary
FileLevelInfoHandler()
          Creates a new instance of FileLevelInfoHandler.
 
Method Summary
 void add(FileLevelInfo info)
          Adds the given to the set of information.
private  void createElementFromNode(org.w3c.dom.Node node, boolean append)
          Fills in the FileLevelInfo information by supplying its XmlNode represenation.
 FileLevelInfo get(int index)
          Gets the FileLevelInfo at the given entry.
 int getPhaseWithMinimumSequence(int jobTypeID, boolean includeDoneEntries)
          Gets the phase with the minimum sequence.
Note:
1) FileLevelInfo of type information are ignored.
 void read(java.io.File file, boolean append)
          Parses the given xml file and reads the FileLevelInfo stored in the file.
 void read(org.w3c.dom.Node node, boolean append)
          Reads the FileLevelInfo within the given node.
The node is assumed to be on the following from:
<> <Info From="" To"" Phase="" Reason="" User="" Done="" /> .
 void read(java.lang.String nodeRep, boolean append)
          Parses the given String and reads the FileLevelInfo from it.
 void remove(int index)
          Remove the element specified by the given entry.
 java.lang.String toString()
          Returns the String representation of this instance.
 java.lang.String toXmlString()
          Converts this instance to a valid XML string.
 boolean write(java.lang.String filePath)
          Writes the set of FileLevelInfo to te given file.
Note: 1) The file is written as an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

information

public java.util.ArrayList<FileLevelInfo> information
Holds the elements defined within this section

Constructor Detail

FileLevelInfoHandler

public FileLevelInfoHandler()
Creates a new instance of FileLevelInfoHandler.

Method Detail

read

public void read(java.lang.String nodeRep,
                 boolean append)
          throws FileLevelInfoException
Parses the given String and reads the FileLevelInfo from it.

Parameters:
nodeRep - The Xml String representing this element.
append - Whether to append to the current information or not.
Throws:
FileLevelInfoException - if the given String could not be parsed.

read

public void read(java.io.File file,
                 boolean append)
          throws FileLevelInfoException
Parses the given xml file and reads the FileLevelInfo stored in the file.

Parameters:
file - the XML file to read the data from.
append - Whether to append to the current information or not.
Throws:
FileLevelInfoException - if the given file could not be parsed.

read

public void read(org.w3c.dom.Node node,
                 boolean append)
          throws FileLevelInfoException
Reads the FileLevelInfo within the given node.
The node is assumed to be on the following from:
<> <Info From="" To"" Phase="" Reason="" User="" Done="" /> . </>

Parameters:
node - The node to parse.
append - Whether to append to the current information or not.
Throws:
FileLevelInfoException - If the elments couldn't be created.

createElementFromNode

private void createElementFromNode(org.w3c.dom.Node node,
                                   boolean append)
                            throws FileLevelInfoException
Fills in the FileLevelInfo information by supplying its XmlNode represenation.

Parameters:
node - The Xml Node representing this element.
append - Whether to append to the current information or not.
Throws:
FileLevelInfoException - If a child couldn't be added.

add

public void add(FileLevelInfo info)
Adds the given to the set of information.

Parameters:
info - The FileLevelInfo to add.

remove

public void remove(int index)
Remove the element specified by the given entry.

Parameters:
index - The index of the entry to remove

get

public FileLevelInfo get(int index)
Gets the FileLevelInfo at the given entry.

Parameters:
index - The ondex of the entry to get.
Returns:
The FileLevelInfo at the specified index.

write

public boolean write(java.lang.String filePath)
Writes the set of FileLevelInfo to te given file.
Note: 1) The file is written as an XML file. 2) If a file with the same name already exists, it is overwritten.

Parameters:
filePath - The path of the file to write the information to.
Returns:
True if the file has been written sucessfully otherwise false.

getPhaseWithMinimumSequence

public int getPhaseWithMinimumSequence(int jobTypeID,
                                       boolean includeDoneEntries)
Gets the phase with the minimum sequence.
Note:
1) FileLevelInfo of type information are ignored.

Parameters:
jobTypeID - The ID of the job type. Used to create a Phase object.
includeDoneEntries - Whether to include the entries that have 'Done' = true or not.
Returns:
The ID of the phase with the minimum sequence.
-1 in the follwoing cases:
1) The informaion is null, or empty.
2) Couldn't get the phase from the phase ID.

toString

public java.lang.String toString()
Returns the String representation of this instance.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this instance.

toXmlString

public java.lang.String toXmlString()
Converts this instance to a valid XML string.

Returns:
A valid XML string representing this instance.