home *** CD-ROM | disk | FTP | other *** search
- package sun.awt;
-
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.PrintStream;
- import java.io.StringBufferInputStream;
- import java.security.AccessController;
- import java.util.Enumeration;
- import java.util.Properties;
- import java.util.Vector;
-
- final class DebugSettings {
- static final String PREFIX = "awtdebug";
- static final String PROP_FILE = "properties";
- private static final String[] DEFAULT_PROPS = new String[]{"awtdebug.assert=true", "awtdebug.trace=false", "awtdebug.on=true", "awtdebug.ctrace=false"};
- private static DebugSettings instance = null;
- private Properties props = new Properties();
-
- static DebugSettings getInstance() {
- if (instance == null) {
- instance = new DebugSettings();
- }
-
- return instance;
- }
-
- private DebugSettings() {
- (new 1(this)).run();
- }
-
- private synchronized void loadProperties() {
- AccessController.doPrivileged(new 2(this));
- this.println(this);
- }
-
- public String toString() {
- Enumeration var1 = this.props.propertyNames();
- ByteArrayOutputStream var2 = new ByteArrayOutputStream();
- PrintStream var3 = new PrintStream(var2);
- var3.println("------------------");
- var3.println("AWT Debug Settings");
- var3.println("------------------");
-
- while(var1.hasMoreElements()) {
- String var4 = (String)var1.nextElement();
- String var5 = this.props.getProperty(var4, "");
- var3.println(var4 + "=" + var5);
- }
-
- var3.println("------------------");
- return new String(var2.toByteArray());
- }
-
- private void loadDefaultProperties() {
- try {
- for(int var1 = 0; var1 < DEFAULT_PROPS.length; ++var1) {
- StringBufferInputStream var2 = new StringBufferInputStream(DEFAULT_PROPS[var1]);
- this.props.load(var2);
- var2.close();
- }
- } catch (IOException var3) {
- }
-
- }
-
- private void loadFileProperties() {
- String var1 = System.getProperty("awtdebug.properties", "");
- if (var1.equals("")) {
- var1 = System.getProperty("user.home", "") + File.separator + "awtdebug" + "." + "properties";
- }
-
- File var3 = new File(var1);
-
- try {
- this.println("Reading debug settings from '" + var3.getCanonicalPath() + "'...");
- FileInputStream var4 = new FileInputStream(var3);
- this.props.load(var4);
- var4.close();
- } catch (FileNotFoundException var5) {
- this.println("Did not find settings file.");
- } catch (IOException var6) {
- this.println("Problem reading settings, IOException: " + var6.getMessage());
- }
-
- }
-
- private void loadSystemProperties() {
- Properties var1 = System.getProperties();
- Enumeration var2 = var1.propertyNames();
-
- while(var2.hasMoreElements()) {
- String var3 = (String)var2.nextElement();
- String var4 = var1.getProperty(var3, "");
- if (var3.startsWith("awtdebug")) {
- this.props.setProperty(var3, var4);
- }
- }
-
- }
-
- public synchronized boolean getBoolean(String var1, boolean var2) {
- String var3 = this.getString(var1, String.valueOf(var2));
- return var3.equalsIgnoreCase("true");
- }
-
- public synchronized int getInt(String var1, int var2) {
- String var3 = this.getString(var1, String.valueOf(var2));
- return Integer.parseInt(var3);
- }
-
- public synchronized String getString(String var1, String var2) {
- String var3 = "awtdebug." + var1;
- String var4 = this.props.getProperty(var3, var2);
- return var4;
- }
-
- public synchronized Enumeration getPropertyNames() {
- Vector var1 = new Vector();
- Enumeration var2 = this.props.propertyNames();
-
- while(var2.hasMoreElements()) {
- String var3 = (String)var2.nextElement();
- var3 = var3.substring("awtdebug".length() + 1);
- var1.addElement(var3);
- }
-
- return var1.elements();
- }
-
- private void println(Object var1) {
- DebugHelperImpl.printlnImpl(var1.toString());
- }
-
- // $FF: synthetic method
- static void access$000(DebugSettings var0) {
- var0.loadProperties();
- }
-
- // $FF: synthetic method
- static void access$100(DebugSettings var0) {
- var0.loadDefaultProperties();
- }
-
- // $FF: synthetic method
- static void access$200(DebugSettings var0) {
- var0.loadFileProperties();
- }
-
- // $FF: synthetic method
- static void access$300(DebugSettings var0) {
- var0.loadSystemProperties();
- }
- }
-