org.gjt.sp.jedit
Class SettingsXML

java.lang.Object
  extended by org.gjt.sp.jedit.SettingsXML

public class SettingsXML
extends java.lang.Object

A XML file in the settings directory. This class provides some common operations to load/save settings from/into a XML file. - Proper encoding and XML declaration. - Two stage save. - Making backup on each save. - Detection of change on disk.


Nested Class Summary
 class SettingsXML.Saver
          A Writer to write XML for saving.
 
Constructor Summary
SettingsXML(java.io.File f)
           
SettingsXML(java.lang.String settingsDirectory, java.lang.String name)
          Construct a SettingsXML with specific location and name.
 
Method Summary
 boolean fileExists()
          Returns true if the file exists.
 boolean hasChangedOnDisk()
          Returns true if the file has been changed on disk.
 void load(org.xml.sax.helpers.DefaultHandler handler)
          Parse the XML file to load.
 SettingsXML.Saver openSaver()
          Open the file to save in XML.
 java.lang.String toString()
          Returns the file's path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SettingsXML

public SettingsXML(java.lang.String settingsDirectory,
                   java.lang.String name)
Construct a SettingsXML with specific location and name.

Parameters:
settingsDirectory - The settings directory of jedit
name - The file name will be (name + ".xml")

SettingsXML

public SettingsXML(java.io.File f)
Method Detail

fileExists

public boolean fileExists()
Returns true if the file exists.


load

public void load(org.xml.sax.helpers.DefaultHandler handler)
          throws java.io.IOException
Parse the XML file to load.

Parameters:
handler - The handler to receive SAX notifications.
Throws:
java.io.IOException

openSaver

public SettingsXML.Saver openSaver()
                            throws java.io.IOException
Open the file to save in XML.

Throws:
java.io.IOException

hasChangedOnDisk

public boolean hasChangedOnDisk()
Returns true if the file has been changed on disk. This is based on the last modified time at the last saving or loading.


toString

public java.lang.String toString()
Returns the file's path.

Overrides:
toString in class java.lang.Object