org.mozilla.jrex.pref
Class JRexPreference

java.lang.Object
  |
  +--org.mozilla.jrex.pref.JRexPreference

public class JRexPreference
extends Object

JRexPreference wraps the nsIPref. This class is used read and write embedded engine Preferences.

Version:
1.0
Author:
C.N.Medappa

Field Summary
static int PREF_BOOL
          A contant representing boolean preference type
static int PREF_INT
          A contant representing int preference type
static int PREF_INVALID
          A contant representing invalid preference type
static int PREF_STRING
          A contant representing string preference type
 
Method Summary
 void clearUserPref(String prefName)
          Called to clear a user set value from a specific preference.
 boolean getBoolPref(String prefName)
          Called to get the state of an individual boolean preference.
 String getCharPref(String prefName)
          Called to get the state of an individual string preference.
 boolean getDefaultBoolPref(String prefName)
          Called to get the state of an Default individual boolean preference.
 String getDefaultCharPref(String prefName)
          Called to get the state of an Default individual string preference.
 long getDefaultIntPref(String prefName)
          Called to get the state of an Default individual integer preference.
static JRexPreference getInstance()
          Returns an JRexPreference instance.
 long getIntPref(String prefName)
          Called to get the state of an individual integer preference.
 Collection getPrefChildren(String parentPrefName)
          Called to get the list of preferences.
 long getPrefType(String prefName)
          Called to determine the type of a specific preference.
 String getRoot()
          Called to get the root on which this branch is based, such as "browser.startup."
 boolean isPrefLocked(String prefName)
          Called to get the state of is preference is locked.
 void lockPref(String prefName)
          Called to lock a specific preference.
 void readUserPrefs(String file)
          Reads user preference from given file.
 void resetPrefs()
          Called to reset preferences
 void resetUserPrefs()
          Called to reset user preferences
 void savePrefFile(String file)
          Saves the preference to given file.
 void setBoolPref(String prefName, boolean value)
          Called to set the state of an individual boolean preference.
 void setCharPref(String prefName, String value)
          Called to set the state of an individual string preference.
 void setDefaultBoolPref(String prefName, boolean value)
          Called to set the state of an Default individual boolean preference.
 void setDefaultCharPref(String prefName, String value)
          Called to set the state of an Default individual string preference.
 void setDefaultIntPref(String prefName, long value)
          Called to set the state of an Default individual integer preference.
 void setIntPref(String prefName, long value)
          Called to set the state of an individual integer preference.
 void unlockPref(String prefName)
          Called to unlock a specific preference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_INVALID

public static final int PREF_INVALID
A contant representing invalid preference type

See Also:
Constant Field Values

PREF_STRING

public static final int PREF_STRING
A contant representing string preference type

See Also:
Constant Field Values

PREF_INT

public static final int PREF_INT
A contant representing int preference type

See Also:
Constant Field Values

PREF_BOOL

public static final int PREF_BOOL
A contant representing boolean preference type

See Also:
Constant Field Values
Method Detail

getInstance

public static JRexPreference getInstance()
Returns an JRexPreference instance.


readUserPrefs

public void readUserPrefs(String file)
                   throws JRexException
Reads user preference from given file.

Parameters:
file - The complete path of file from which preference should be read.
JRexException

resetPrefs

public void resetPrefs()
                throws JRexException
Called to reset preferences

JRexException

resetUserPrefs

public void resetUserPrefs()
                    throws JRexException
Called to reset user preferences

JRexException

savePrefFile

public void savePrefFile(String file)
                  throws JRexException
Saves the preference to given file.

Parameters:
file - The complete path of file to which preference should be saved.
JRexException

getRoot

public String getRoot()
               throws JRexException
Called to get the root on which this branch is based, such as "browser.startup."

JRexException

getPrefType

public long getPrefType(String prefName)
                 throws JRexException
Called to determine the type of a specific preference.

Parameters:
prefName - The preference to get the type of.
Returns:
long A value representing the type of the preference. This value will be PREF_STRING, PREF_INT, or PREF_BOOL.
JRexException

getBoolPref

public boolean getBoolPref(String prefName)
                    throws JRexException
Called to get the state of an individual boolean preference.

Parameters:
prefName - The boolean preference to get the state of.
Returns:
boolean The value of the requested boolean preference.
JRexException
See Also:
setBoolPref(java.lang.String, boolean)

setBoolPref

public void setBoolPref(String prefName,
                        boolean value)
                 throws JRexException
Called to set the state of an individual boolean preference.

Parameters:
prefName - The boolean preference to set the state of.
value - The boolean value to set the preference to.
JRexException
See Also:
getBoolPref(java.lang.String)

