mozilla

Revision 562001 of fuelIAnnotations

  • Revision slug: Mozilla/Tech/Toolkit_API/FUEL/fuelIAnnotations
  • Revision title: fuelIAnnotations
  • Revision id: 562001
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Clean up sourceToolkit_API/FUEL/fuelIAnnotations Mozilla/Tech/Toolkit_API/FUEL/fuelIAnnotations

Revision Content

{{ Fx_minversion_header(3) }} The annotation service is designed to store arbitrary data about a web page in Firefox 3

Method overview

boolean has(in AString aName)
nsIVariant get(in AString aName)
void set(in AString aName, in nsIVariant aValue, in PRInt32 aExpiration)
void remove(in AString aName)

Attributes

Attribute Type Description
names readonly attribute nsIVariant Array of the annotation names associated with the owning item

Methods

has()

Determines if an annotation exists with the given name.

boolean has(in AString aName)

Parameters

aName
The name of the annotation

Return value

true if an annotation exists with the given name, false otherwise.

get()

Gets the value of an annotation with the given name.

nsIVariant get(in AString aName)

Parameters

aName
The name of the annotation

Return value

A variant containing the value of the annotation. Supports string, boolean and number.

set()

Sets the value of an annotation with the given name.

void set(in AString aName, in nsIVariant aValue, in PRInt32 aExpiration)

Parameters

aName
The name of the annotation
aValue
The new value of the annotation. Supports string, boolean and number.
aExpiration
The expiration policy for the annotation. See nsIAnnotationService.

Return value

remove()

Removes the named annotation from the owner item.

void remove(in AString aName)

Parameters

aName
The name of annotation.

Return value

Examples

const NEVER_EXPIRE = 0;

function url(spec) {
  var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
  return ios.newURI(spec, null, null);
}

var bookmark = Application.bookmarks.menu.addBookmark("Mozilla", url("http://www.mozilla.com/"));
bookmark.annotations.set("mystuff/public", true, NEVER_EXPIRE);
bookmark.annotations.set("mystuff/rating", 5, NEVER_EXPIRE);

alert(bookmark.annotations.get("mystuff/rating"));

bookmark.annotations.remove("mystuff/rating");

See also

Revision Source

<p>{{ Fx_minversion_header(3) }} The annotation service is designed to store arbitrary data about a web page in Firefox 3</p>
<h2 id="Method_overview" name="Method_overview">Method overview</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <td><code>boolean <a href="#has()">has</a>(in AString aName)</code></td>
    </tr>
    <tr>
      <td><code>nsIVariant <a href="#get()">get</a>(in AString aName)</code></td>
    </tr>
    <tr>
      <td><code>void <a href="#set()">set</a>(in AString aName, in nsIVariant aValue, in PRInt32 aExpiration)</code></td>
    </tr>
    <tr>
      <td><code>void <a href="#remove()">remove</a>(in AString aName)</code></td>
    </tr>
  </tbody>
</table>
<h2 id="Attributes" name="Attributes">Attributes</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <td class="header">Attribute</td>
      <td class="header">Type</td>
      <td class="header">Description</td>
    </tr>
    <tr>
      <td><code>names</code></td>
      <td><code>readonly attribute nsIVariant</code></td>
      <td>Array of the annotation names associated with the owning item</td>
    </tr>
  </tbody>
</table>
<h2 id="Methods" name="Methods">Methods</h2>
<h3 id="has()" name="has()">has()</h3>
<p>Determines if an annotation exists with the given name.</p>
<pre class="eval">
boolean has(in AString aName)
</pre>
<h4 id="Parameters" name="Parameters">Parameters</h4>
<dl>
  <dt>
    aName</dt>
  <dd>
    The name of the annotation</dd>
</dl>
<h4 id="Return_value" name="Return_value">Return value</h4>
<p>true if an annotation exists with the given name, false otherwise.</p>
<h3 id="get()" name="get()">get()</h3>
<p>Gets the value of an annotation with the given name.</p>
<pre class="eval">
nsIVariant get(in AString aName)
</pre>
<h4 id="Parameters_2" name="Parameters_2">Parameters</h4>
<dl>
  <dt>
    aName</dt>
  <dd>
    The name of the annotation</dd>
</dl>
<h4 id="Return_value_2" name="Return_value_2">Return value</h4>
<p>A variant containing the value of the annotation. Supports string, boolean and number.</p>
<h3 id="set()" name="set()">set()</h3>
<p>Sets the value of an annotation with the given name.</p>
<pre class="eval">
void set(in AString aName, in nsIVariant aValue, in PRInt32 aExpiration)
</pre>
<h4 id="Parameters_3" name="Parameters_3">Parameters</h4>
<dl>
  <dt>
    aName</dt>
  <dd>
    The name of the annotation</dd>
  <dt>
    aValue</dt>
  <dd>
    The new value of the annotation. Supports string, boolean and number.</dd>
  <dt>
    aExpiration</dt>
  <dd>
    The expiration policy for the annotation. See nsIAnnotationService.</dd>
</dl>
<h4 id="Return_value_3" name="Return_value_3">Return value</h4>
<h3 id="remove()" name="remove()">remove()</h3>
<p>Removes the named annotation from the owner item.</p>
<pre class="eval">
void remove(in AString aName)
</pre>
<h4 id="Parameters_4" name="Parameters_4">Parameters</h4>
<dl>
  <dt>
    aName</dt>
  <dd>
    The name of annotation.</dd>
</dl>
<h4 id="Return_value_4" name="Return_value_4">Return value</h4>
<h2 id="Examples" name="Examples">Examples</h2>
<pre>
const NEVER_EXPIRE = 0;

function url(spec) {
  var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
  return ios.newURI(spec, null, null);
}

var bookmark = Application.bookmarks.menu.addBookmark("Mozilla", url("http://www.mozilla.com/"));
bookmark.annotations.set("mystuff/public", true, NEVER_EXPIRE);
bookmark.annotations.set("mystuff/rating", 5, NEVER_EXPIRE);

alert(bookmark.annotations.get("mystuff/rating"));

bookmark.annotations.remove("mystuff/rating");
</pre>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/Using_the_Places_annotation_service">Using the Places annotation service</a></li>
  <li>{{interface("nsIAnnotationService")}}</li>
</ul>
Revert to this revision