merge the formfield patch from ooo-build
[ooovba.git] / toolkit / test / accessibility / Options.java
blob76a2a3b0b55b140c9b006f91b4d3feccb6a456f4
1 import java.io.File;
2 import java.io.FileReader;
3 import java.io.FileInputStream;
4 import java.io.FileOutputStream;
5 import java.util.Properties;
7 /** Load from and save options into a file.
8 */
9 class Options
10 extends Properties
12 static public Options Instance ()
14 if (saOptions == null)
15 saOptions = new Options ();
16 return saOptions;
19 static public void SetString (String sName, String sValue)
21 Instance().setProperty (sName, sValue);
24 static public String GetString (String sName)
26 return Instance().getProperty (sName);
29 static public void SetBoolean (String sName, boolean bValue)
31 Instance().setProperty (sName, Boolean.toString(bValue));
34 static public boolean GetBoolean (String sName)
36 return Boolean.getBoolean(Instance().getProperty (sName));
39 static public void SetInteger (String sName, int nValue)
41 Instance().setProperty (sName, Integer.toString(nValue));
44 static public int GetInteger (String sName, int nDefault)
46 String sValue = Instance().getProperty (sName);
47 if (sValue == null)
48 return nDefault;
49 else
50 return Integer.parseInt (sValue);
53 public void Load (String sBaseName)
55 try
57 load (new FileInputStream (ProvideFile(sBaseName)));
59 catch (java.io.IOException e)
61 // Ignore a non-existing options file.
65 public void Save (String sBaseName)
67 try
69 store (new FileOutputStream (ProvideFile(sBaseName)), null);
71 catch (java.io.IOException e)
76 private Options ()
80 private File ProvideFile (String sBaseName)
82 return new File (
83 System.getProperty ("user.home"),
84 sBaseName);
87 static private Options saOptions = null;