vc.xml.dom
Class VersionHandler

java.lang.Object
  |
  +--vc.xml.dom.VersionHandler
All Implemented Interfaces:
java.lang.Runnable, VersionHandling

public class VersionHandler
extends java.lang.Object
implements java.lang.Runnable, VersionHandling

VersionHandler is the class of XML subsystem which deals with the maintainance of different versions of a file using an XML file for version content of each file.


Constructor Summary
VersionHandler(java.lang.String fileName)
          Constructs and Initializes the objects from the parameters
 
Method Summary
 void addAnotherVersion(java.lang.String allLinesOfText, java.lang.String versionName, java.lang.String versionComment, java.lang.String versionCreator)
          Obtains the reference DOM document from the reeference XML file and then creates the new version in the document by appending the nex XML content to the existing one.
 void createNewVersion(java.lang.String contentFileName, java.lang.String allLinesOfText, java.lang.String versionName, java.lang.String versionComment, java.lang.String versionCreator, java.lang.String birthTime)
          Obtains the reference DOM document from the reeference XML file and then creates the document from the scratch.
 java.lang.String getLatestVersionName()
          Gets the name of the latest version of a file.
 VersionData[] getMultipleVersionContent(java.lang.String fileID, java.lang.String[] versionNames)
          Gets the XMl content of multiple versions of a file in the XML document.
 void loadXmlFile(boolean referenceXML)
          Checks if a file exists with the file name given in constructor.
 void removeVersion(java.lang.String versionName)
          Obtains the reference DOM document from the reeference XML file and then removes the content of the specified version from the XML document.
 void run()
          This method saves the DOM document by deleating to saveXML() method.
 void saveChanges()
          Saves the changes made to the DOM document in a separate thread by creating a new thread
 void saveXML()
          Saves the existing DOM document into an XML file named after the object's filename variable, using the serialization of DOM document
 void setLatestVersionName(java.lang.String versionName)
          Sets the name of the latest version of a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionHandler

public VersionHandler(java.lang.String fileName)
               throws java.lang.Throwable
Constructs and Initializes the objects from the parameters
Parameters:
fileName - to initialize the field fileName
Method Detail

loadXmlFile

public void loadXmlFile(boolean referenceXML)
                 throws java.lang.Throwable
Checks if a file exists with the file name given in constructor. If exists, loads the DOM document with it's content , if not and if referenceXML is true then loads from the regference document.
Specified by:
loadXmlFile in interface VersionHandling
Parameters:
referenceXML - if true loads the XMl document from the regference file or else from the file given in the constructor

saveXML

public void saveXML()
             throws java.lang.Throwable
Saves the existing DOM document into an XML file named after the object's filename variable, using the serialization of DOM document
Specified by:
saveXML in interface VersionHandling

createNewVersion

public void createNewVersion(java.lang.String contentFileName,
                             java.lang.String allLinesOfText,
                             java.lang.String versionName,
                             java.lang.String versionComment,
                             java.lang.String versionCreator,
                             java.lang.String birthTime)
                      throws java.lang.Throwable
Obtains the reference DOM document from the reeference XML file and then creates the document from the scratch. It creates the xml document based upon the data sent as parameters and then saves that document.
Specified by:
createNewVersion in interface VersionHandling
Parameters:
contentFileName - XML file name which is to be updated with the data of new versiomn
allLinesOfText - XML data with wich the new version is to be created
versionName - Name of the new version
versionComment - Comment or Disription for the new version
versionCreator - Name of the user creating this new version
birthTime - timestamp of the creation of this new version

addAnotherVersion

public void addAnotherVersion(java.lang.String allLinesOfText,
                              java.lang.String versionName,
                              java.lang.String versionComment,
                              java.lang.String versionCreator)
                       throws java.lang.Throwable
Obtains the reference DOM document from the reeference XML file and then creates the new version in the document by appending the nex XML content to the existing one. It creates the xml document based upon the data sent as parameters and then saves that document. Also it wont let the existing XML data get lost.
Specified by:
addAnotherVersion in interface VersionHandling
Parameters:
allLinesOfText - XML data with wich the new version is to be created
versionName - Name of the new version
versionComment - Comment or Disription for the new version
versionCreator - Name of the user creating this new version

removeVersion

public void removeVersion(java.lang.String versionName)
                   throws java.lang.Throwable
Obtains the reference DOM document from the reeference XML file and then removes the content of the specified version from the XML document.
Specified by:
removeVersion in interface VersionHandling
Parameters:
allLinesOfText - XML data with wich the new version is to be created
versionName - Name of the new version
versionComment - Comment or Disription for the new version
versionCreator - Name of the user creating this new version

getMultipleVersionContent

public VersionData[] getMultipleVersionContent(java.lang.String fileID,
                                               java.lang.String[] versionNames)
                                        throws java.lang.Throwable
Gets the XMl content of multiple versions of a file in the XML document.
Specified by:
getMultipleVersionContent in interface VersionHandling
Parameters:
fileID - ID of the file whose version data is to wanted
versionNames - Names of the versions whose content is wanted
Returns:
Returns the XMl content of multiple versions of a file with array of strings where each array element is the content of a aricular version

getLatestVersionName

public java.lang.String getLatestVersionName()
                                      throws java.util.NoSuchElementException
Gets the name of the latest version of a file.
Returns:
Returns the name of the latest version of a file.

setLatestVersionName

public void setLatestVersionName(java.lang.String versionName)
                          throws java.util.NoSuchElementException
Sets the name of the latest version of a file.
Returns:
versionName Name to be set for the latest version of a file.

saveChanges

public void saveChanges()
Saves the changes made to the DOM document in a separate thread by creating a new thread

run

public void run()
This method saves the DOM document by deleating to saveXML() method. This method is for saving the DOM document in a separate thread.
Specified by:
run in interface java.lang.Runnable