org.xnap.util
Class AbstractPluginPreferences

java.lang.Object
  extended by org.xnap.util.AbstractPluginPreferences
All Implemented Interfaces:
PreferencesProvider, TablePreferencesProvider
Direct Known Subclasses:
AzureusPreferences, GiFTPreferences, JOscarPreferences, JTellaPreferences, LimeWirePreferences, OAVPreferences, OpenNapPreferences, OvernetPreferences, PircBotPreferences, VorbisViewerPreferences, ZipViewerPreferences

public abstract class AbstractPluginPreferences
extends java.lang.Object
implements TablePreferencesProvider

This class acts as a wraper for the Preferences class. It is meant to be extended by plugins that need to store preferences.


Field Summary
protected static org.apache.log4j.Logger logger
           
protected  Preferences prefs
           
static java.lang.String VERSION_KEY
           
 
Constructor Summary
AbstractPluginPreferences(java.lang.String namespace, int version)
          Constructs an AbstractPluginPreference object.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void addPropertyChangeListener(java.lang.String key, java.beans.PropertyChangeListener l)
           
 void addTableListener(java.lang.String table, java.beans.PropertyChangeListener l)
           
 void convert(int oldVersion)
          Convert the preferences from oldVersion.
 java.lang.String get(java.lang.String key)
          Returns the String value to which the specified key is mapped.
 java.lang.String[] getArray(java.lang.String key)
           
 boolean getBoolean(java.lang.String key)
          Returns the boolean value to which the specified key is mapped.
 java.awt.Color getColor(java.lang.String key)
           
 java.awt.Font getFont(java.lang.String key)
           
 int getInt(java.lang.String key)
           
 int[] getIntArray(java.lang.String key)
           
 javax.swing.KeyStroke getKeyStroke(java.lang.String key)
           
 long getLong(java.lang.String key)
           
 boolean getNotShowDialog(java.lang.String dialogName)
           
 java.lang.String[] getTableColumns(java.lang.String table)
          Returns an array of visible columns as an array of column keys.
 int[] getTableColumnWidths(java.lang.String table)
           
 boolean getTableMaintainSortOrder(java.lang.String table)
           
 int getTableSortedColumn(java.lang.String table)
          Returns 0, if no column is sorted, otherwise the model index of the column + 1.
 void removeProperty(java.lang.String key)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void removePropertyChangeListener(java.lang.String key, java.beans.PropertyChangeListener l)
           
 void renameProperty(java.lang.String oldKey, java.lang.String newKey)
          Renames a property, used for conversion of property file formats.
 void set(java.lang.String key, boolean newValue)
           
 void set(java.lang.String key, java.awt.Color newValue)
           
 void set(java.lang.String key, java.awt.Font newValue)
           
 void set(java.lang.String key, int newValue)
           
 void set(java.lang.String key, int[] newValue)
           
 void set(java.lang.String key, javax.swing.KeyStroke newValue)
           
 void set(java.lang.String key, long newValue)
           
 void set(java.lang.String key, java.lang.String newValue)
           
 void set(java.lang.String key, java.lang.String[] newValue)
           
 void setDefault(java.lang.String key, java.lang.String value)
           
 void setDefault(java.lang.String key, java.lang.String value, Validator validator)
           
 void setNotShowDialog(java.lang.String dialogName, boolean newValue)
           
 void setTableColumns(java.lang.String table, java.lang.String[] columns)
          Sets an array of visible columns as an array of column keys.
 void setTableColumnWidths(java.lang.String table, int[] widths)
           
 void setTableMaintainSortOrder(java.lang.String table, boolean enable)
           
 void setTableSortedColumn(java.lang.String table, int column)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_KEY

public static final java.lang.String VERSION_KEY
See Also:
Constant Field Values

logger

protected static org.apache.log4j.Logger logger

prefs

protected Preferences prefs
Constructor Detail

AbstractPluginPreferences

public AbstractPluginPreferences(java.lang.String namespace,
                                 int version)
Constructs an AbstractPluginPreference object. Calls the convert method if neccessary.

Parameters:
namespace - a prefix that is used for each key
version - the current version of the preferences
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface PreferencesProvider

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String key,
                                      java.beans.PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface PreferencesProvider

addTableListener

public void addTableListener(java.lang.String table,
                             java.beans.PropertyChangeListener l)
