nsITaggingService

Provides methods to tag/untag a URI, to retrieve URIs for a given tag, and to retrieve all tags for a URI.
1.0
66
Introduced
Gecko 1.9
Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Implemented by: @mozilla.org/browser/tagging-service;1. To use this service, use:

var taggingSvc = Components.classes["@mozilla.org/browser/tagging-service;1"]
                           .getService(Components.interfaces.nsITaggingService);

Method overview

void tagURI(in nsIURI aURI, in nsIVariant aTags);
void untagURI(in nsIURI aURI, in nsIVariant aTags);
nsIVariant getURIsForTag(in AString aTag);
nsIVariant getTagsForURI(in nsIURI aURI, [optional] out unsigned long length, [retval, array, size_is(length)] out wstring aTags);

Attributes

Attribute Type Description
allTags nsIVariant Retrieves all tags used to tag URIs in the data-base (sorted by name).
tagContainerIconSpec AUTF8String Retrieves the URL spec for the tag container icon

Methods

tagURI()

This method tags a URI with the given set of tags. Current tags set for the URL persist. Tags in aTags which are already set for the given URI are ignored.

 void tagURI(
   in nsIURI aURI,
   in nsIVariant aTags
 );
Parameters
aURI
The URL to tag.
aTags
Array of tags to set for the given URI.

untagURI()

This method removes tags from a URI. Tags from aTags which are not set for the given URI are ignored.

 void untagURI(
   in nsIURI aURI,
   in nsIVariant aTags
 );
Parameters
aURI
The URL to un-tag.
aTags
Array of tags to unset. Pass NULL to remove all tags from the given URI.

getURIsForTag()

This method retrieves all URIs tagged with the given tag.

 nsIVariant getURIsForTag(
   in AString aTag
 );
Parameters
aTag
The tag name.
Return value

Returns array of URIs tagged with aTag.

getTagsForURI()

This method retrieves all tags set for the given URI.

nsIVariant getTagsForURI(
  in nsIURI aURI,
  [optional] out unsigned long length,
  [retval, array, size_is(length)] out wstring aTags
);
Parameters
aURI
The URI for which to return the tags.
length Optional
On return, contains the number of tags returned in aTags. This optional parameter was required prior to Gecko 2.0.
aTags
On return, contains an array of tags for the specified URI.
Return value

Returns array of tags (sorted by name).

See also