Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.robrohan.tools
Class ConfigFile  view ConfigFile download ConfigFile.java

java.lang.Object
  extended bycom.robrohan.tools.ConfigFile

public class ConfigFile
extends java.lang.Object

This is used to read simple xml config documents and either just get the DOM or allow access to specific values.


Field Summary
private  org.w3c.dom.Document document
           
 java.lang.String DOMFactory
          Which dom factory to use
private  java.lang.String filename
           
 
Constructor Summary
ConfigFile()
          Creates a new instance of ConfigFile
ConfigFile(java.lang.String path)
          Creates a new config file object using the passed file name
 
Method Summary
 org.w3c.dom.Document getDOM()
          Get the raw DOM
 java.lang.String getFileName()
          Returns the current file URI
 int getLength(java.lang.String key)
          Returns the number of times "key" is found in the config file
 java.lang.String getValue(java.lang.String key, int iteration)
          Gets a value from the file
 void openFile()
          Opens the file that was set using setFile or on object creation
 void saveFile()
          Saves the config file if possible
 void setFileName(java.lang.String path)
          Sets the config file URI to a new file
 void setValue(java.lang.String key, int iteration, java.lang.String newValue)
          Changes the value of a key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOMFactory

public java.lang.String DOMFactory
Which dom factory to use


filename

private java.lang.String filename

document

private org.w3c.dom.Document document
Constructor Detail

ConfigFile

public ConfigFile()
Creates a new instance of ConfigFile


ConfigFile

public ConfigFile(java.lang.String path)
           throws java.lang.Exception,
                  javax.xml.parsers.FactoryConfigurationError
Creates a new config file object using the passed file name

Method Detail

setFileName

public void setFileName(java.lang.String path)
Sets the config file URI to a new file


getFileName

public java.lang.String getFileName()
Returns the current file URI


openFile

public void openFile()
              throws java.lang.Exception,
                     javax.xml.parsers.FactoryConfigurationError
Opens the file that was set using setFile or on object creation


saveFile

public void saveFile()
Saves the config file if possible


getLength

public int getLength(java.lang.String key)
Returns the number of times "key" is found in the config file


getValue

public java.lang.String getValue(java.lang.String key,
                                 int iteration)
Gets a value from the file


setValue

public void setValue(java.lang.String key,
                     int iteration,
                     java.lang.String newValue)
Changes the value of a key


getDOM

public org.w3c.dom.Document getDOM()
Get the raw DOM