nsIProperties 编辑

xpcom/ds/nsIProperties.idlScriptable 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:36 次

字数:4505

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文