org.problets.lib.comm.database
Class DataTranslator

java.lang.Object
  extended by org.problets.lib.comm.database.DataTranslator

public class DataTranslator
extends java.lang.Object

read the structure of the queries from a local file and creates the appropriate queries

Author:
Atanas Frengov

Constructor Summary
DataTranslator(java.lang.String structureFilename)
          The constructor opens the file that contains the translation instructions
 
Method Summary
 java.util.Vector getCommands()
          returns a vector containing strings with commands to insert in each table
static void main(java.lang.String[] args)
           
 AttributeValue parseElement(java.lang.String a_element)
          returns an AttributeValue object containing data from the string argument
 DatabaseRecord parseVectorFromTutor(java.util.Vector vectorFromTutor)
          Put the data from the vector that is send from the tutor to a DatabaseRecord object
 void printTable()
          a function that prints the commands vector
static java.util.Vector readFromLocalFile(java.lang.String path, java.lang.String fileName)
          This method returns a vector containing the contents of a file included with Jar file.
 java.util.Vector returnStructure()
          return a vector with the current structure
 java.util.HashMap translate(java.util.Vector vectorFromTutor)
          Translates the supplied databaseRecord object from the tutor with the translation instructions read from a local file and returns a hash map with all translations
 void trimDataInVector()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataTranslator

public DataTranslator(java.lang.String structureFilename)
The constructor opens the file that contains the translation instructions

Parameters:
structureFilename - the name of the file that contains the translation instructions
Method Detail

returnStructure

public java.util.Vector returnStructure()
return a vector with the current structure

Returns:
a vector with the current structure

getCommands

public java.util.Vector getCommands()
returns a vector containing strings with commands to insert in each table

Parameters:
none -
Returns:
a vector containing strings with commands to insert in each table

translate

public java.util.HashMap translate(java.util.Vector vectorFromTutor)
Translates the supplied databaseRecord object from the tutor with the translation instructions read from a local file and returns a hash map with all translations

Parameters:
vectorFromTutor - the data vector that is supplied by the tutor
Returns:
a HashMap with the translation

readFromLocalFile

public static java.util.Vector readFromLocalFile(java.lang.String path,
                                                 java.lang.String fileName)
This method returns a vector containing the contents of a file included with Jar file. It strips all comments and blank lines from the file.


trimDataInVector

public void trimDataInVector()

parseElement

public AttributeValue parseElement(java.lang.String a_element)
returns an AttributeValue object containing data from the string argument

Parameters:
a_element - a string to be parsed
Returns:
an AttributeValue pair from the parsed string null if no delimiter was found

parseVectorFromTutor

public DatabaseRecord parseVectorFromTutor(java.util.Vector vectorFromTutor)
Put the data from the vector that is send from the tutor to a DatabaseRecord object

Parameters:
vectorFromTutor - the vector that is passed from the tutor
Returns:
a DatabaseRecord object holding all data

printTable

public void printTable()
a function that prints the commands vector


main

public static void main(java.lang.String[] args)