com.anthonyeden.lib
Class Preferences

java.lang.Object
  extended bycom.anthonyeden.lib.Preferences

public class Preferences
extends java.lang.Object

Base class for user preferences. Applications can extend this base class to provide extended user preferences.

Methods which alter a preference should fire a PropertyChange event.

Author:
Anthony Eden

Field Summary
static java.lang.String LOOK_AND_FEEL
          The Look and Feel property name.
 
Constructor Summary
Preferences()
          Construct a Preferences object.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener.
 java.lang.String getLookAndFeelClassName()
          Get the preferred look and feel class name.
 void load(Configuration configuration)
          Load the preferences from the given root element.
 void load(java.io.File file)
          Load the preferences from the given file.
 void load(org.apache.commons.vfs.FileObject file)
          Load the preferences from the given file.
 void load(java.lang.String id, java.io.InputStream in)
          Load the preferences from the given InputStream.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener.
 void save(java.io.File file)
          Save the current configuration to the given file.
 void save(org.apache.commons.vfs.FileObject file)
          Save the current configuration to the given file.
 void save(MutableConfiguration configuration)
          Save the preferences to the given root XML Element.
 void save(java.lang.String id, java.io.OutputStream out)
          Save the preferences to the given OutputStream.
 void setLookAndFeelClassName(java.lang.String lookAndFeelClassName)
          Set the preferred look and feel class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOOK_AND_FEEL

public static final java.lang.String LOOK_AND_FEEL
The Look and Feel property name.

See Also:
Constant Field Values
Constructor Detail

Preferences

public Preferences()
Construct a Preferences object.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener.

Parameters:
l - The PropertyChangeListener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener.

Parameters:
l - The PropertyChangeListener

getLookAndFeelClassName

public java.lang.String getLookAndFeelClassName()
Get the preferred look and feel class name. If no preferred look and feel is specified, then the System look and feel will be used.

Returns:
The preferred look and feel class name

setLookAndFeelClassName

public void setLookAndFeelClassName(java.lang.String lookAndFeelClassName)
Set the preferred look and feel class name.

Parameters:
lookAndFeelClassName - The new preferred look and feel class name

load

public void load(java.io.File file)
          throws java.lang.Exception
Load the preferences from the given file.

Parameters:
file - The file
Throws:
java.lang.Exception - Any exception
See Also:
load(String id, InputStream in)

load

public void load(org.apache.commons.vfs.FileObject file)
          throws java.lang.Exception
Load the preferences from the given file.

Parameters:
file - The file
Throws:
java.lang.Exception - Any exception
See Also:
load(String id, InputStream in)

load

public void load(java.lang.String id,
                 java.io.InputStream in)
          throws java.lang.Exception
Load the preferences from the given InputStream. The stream must be an XML stream. Subclasses can overload the load(Element element) method to obtain preference configuration information. Subclasses must call super.load(Element element) if they override this method so that standard preferences are properly loaded.

Parameters:
id - The source id
in - The InputStream
Throws:
java.lang.Exception - Any exception

load

public void load(Configuration configuration)
          throws java.lang.Exception
Load the preferences from the given root element. Subclasses can overload this method to obtain preference configuration information. Subclasses must call super.load(Configuration configuration) if they override this method so that standard preferences are properly loaded.

Parameters:
configuration - The configuration element
Throws:
java.lang.Exception - Any Exception

save

public void save(java.io.File file)
          throws java.lang.Exception
Save the current configuration to the given file.

Parameters:
file - The file to save to
Throws:
java.lang.Exception

save

public void save(org.apache.commons.vfs.FileObject file)
          throws java.lang.Exception
Save the current configuration to the given file.

Parameters:
file - The file to save to
Throws:
java.lang.Exception

save

public void save(java.lang.String id,
                 java.io.OutputStream out)
          throws java.lang.Exception
Save the preferences to the given OutputStream. Subclasses can overload the save(Element element) method to store preference configuration information to the root XML element. Subclasses must call super.save(Element element) if they override this method so that standard preferences are properly stored.

Parameters:
out - The OutputStream
Throws:
java.lang.Exception - Any exception

save

public void save(MutableConfiguration configuration)
          throws java.lang.Exception
Save the preferences to the given root XML Element. Subclasses can overload this method to store preference configuration information to the root XML element. Subclasses must call super.save(MutableConfiguration configuration) if they override this method so that standard preferences are properly stored.

Parameters:
configuration - The MutableConfiguration object
Throws:
java.lang.Exception


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.