nsIProperties

This interface provides methods to access a map of named XPCOM object values.
Inherits from: nsISupports Last changed in Gecko 1.2

Implemented by: @mozilla.org/file/directory_service;1. To get an instance, use:

var properties = Components.classes["@mozilla.org/file/directory_service;1"]
                 .getService(Components.interfaces.nsIProperties);

Method overview

void get(in string prop, in nsIIDRef iid, [iid_is(iid),retval] out nsQIResult result);
void getKeys(out PRUint32 count, [array, size_is(count), retval] out string keys);
boolean has(in string prop);
void set(in string prop, in nsISupports value);
void undefine(in string prop);

Methods

get()

Gets the XPCOM object associated with a particular name.

void get(
  in string prop,
  in nsIIDRef iid,
  [iid_is(iid),retval] out nsQIResult result
);
Parameters
prop
The property name.
iid
The desired interface.
result
The resulting object instance.
Exceptions thrown
NS_ERROR_FAILURE
If the property does not exist.
NS_ERROR_NO_INTERFACE
If the property exists, but does not support the requested interface.

getKeys()

Returns an array of property names.

nsMemory.h defines the macro NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY, which can be used to free aKeys when it is no longer needed.

void getKeys(
  out PRUint32 count,
  [array, size_is(count), retval] out string keys
);
Parameters
count
The length of the result array.
keys
The resulting array of keys.

has()

Tests if a property exists.

boolean has(
  in string prop
);
Parameters
prop
The property name.
Return value

true if the property exists, false if the property does not exist.

set()

Sets the XPCOM object associated with a particular name.

void set(
  in string prop,
  in nsISupports value
);
Parameters
prop
The property name.
value
The XPCOM object value to associate with prop.

undefine()

Undefines a property.

void undefine(
  in string prop
);
Parameters
prop
The property name.

Remarks

This interface was frozen for Gecko 1.2. See bug 162114 for details. From Gecko 2.0 interfaces are no longer frozen.