getCharPref

public String getCharPref(String prefName)
                   throws JRexException
Called to get the state of an individual string preference.

Parameters:
prefName - The string preference to retrieve.
Returns:
The value of the requested string preference.
JRexException
See Also:
setCharPref(java.lang.String, java.lang.String)

setCharPref

public void setCharPref(String prefName,
                        String value)
                 throws JRexException
Called to set the state of an individual string preference.

Parameters:
prefName - The string preference to set.
value - The string value to set the preference to.
JRexException
See Also:
getCharPref(java.lang.String)

getIntPref

public long getIntPref(String prefName)
                throws JRexException
Called to get the state of an individual integer preference.

Parameters:
prefName - The integer preference to get the value of.
Returns:
The value of the requested integer preference.
JRexException
See Also:
setIntPref(java.lang.String, long)

setIntPref

public void setIntPref(String prefName,
                       long value)
                throws JRexException
Called to set the state of an individual integer preference.

Parameters:
prefName - The integer preference to set the value of.
value - The integer value to set the preference to.
JRexException
See Also:
getIntPref(java.lang.String)

clearUserPref

public void clearUserPref(String prefName)
                   throws JRexException
Called to clear a user set value from a specific preference. This will, in effect, reset the value to the default value. If no default value exists the preference will cease to exist.

Parameters:
prefName - The preference to be cleared. Note:- This method does nothing if this object is a default branch.
JRexException

isPrefLocked

public boolean isPrefLocked(String prefName)
                     throws JRexException
Called to get the state of is preference is locked.

Parameters:
prefName - The boolean preference to get the state of.
Returns:
true if preference is locked else false.
JRexException

lockPref

public void lockPref(String prefName)
              throws JRexException
Called to lock a specific preference. Locking a preference will cause the preference service to always return the default value regardless of whether there is a user set value or not.

Parameters:
prefName - The preference to be locked. Note:- This method can be called on either a default or user branch but, in effect, always operates on the default branch.
JRexException
See Also:
unlockPref(java.lang.String)

unlockPref

public void unlockPref(String prefName)
                throws JRexException
Called to unlock a specific preference. Unlocking a previously locked preference allows the preference service to once again return the user set value of the preference.

Parameters:
prefName - The preference to be unlocked. Note:- This method can be called on either a default or user branch but, in effect, always operates on the default branch.
JRexException
See Also:
lockPref(java.lang.String)

getDefaultBoolPref

public boolean getDefaultBoolPref(String prefName)
                           throws JRexException
Called to get the state of an Default individual boolean preference.

Parameters:
prefName - The boolean preference to get the state of.
Returns:
The value of the requested boolean preference.
JRexException
See Also:
setBoolPref(java.lang.String, boolean)

setDefaultBoolPref

public void setDefaultBoolPref(String prefName,
                               boolean value)
                        throws JRexException
Called to set the state of an Default individual boolean preference.

Parameters:
prefName - The boolean preference to set the state of.
value - The boolean value to set the preference to.
JRexException
See Also:
getBoolPref(java.lang.String)

getDefaultCharPref

public String getDefaultCharPref(String prefName)
                          throws JRexException
Called to get the state of an Default individual string preference.

Parameters:
prefName - The string preference to retrieve.
Returns:
The value of the requested string preference.
JRexException
See Also:
setCharPref(java.lang.String, java.lang.String)

setDefaultCharPref

public void setDefaultCharPref(String prefName,
                               String value)
                        throws JRexException
Called to set the state of an Default individual string preference.

Parameters:
prefName - The string preference to set.
value - The string value to set the preference to.
JRexException
See Also:
getCharPref(java.lang.String)

getDefaultIntPref

public long getDefaultIntPref(String prefName)
                       throws JRexException
Called to get the state of an Default individual integer preference.

Parameters:
prefName - The integer preference to get the value of.
Returns:
The value of the requested integer preference.
JRexException
See Also:
setIntPref(java.lang.String, long)

setDefaultIntPref

public void setDefaultIntPref(String prefName,
                              long value)
                       throws JRexException
Called to set the state of an Default individual integer preference.

Parameters:
prefName - The integer preference to set the value of.
value - The integer value to set the preference to.
JRexException
See Also:
getIntPref(java.lang.String)

getPrefChildren

public Collection getPrefChildren(String parentPrefName)
                           throws JRexException
Called to get the list of preferences.

Parameters:
parentPrefName - The parent preference to be enumerated.
Returns:
The list children for give parent.
JRexException


Copyright © 2004 C.N.Medappa. All Rights Reserved.