You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.
nsIPrefBranch
This interface is used to manipulate the preferences data. This object may be obtained from the preferences service (
nsIPrefService
) and used to get and set default and/or user preferences across the application. This object is created with a "root" value which describes the base point in the preferences "tree" from which this "branch" stems. Preferences are accessed off of this root by using just the final portion of the preference. For example, if this object is created with the root "browser.startup.", the preferences "browser.startup.page", "browser.startup.homepage", and "browser.startup.homepage_override" can be accessed by simply passing "page", "homepage", or "homepage_override" to the various Get/Set methods. This interface is scriptable.See also
nsIPrefService
Determines the type of a specific preference.
Syntax:
long nsIPrefBranch::getPrefType(in string aPrefName)Parameters:
Returns:
A value representing the type of the preference. This value will be
PREF_STRING
,PREF_INT
, orPREF_BOOL
(see below for definition of these constants).Gets the state of an individual boolean preference.
boolean nsIPrefBranch::getBoolPref(in string aPrefName)Parameters:
Returns:
Sets the state of an individual boolean preference.
Syntax:
void nsIPrefBranch::setBoolPref(in string aPrefName, in long aValue)Parameters:
nsresult:
Gets the state of an individual string preference.
Syntax:
string nsIPrefBranch::getCharPref(in string aPrefName)Parameters:
Returns:
Sets the state of an individual string preference.
Syntax:
void nsIPrefBranch::setCharPref(in string aPrefName, in string aValue)Parameters:
Returns:
Gets the state of an individual integer preference.
Syntax:
long nsIPrefBranch::getIntPref(in string aPrefName)Parameters:
Returns:
Sets the state of an individual integer preference.
Syntax:
void nsIPrefBranch::setIntPref(in string aPrefName, in long aValue)
Parameters:
nsresult:
Gets the state of an individual complex preference. A complex preference is a preference which represents an XPCOM object that can not be easily represented using a standard boolean, integer or string value.
Syntax:
void nsIPrefBranch::getComplexValue(in string aPrefName, in nsIIDRef aType, [iid_is(aType), retval] out nsQIResult aValue)Parameters:
aType:
The XPCOM interface that this complex preference represents. Interfaces currently supported are:
nsresult:
Sets the state of an individual complex preference. A complex preference is a preference which represents an XPCOM object that can not be easily represented using a standard boolean, integer or string value.
Syntax:
void nsIPrefBranch::setComplexValue(in string aPrefName, in nsIIDRef aType, in nsISupports aValue)Parameters:
aType:
The XPCOM interface that this complex preference represents. Interfaces currently supported are:
nsresult:
Clears 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.
Syntax:
void nsIPrefBranch::clearUserPref (in string aPrefName)Parameters:
Note: This method does nothing if this object is a default branch.
nsresult:
Locks 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.
Syntax:
void nsIPrefBranch::lockPref(in string aPrefName)Parameters:
Note: This method can be called on either a default or user branch but, in effect, always operates on the default branch.
nsresult:
Checks if a specific preference has a user value associated with it.
Syntax:
boolean nsIPrefBranch::prefHasUserValue( in string aPrefName)Parameters:
Note: This method can be called on either a default or user branch but, in effect, always operates on the user branch.
Returns:
Checks if a specific preference is locked. If a preference is locked calling its Get method will always return the default value.
Syntax:
boolean nsIPrefBranch::prefIsLocked(in string aPrefName)Parameters:
Note: This method can be called on either a default or user branch but, in effect, always operates on the default branch.
Returns:
Unlocks a specific preference.Unlocking a previously locked preference allows the preference service to once again return the user set value of the preference.
Syntax:
void nsIPrefBranch::unlockPref(in string aPrefName)Parameters:
Note: This method can be called on either a default or user branch but, in effect, always operates on the default branch.
nsresult:
Removes all of the preferences referenced by this branch.
Syntax:
void nsIPrefBranch::deleteBranch(in string aStartingAt)Parameters:
aStartingAt:
The point on the branch at which to start the deleting preferences. Pass in "" to remove all preferences referenced by this branch.
Note:This method can be called on either a default or user branch but, in effect, always operates on both.
nsresult:
Returns an array of strings representing the child preferences of the root of this branch.
Syntax:
void nsIPrefBranch::getChildList(in string aStartingAt, out unsigned long aCount, [array, size_is(aCount), retval] out string aChildArray)Parameters:
aStartingAt:
The point on the branch at which to start enumerating the child preferences. Pass in "" to enumerate all preferences referenced by this branch.
Note: This method can be called on either a default or user branch but, in effect, always operates on both.
nsresult:
Resets all of the preferences referenced by this branch to their default values
Syntax:
void nsIPrefBranch::resetBranch(in string aStartingAt)Parameters:
aStartingAt:
The point on the branch at which to start resetting the preferences to their default values. Pass in "" to reset all preferences referenced by this branch.
Note: This method can be called on either a default or user branch but, in effect, always operates on the user branch.
nsresult:
Gets the root on which this branch is based, such as "browser.startup."
Values describing the basic preference types. Used in
getPrefType.
Written by:Ellen Evans | Comments, questions, complaints?
Bug 143387 |