All pastes #2093902 Raw Edit

Something

public text v1 · immutable
#2093902 ·published 2011-11-12 00:44 UTC
rendered paste body
package sqlquerygenerator;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Hashtable;

public class DatabaseSchemaInterpreter {

	public Hashtable<String, Hashtable<String, String>> readSchemaFile(
			String fileName) {

		Hashtable<String, Hashtable<String, String>> tableAndColumnNames = new Hashtable<String, Hashtable<String, String>>();		
		
		try {

			String currentLine;
			BufferedReader bReader = new BufferedReader(
					new FileReader(fileName));

			while ((currentLine = bReader.readLine()) != null) {
				String[] currentLineFields = currentLine.split(" ");
				String currentLineTableField = currentLineFields[0];
				String currentLineColNameField = currentLineFields[1];
				String currentLineColTypeField = currentLineFields[2];

				if (!tableAndColumnNames.containsKey(currentLineTableField)) {
					tableAndColumnNames.put(currentLineTableField,
							new Hashtable<String, String>());
				}
				tableAndColumnNames.get(currentLineTableField).put(
						currentLineColNameField, currentLineColTypeField);

			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		return tableAndColumnNames;

	}

}