FileDocCategorySizeDatePackage
Parameters.javaAPI DocExample2312Tue Dec 12 18:58:44 GMT 2000bingo.shared

Parameters

public abstract class Parameters extends Object

Fields Summary
private boolean
DEBUG
private String
propertiesFilename
private String
propertiesDescription
protected Properties
properties
Constructors Summary
protected Parameters(String propertiesFilename, String propertiesDescription)


         
	this.propertiesFilename = propertiesFilename;
	this.propertiesDescription = propertiesDescription;
    
Methods Summary
protected voidgetParameters()

        Properties defaults = new Properties();
        FileInputStream in = null;

	setDefaults(defaults);

        properties = new Properties(defaults);

	try {
	    String folder = System.getProperty("user.home");
	    String filesep = System.getProperty("file.separator");
            in = new FileInputStream(folder
				     + filesep
				     + propertiesFilename);
	    properties.load(in);

	} catch (java.io.FileNotFoundException e) {
	    in = null;
	    ErrorMessages.error("Can't find properties file. " +
				"Using defaults.");
	} catch (java.io.IOException e) {
	    ErrorMessages.error("Can't read properties file. " +
				"Using defaults.");
	} finally {
	    if (in != null) {
		try { in.close(); } catch (java.io.IOException e) { }
		in = null;
	    }
	}

	updateSettingsFromProperties();

    
protected voidsaveParameters()


	updatePropertiesFromSettings();

	if (DEBUG) {
	    System.out.println("Just set properties: " + propertiesDescription);
	    System.out.println(toString());
	}

        FileOutputStream out = null;

	try {
	    String folder = System.getProperty("user.home");
	    String filesep = System.getProperty("file.separator");
            out = new FileOutputStream(folder 
				       + filesep
				       + propertiesFilename);
	    properties.save(out, propertiesDescription);
	} catch (java.io.IOException e) {
	    ErrorMessages.error("Can't save properties. " +
				"Oh well, it's not a big deal.");
	} finally {
	    if (out != null) {
		try { out.close(); } catch (java.io.IOException e) { }
		out = null;
	    }
	}
    
protected abstract voidsetDefaults(java.util.Properties defaults)

protected abstract voidupdatePropertiesFromSettings()

protected abstract voidupdateSettingsFromProperties()