aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/config/ConfigReader.java
diff options
context:
space:
mode:
authorNathan Lasseter <nathan.je.lasseter@googlemail.com>2011-02-20 14:23:52 +0000
committerNathan Lasseter <nathan.je.lasseter@googlemail.com>2011-02-20 14:23:52 +0000
commit1873252f1ec11794092dcaedaed477afc0572da7 (patch)
tree6e1e7fb41122dc49b344f2ff0ed089d942903268 /src/uk/org/ury/config/ConfigReader.java
parent904caa25f8de49cc20823a25ce8051dfdcae7c26 (diff)
Comment, comment, comment! Shout at me if i dont comment. I tend not to.
Diffstat (limited to 'src/uk/org/ury/config/ConfigReader.java')
-rw-r--r--src/uk/org/ury/config/ConfigReader.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/uk/org/ury/config/ConfigReader.java b/src/uk/org/ury/config/ConfigReader.java
index 6b66e24..6166ec4 100644
--- a/src/uk/org/ury/config/ConfigReader.java
+++ b/src/uk/org/ury/config/ConfigReader.java
@@ -10,24 +10,44 @@ import org.xml.sax.SAXParseException;
import uk.org.ury.database.UserClass;
+/**
+ * Reads in an XML config file and creates config objects
+ *
+ * @author Nathan
+ */
public class ConfigReader {
private Database database;
private Auth auth;
+ /**
+ * Get the database configuration
+ *
+ * @return Database database
+ */
public Database getDatabase() { return database; }
+ /**
+ * Get the login auth configuration
+ *
+ * @return Auth auth
+ */
public Auth getAuth() { return auth; }
+ /**
+ * Read in the config file and create the Database and Auth configuration objects.
+ */
public ConfigReader() {
+ new ConfigReader("res/conf.xml");
+ }
+
+ public ConfigReader(String configFile) {
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- Document doc = docBuilder.parse (new File("res/conf.xml"));
+ Document doc = docBuilder.parse (new File(configFile));
doc.getDocumentElement().normalize();
- System.out.println(doc.getDocumentElement().getNodeName());
-
String user = doc.getElementsByTagName("user").item(0).getTextContent();
String pass = doc.getElementsByTagName("pass").item(0).getTextContent();
UserClass type;