kawigi.properties
Class AbstractPrefs

java.lang.Object
  extended by kawigi.properties.AbstractPrefs
All Implemented Interfaces:
PrefProxy
Direct Known Subclasses:
ChainedPrefs, StandAlonePrefs, TCPrefs

public abstract class AbstractPrefs
extends java.lang.Object
implements PrefProxy

This is the superclass of PrefProxy implementations used in KawigiEdit. The purpose here is to reduce duplicated code in converting the string representations of property values into other types. Then, other actually distinct implementations only really need to implement getProperty, setProperty and commit. Note the difference in semantics between this implementation and the way Java's and TopCoder's properties work and the way I want KawigiEdit's properties to work - in other implementations, the default value is just returned if there is no set property. Here I'm setting it if it's not set.


Constructor Summary
AbstractPrefs()
          AbstractPrefs constructor.
 
Method Summary
 boolean getBoolean(java.lang.String property)
          Gets the given property as a boolean value.
 boolean getBoolean(java.lang.String property, boolean defaultValue)
          Gets the given property as a boolean value, setting it to the defaultValue if it isn't set yet.
 java.awt.Color getColor(java.lang.String property)
          Gets the given property as a color.
 java.awt.Color getColor(java.lang.String property, java.awt.Color defaultValue)
          Gets the given property as a color, setting it to defaultValue if it isn't set yet.
 double getDouble(java.lang.String property)
          Gets the given property as a double.
 double getDouble(java.lang.String property, double defaultValue)
          Gets the given property as a double, setting it to defaultValue if it hasn't been set yet.
 java.awt.Font getFont(java.lang.String property)
          Gets the given property as a Font object.
 java.awt.Font getFont(java.lang.String property, java.awt.Font defaultValue)
          Returns the given property as a Font object, setting the property to the value of the default value if it isn't set.
 int getInt(java.lang.String property)
          Gets the given property as an int.
 int getInt(java.lang.String property, int defaultValue)
          Gets the given property as an int, setting the property to defaultValue if it hasn't been set yet.
 java.lang.String getProperty(java.lang.String property, java.lang.String defaultValue)
          Gets the given property, setting it to defaultValue if it isn't set yet.
 java.io.File getWorkingDirectory()
          Returns the value of the "kawigi.localpath" property as a File.
 void setBoolean(java.lang.String property, boolean value)
          Sets a given property to a boolean value.
 void setColor(java.lang.String property, java.awt.Color value)
          Sets the given property to the given Color value.
 void setDouble(java.lang.String property, double value)
          Sets the given property to the given double value.
 void setFont(java.lang.String property, java.awt.Font value)
          Sets the given property to the given Font value.
 void setInt(java.lang.String property, int value)
          Sets the given property to the given integer value.
 void setWorkingDirectory(java.io.File f)
          Sets the "kawigi.localpath" property to the path of the given directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kawigi.properties.PrefProxy
commit, getProperty, setProperty
 

Constructor Detail

AbstractPrefs

public AbstractPrefs()
AbstractPrefs constructor.

Method Detail

getBoolean

public boolean getBoolean(java.lang.String property)
Gets the given property as a boolean value.

Specified by:
getBoolean in interface PrefProxy

getBoolean

public boolean getBoolean(java.lang.String property,
                          boolean defaultValue)
Gets the given property as a boolean value, setting it to the defaultValue if it isn't set yet.

Specified by:
getBoolean in interface PrefProxy

setBoolean

public void setBoolean(java.lang.String property,
                       boolean value)
Sets a given property to a boolean value.

Specified by:
setBoolean in interface PrefProxy

getFont

public java.awt.Font getFont(java.lang.String property)
Gets the given property as a Font object. Note - "property" refers to the property that gives the font face. "property.size" is the property that gives the font size. "property.bold" and "property.italic" are additional style specifications. I don't think there is a way through the UI to set these, but one could technically set some font property to have these styles by modifying the config files directly.

Specified by:
getFont in interface PrefProxy

getFont

public java.awt.Font getFont(java.lang.String property,
                             java.awt.Font defaultValue)
Returns the given property as a Font object, setting the property to the value of the default value if it isn't set.

Specified by:
getFont in interface PrefProxy

setFont

public void setFont(java.lang.String property,
                    java.awt.Font value)
Sets the given property to the given Font value.

Specified by:
setFont in interface PrefProxy

getColor

public java.awt.Color getColor(java.lang.String property)
Gets the given property as a color.

Specified by:
getColor in interface PrefProxy

getColor

public java.awt.Color getColor(java.lang.String property,
                               java.awt.Color defaultValue)
Gets the given property as a color, setting it to defaultValue if it isn't set yet.

Specified by:
getColor in interface PrefProxy

setColor

public void setColor(java.lang.String property,
                     java.awt.Color value)
Sets the given property to the given Color value.

Specified by:
setColor in interface PrefProxy

getInt

public int getInt(java.lang.String property)
Gets the given property as an int.

Specified by:
getInt in interface PrefProxy

getInt

public int getInt(java.lang.String property,
                  int defaultValue)
Gets the given property as an int, setting the property to defaultValue if it hasn't been set yet.

Specified by:
getInt in interface PrefProxy

setInt

public void setInt(java.lang.String property,
                   int value)
Sets the given property to the given integer value.

Specified by:
setInt in interface PrefProxy

getDouble

public double getDouble(java.lang.String property)
Gets the given property as a double.

Specified by:
getDouble in interface PrefProxy

getDouble

public double getDouble(java.lang.String property,
                        double defaultValue)
Gets the given property as a double, setting it to defaultValue if it hasn't been set yet.

Specified by:
getDouble in interface PrefProxy

setDouble

public void setDouble(java.lang.String property,
                      double value)
Sets the given property to the given double value.

Specified by:
setDouble in interface PrefProxy

getProperty

public java.lang.String getProperty(java.lang.String property,
                                    java.lang.String defaultValue)
Gets the given property, setting it to defaultValue if it isn't set yet.

Specified by:
getProperty in interface PrefProxy

getWorkingDirectory

public java.io.File getWorkingDirectory()
Returns the value of the "kawigi.localpath" property as a File. If there is no value for "kawigi.localpath", it will set it to the default "testprograms" directory. If the directory doesn't exist, it will be created.

Specified by:
getWorkingDirectory in interface PrefProxy

setWorkingDirectory

public void setWorkingDirectory(java.io.File f)
Sets the "kawigi.localpath" property to the path of the given directory.

Specified by:
setWorkingDirectory in interface PrefProxy