nsIAnnotationService
From MDC
This article covers features introduced in Firefox 3
The nsIAnnotationService interface is designed to store arbitrary data about a web page in Firefox 3. It is usable from trusted Firefox code such as extensions, but not web pages.
nsIAnnotationService is defined in toolkit/components/places/public/nsIAnnotationService.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 1.9).
Inherits from: nsISupports
Implemented by: "@mozilla.org/browser/annotation-service;1". To use this service, use:
var annotationService = Components.classes["@mozilla.org/browser/annotation-service;1"]
.getService(Components.interfaces.nsIAnnotationService);
[edit] Method overview
void setPageAnnotation(in nsIURI aURI, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration);
|
void setItemAnnotation(in long long aItemId, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration);
|
void setPageAnnotationString(in nsIURI aURI, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration);
|
boolean setItemAnnotationString(in long long aItemId, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration);
|
void setPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration);
|
void setItemAnnotationInt32(in long long aItemId, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration);
|
void setPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration);
|
void setItemAnnotationInt64(in long long aItemId, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration);
|
void setPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration);
|
void setItemAnnotationDouble(in long long aItemId, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration);
|
void setPageAnnotationBinary(in nsIURI aURI, in AUTF8String aName,[const, array, size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration);
|
void setItemAnnotationBinary(in long long aItemId, in AUTF8String aName,[const, array, size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration);
|
nsIVariant getPageAnnotation(in nsIURI aURI, in AUTF8String aName);
|
nsIVariant getItemAnnotation(in long long aItemId, in AUTF8String aName);
|
AString getPageAnnotationString(in nsIURI aURI, in AUTF8String aName);
|
AString getItemAnnotationString(in long long aItemId, in AUTF8String aName);
|
long getPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName);
|
long getItemAnnotationInt32(in long long aItemId, in AUTF8String aName);
|
long long getPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName);
|
long long getItemAnnotationInt64(in long long aItemId, in AUTF8String aName);
|
double getPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName);
|
double getItemAnnotationDouble(in long long aItemId, in AUTF8String aName);
|
void getPageAnnotationBinary(in nsIURI aURI, in AUTF8String aName,[array, size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType);
|
void getItemAnnotationBinary(in long long aItemId, in AUTF8String aName,[array, size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType);
|
void getPageAnnotationInfo(in nsIURI aURI, in AUTF8String aName, out PRInt32 aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType);
|
void getItemAnnotationInfo(in long long aItemId, in AUTF8String aName, out long aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType);
|
PRUint16 getPageAnnotationType(in nsIURI aURI, in AUTF8String aName);
|
PRUint16 getItemAnnotationType(in long long aItemId, in AUTF8String aName);
|
void getPagesWithAnnotation(in AUTF8String name, out unsigned long resultCount,[retval, array, size_is(resultCount)] out nsIURI results);
|
void getItemsWithAnnotation(in AUTF8String name, out unsigned long resultCount,[retval, array, size_is(resultCount)] out long long results);
|
void getPageAnnotationNames(in nsIURI aURI, out unsigned long count,[retval, array, size_is(count)] out nsIVariant result);
|
void getItemAnnotationNames(in long long aItemId, out unsigned long count,[retval, array, size_is(count)] out nsIVariant result);
|
boolean pageHasAnnotation(in nsIURI aURI, in AUTF8String aName);
|
boolean itemHasAnnotation(in long long aItemId, in AUTF8String aName);
|
void removePageAnnotation(in nsIURI aURI, in AUTF8String aName);
|
void removeItemAnnotation(in long long aItemId, in AUTF8String aName);
|
void removePageAnnotations(in nsIURI aURI);
|
void removeItemAnnotations(in long long aItemId);
|
void copyPageAnnotations(in nsIURI aSourceURI, in nsIURI aDestURI, in boolean aOverwriteDest);
|
void copyItemAnnotations(in long long aSourceItemId, in long long aDestItemId, in boolean aOverwriteDest);
|
void addObserver(in nsIAnnotationObserver aObserver);
|
void removeObserver(in nsIAnnotationObserver aObserver);
|
nsIURI getAnnotationURI(in nsIURI aURI, in AUTF8String aName);
|
[edit] Constants
| Constant | Value | Description |
EXPIRE_SESSION
| 0 | For temporary data that can be discarded when the user exits. Removed at application exit. |
EXPIRE_WEEKS
| 2 | For general page settings, things the user is interested in seeing if they come back to this page some time in the near future. Removed at 30 days. |
EXPIRE_MONTHS
| 3 | Something that the user will be interested in seeing in their history like favicons. If they haven't visited a page in a couple of months, they probably aren't interested in many other annotations, the positions of things, or other stuff you create, so put that in the weeks policy. Removed at 180 days.
|
EXPIRE_NEVER
| 4 | For data that should never expire. Must be explicitly removed. |
EXPIRE_WITH_HISTORY
| 5 | For annotations that only live as long as the URI is in history (eg: Has >0 visits). |
EXPIRE_DAYS
| 6 | For short-lived temporary data that you still want to outlast a session. Removed at 7 days. |
TYPE_INT32
| 1 | INT32 type constant.
|
TYPE_DOUBLE
| 2 | DOUBLE type constant.
|
TYPE_STRING
| 3 | STRING type constant.
|
TYPE_BINARY
| 4 | BINARY type constant.
|
TYPE_INT64
| 5 | INT64 type constant.
|
EXPIRE_NEVER in bug #319455.[edit] Methods
[edit] setPageAnnotation()
This method sets an annotation for given URI, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value", so your name would be like "bills_extension/page_state" or "history/thumbnail".
Do not use characters that are not valid in URLs such as spaces, ":", commas, or most other symbols. You should stick to ASCII letters and numbers plus "_", "-", and "/".
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary or setPageAnnotationBinary. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotation( in nsIURI aURI, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
EXPIRE_NEVER. This will ensure the item is never completely deleted from the Places database.[edit] setItemAnnotation()
This method sets an annotation for given item, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value", so your name would be like "bills_extension/page_state" or "history/thumbnail".
Do not use characters that are not valid in URLs such as spaces, ":", commas, or most other symbols. You should stick to ASCII letters and numbers plus "_", "-", and "/".
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary or setPageAnnotationBinary. For other types, only C++ consumers may use the type-specific methods.
void setItemAnnotation( in long long aItemId, in AUTF8String aName, in nsIVariant aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemID
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
EXPIRE_NEVER. This will ensure the item is never completely deleted from the Places database.[edit] setPageAnnotationString()
This method sets an annotation for given URI by taking a String as input value, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value", so your name would be like "bills_extension/page_state" or "history/thumbnail".
Do not use characters that are not valid in URLs such as spaces, ":", commas, or most other symbols. You should stick to ASCII letters and numbers plus "_", "-", and "/".
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary or setPageAnnotationBinary. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotationString( in nsIURI aURI, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
EXPIRE_NEVER. This will ensure the item is never completely deleted from the Places database.[edit] setItemAnnotationString()
This method sets an annotation for given item by taking a String as input value, overwriting any previous annotation with the same URL/name. IT IS YOUR JOB TO NAMESPACE YOUR ANNOTATION NAMES. Use the form "namespace/value", so your name would be like "bills_extension/page_state" or "history/thumbnail".
Do not use characters that are not valid in URLs such as spaces, ":", commas, or most other symbols. You should stick to ASCII letters and numbers plus "_", "-", and "/".
The annotation "favicon" is special. Favicons are stored in the favicon service, but are special cased in the protocol handler so they look like annotations. Do not set favicons using this service, it will not work.
Binary annotations should be set using setItemAnnotationBinary or setPageAnnotationBinary. For other types, only C++ consumers may use the type-specific methods.
void setPageAnnotation( in long long aItemId, in AUTF8String aName, in AString aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemID
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
EXPIRE_NEVER. This will ensure the item is never completely deleted from the Places database.[edit] setPageAnnotationInt32()
This method sets an annotation for given URI, just like setPageAnnotationString, but takes an Int32 as an input.
void setPageAnnotationInt32( in nsIURI aURI, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setItemAnnotationInt32()
This method sets an annotation for given item, just like setItemAnnotationString, but takes an Int32 as an input.
void setItemAnnotationInt32( in long long aItemId, in AUTF8String aName, in long aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemId
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setPageAnnotationInt64()
This method sets an annotation for given URI, just like setPageAnnotationString, but takes an Int64 as an input.
void setPageAnnotationInt64( in nsIURI aURI, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setItemAnnotationInt64()
This method sets an annotation for given item, just like setItemAnnotationString, but takes an Int64 as an input.
void setItemAnnotationInt64( in long long aItemId, in AUTF8String aName, in long long aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemId
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setPageAnnotationDouble()
This method sets an annotation for given URI, just like setPageAnnotationString, but takes an Double as an input.
void setPageAnnotationDouble( in nsIURI aURI, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setItemAnnotationDouble()
This method sets an annotation for given item, just like setItemAnnotationString, but takes an Double as an input.
void setItemAnnotationDouble( in long long aItemId, in AUTF8String aName, in double aValue, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemId
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aValue
- The annotation value.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setPageAnnotationBinary()
This method sets an annotation for given URI, just like setPageAnnotationString, but takes Binary data as an input. You MUST supply a valid MIME type.
void setPageAnnotationBinary( in nsIURI aURI, in AUTF8String aName, [const,array,size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aURI
- The URI on which the annotation is to be set.
- aName
- The annotation name.
- aData
- Binary contents of the page to save.
- aDataLen
- Length of binary data.
- aMimeType
MIMEtype of the data to store. MUST be supplied.- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] setItemAnnotationBinary()
This method sets an annotation for given item, just like setItemAnnotationString, but takes Binary data as an input. You MUST supply a valid MIME type.
void setItemAnnotationBinary( in long long aItemId, in AUTF8String aName, [const,array,size_is(aDataLen)] in octet aData, in unsigned long aDataLen, in AUTF8String aMimeType, in long aFlags, in unsigned short aExpiration );
[edit] Parameters
- aItemId
- The item on which the annotation is to be set.
- aName
- The annotation name.
- aData
- Binary contents of the item to save.
- aDataLen
- Length of binary data.
- aMimeType
MIMEtype of the data to store. MUST be supplied.- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above.
[edit] getPageAnnotation()
This method retrieves the value of a given URI annotation. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
nsIVariant getPageAnnotation( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a page annotation.
[edit] getItemAnnotation()
This method retrieves the value of a given item annotation. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
nsIVariant getPageAnnotation( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns an item annotation.
[edit] getPageAnnotationString()
This method retrieves the value of a given URI annotation in String format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
AString getPageAnnotationString( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a String value page annotation.
[edit] getItemAnnotationString()
This method retrieves the value of a given item annotation in String format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
AString getItemAnnotationString( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a String value item annotation.
[edit] getPageAnnotationInt32()
This method retrieves the value of a given URI annotation in a Int32 format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long getPageAnnotationInt32( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns an Int32 value page annotation.
[edit] getItemAnnotationInt32()
This method retrieves the value of a given item annotation in a Int32 format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long getItemAnnotationInt32( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns an Int32 value item annotation.
[edit] getPageAnnotationInt64()
This method retrieves the value of a given URI annotation in a Int64 format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long long getPageAnnotationInt64( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns an Int64 value page annotation.
[edit] getItemAnnotationInt64()
This method retrieves the value of a given item annotation in a Int64 format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
long long getItemAnnotationInt64( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns an Int64 value item annotation.
[edit] getPageAnnotationDouble()
This method retrieves the value of a given URI annotation in Double format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
double getPageAnnotationDouble( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a Double value page annotation.
[edit] getItemAnnotationDouble()
This method retrieves the value of a given item annotation in Double format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type.
double getItemAnnotationDouble( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a Double value item annotation.
[edit] getPageAnnotationBinary()
This method retrieves the value of a given URI annotation in a Binary format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type. This also returns the MIME type.
void getPageAnnotationBinary( in nsIURI aURI, in AUTF8String aName, [array,size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
- aData
- Binary contents of the page to retrieve.
- aDataLen
- Length of binary data.
- aMimeType
MIMEtype of the data to be retrieved.
[edit] Return value
Returns a Binary value and a MIME type page annotation.
[edit] getItemAnnotationBinary()
This method retrieves the value of a given item annotation in a Binary format. Throws an error if the annotation does not exist. Throws for binary annotations, for which getPageAnnotationBinary or getItemAnnotationBinary should be used. C++ consumers may use the type-specific methods. The type-specific methods throw if the given annotation is set in a different type. This also returns the MIME type.
void getItemAnnotationBinary( in long long aItemId, in AUTF8String aName, [array,size_is(aDataLen)] out octet aData, out unsigned long aDataLen, out AUTF8String aMimeType );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
- aData
- Binary contents of the item to retrieve.
- aDataLen
- Length of binary data.
- aMimeType
MIMEtype of the data to be retrieved.
[edit] Return value
Returns a Binary value and a MIME type item annotation.
[edit] getPageAnnotationInfo()
This method retrieves info about an existing annotation for the given URI.
void getPageAnnotationInfo( in nsIURI aURI, in AUTF8String aName, out PRInt32 aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above. - aMimeType
MIMEtype of the data to be retrieved. Default to"0"if value was not binary data.- aType
- One of
TYPE_*constansts defined above.
[edit] getItemAnnotationInfo()
This method retrieves info about an existing annotation for the given item.
void getItemAnnotationInfo( in long long aItemId, in AUTF8String aName, out long aFlags, out unsigned short aExpiration, out AUTF8String aMimeType, out unsigned short aType );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
- aFlags
- Should be
"0"for now, some flags will be defined in the future. - aExpiration
- One of the
EXPIRE_*constant value defined above. - aMimeType
MIMEtype of the data to be retrieved. Default to"0"if value was not binary data.- aType
- One of
TYPE_*constansts defined above.
[edit] getPageAnnotationType()
This method retrieves the type of an existing annotation. Use getAnnotationInfo method, if you need this along with the mime-type etc. It throwns an exception if the annotation is not set.
PRUint16 getPageAnnotationType( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns one of the TYPE_* constants defined above.
[edit] getItemAnnotationType()
This method retrieves the type of an existing annotation. Use getAnnotationInfo method, if you need this along with the mime-type etc. It throwns an exception if the annotation is not set.
PRUint16 getPageAnnotationType( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aURI
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns one of the TYPE_* constants defined above.
[edit] getPagesWithAnnotation()
This method returns a list of all URIs having a given annotation.
void getPagesWithAnnotation( in AUTF8String name, out unsigned long resultCount, [retval, array, size_is(resultCount)] out nsIURI results );
[edit] Parameters
- name
- The annotation name.
- resultCount
- Count of URIs.
- results
- Returns the list of all URIs.
[edit] getItemsWithAnnotation()
This method returns a list of all items having a given annotation.
void getItemsWithAnnotation( in AUTF8String name, out unsigned long resultCount, [retval, array, size_is(resultCount)] out long long results );
[edit] Parameters
- name
- The annotation name.
- resultCount
- Count of items.
- results
- Returns the list of all items.
[edit] getPageAnnotationNames()
This method retrieves the names of all annotations for given URI.
void getPageAnnotationNames( in nsIURI aURI, out unsigned long count, [retval, array, size_is(count)] out nsIVariant result );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- count
- Count of annotations name available.
- result
- Returns the name of all annotations.
[edit] getItemAnnotationNames()
This method retrieves the names of all annotations for given item.
void getItemAnnotationNames( in long long aItemId, out unsigned long count, [retval, array, size_is(count)] out nsIVariant result );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- count
- Count of annotations name available.
- result
- Returns the name of all annotations.
[edit] pageHasAnnotation()
This method tests for annotation existance for given URI.
boolean pageHasAnnotation( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns true, if an annotation exists for given URI, otherwise returns false.
[edit] removeItemAnnotation()
This method tests for annotation existance for given item.
boolean itemHasAnnotation( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns true, if an annotation exists for given item, otherwise returns false.
[edit] removePageAnnotation()
This method removes a specific annotation for given URI. Succeeds even if the annotation is not found.
void removePageAnnotation( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] removeItemAnnotation()
This method removes a specific annotation for given item. Succeeds even if the annotation is not found.
void removeItemAnnotation( in long long aItemId, in AUTF8String aName );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
- aName
- The annotation name.
[edit] removePageAnnotations()
This method removes all annotations for the given URI. We may want some other similar functions to get annotations with given flags (once we have flags defined).
void removePageAnnotations( in nsIURI aURI );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
[edit] removeItemAnnotations()
This method removes all annotations for the given item. We may want some other similar functions to get annotations with given flags (once we have flags defined).
void removeItemAnnotations( in long long aItemId );
[edit] Parameters
- aItemId
- The item on which the annotation is set.
[edit] copyPageAnnotations()
This method copies all annotations from the source to the destination URI. If the destination already has an annotation with the same name as one on the source, it will be overwritten if aOverwriteDest is set. Otherwise, the destination URIs will be preferred.
All the source annotations will stay as-is. If you don't want them any more, use removePageAnnotations on that URI.
void copyPageAnnotations( in nsIURI aSourceURI, in nsIURI aDestURI, in boolean aOverwriteDest );
[edit] Parameters
- aSourceItemId
- Source item.
- aDestItemId
- Destination item.
- aOverwriteDest
- If you want to overwrite existing annotation, set this parameter to
true, or else set it tofalse.
[edit] copyItemAnnotations()
This method copies all annotations from the source to the destination item. If the destination already has an annotation with the same name as one on the source, it will be overwritten if aOverwriteDest is set. Otherwise, the destination URIs will be preferred.
All the source annotations will stay as-is. If you don't want them any more, use removePageAnnotations on that URI.
void copyItemAnnotations( in long long aSourceItemId, in long long aDestItemId, in boolean aOverwriteDest );
[edit] Parameters
- aSourceItemId
- Source item.
- aDestItemId
- Destination item.
- aOverwriteDest
- If you want to overwrite existing annotation, set this parameter to
trueor elsefalse.
[edit] addObserver()
This method adds an annotation observer. The annotation service will keep an owning reference to the observer object.
void addObserver( in nsIAnnotationObserver aObserver );
[edit] Parameters
- aObserver
- Annotation observer.
[edit] removeObserver()
This method removes an annotaton observer previously registered by addObserver method.
void removeObserver( in nsIAnnotationObserver aObserver );
[edit] Parameters
- aObserver
- Annotation observer.
[edit] getAnnotationURI()
This method returns a URI that can be used to access the given binary annotation. This method does NOT check that the annotation exists. Also, note that you can only load URIs for annotations that have have a valid MIME type set by setPageAnnotationBinary or setItemAnnotationBinary methods. No non-URI valid chars in name, especially colon, which will mess up parsing.
nsIURI getAnnotationURI( in nsIURI aURI, in AUTF8String aName );
[edit] Parameters
- aURI
- The URI on which the annotation is set.
- aName
- The annotation name.
[edit] Return value
Returns a URI that can be used to access the given binary annotation.