Specified by:
addTableListener in interface TablePreferencesProvider

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface PreferencesProvider

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String key,
                                         java.beans.PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface PreferencesProvider

convert

public void convert(int oldVersion)
Convert the preferences from oldVersion. The default implementation does nothing. Sub classes should overwrite this method.


get

public java.lang.String get(java.lang.String key)
Description copied from interface: PreferencesProvider
Returns the String value to which the specified key is mapped.

Specified by:
get in interface PreferencesProvider

getNotShowDialog

public boolean getNotShowDialog(java.lang.String dialogName)

getArray

public java.lang.String[] getArray(java.lang.String key)

getBoolean

public boolean getBoolean(java.lang.String key)
Description copied from interface: PreferencesProvider
Returns the boolean value to which the specified key is mapped.

Specified by:
getBoolean in interface PreferencesProvider

getColor

public java.awt.Color getColor(java.lang.String key)

getFont

public java.awt.Font getFont(java.lang.String key)

getInt

public int getInt(java.lang.String key)

getIntArray

public int[] getIntArray(java.lang.String key)

getKeyStroke

public javax.swing.KeyStroke getKeyStroke(java.lang.String key)
Specified by:
getKeyStroke in interface PreferencesProvider

getLong

public long getLong(java.lang.String key)

getTableColumns

public java.lang.String[] getTableColumns(java.lang.String table)
Description copied from interface: TablePreferencesProvider
Returns an array of visible columns as an array of column keys.

Specified by:
getTableColumns in interface TablePreferencesProvider

getTableColumnWidths

public int[] getTableColumnWidths(java.lang.String table)
Specified by:
getTableColumnWidths in interface TablePreferencesProvider

getTableMaintainSortOrder

public boolean getTableMaintainSortOrder(java.lang.String table)
Specified by:
getTableMaintainSortOrder in interface TablePreferencesProvider

getTableSortedColumn

public int getTableSortedColumn(java.lang.String table)
Description copied from interface: TablePreferencesProvider
Returns 0, if no column is sorted, otherwise the model index of the column + 1. If the return value is < 0 the column is sorted descending .

Specified by:
getTableSortedColumn in interface TablePreferencesProvider

removeProperty

public void removeProperty(java.lang.String key)

renameProperty

public void renameProperty(java.lang.String oldKey,
                           java.lang.String newKey)
Renames a property, used for conversion of property file formats. Ignores namespace. Does not fire change event.


set

public void set(java.lang.String key,
                java.lang.String newValue)
Specified by:
set in interface PreferencesProvider

set

public void set(java.lang.String key,
                java.lang.String[] newValue)

set

public void set(java.lang.String key,
                boolean newValue)
Specified by:
set in interface PreferencesProvider

set

public void set(java.lang.String key,
                java.awt.Color newValue)

set

public void set(java.lang.String key,
                java.awt.Font newValue)

set

public void set(java.lang.String key,
                int newValue)

set

public void set(java.lang.String key,
                int[] newValue)

set

public void set(java.lang.String key,
                javax.swing.KeyStroke newValue)
Specified by:
set in interface PreferencesProvider

set

public void set(java.lang.String key,
                long newValue)

setDefault

public void setDefault(java.lang.String key,
                       java.lang.String value,
                       Validator validator)

setDefault

public void setDefault(java.lang.String key,
                       java.lang.String value)

setNotShowDialog

public void setNotShowDialog(java.lang.String dialogName,
                             boolean newValue)

setTableColumns

public void setTableColumns(java.lang.String table,
                            java.lang.String[] columns)
Description copied from interface: TablePreferencesProvider
Sets an array of visible columns as an array of column keys.

Specified by:
setTableColumns in interface TablePreferencesProvider

setTableColumnWidths

public void setTableColumnWidths(java.lang.String table,
                                 int[] widths)
Specified by:
setTableColumnWidths in interface TablePreferencesProvider

setTableMaintainSortOrder

public void setTableMaintainSortOrder(java.lang.String table,
                                      boolean enable)
Specified by:
setTableMaintainSortOrder in interface TablePreferencesProvider

setTableSortedColumn

public void setTableSortedColumn(java.lang.String table,
                                 int column)
Specified by:
setTableSortedColumn in interface TablePreferencesProvider


Copyright © 2001-2005 XNap Team. All Rights Reserved.