7 Ci = Components.interfaces;
8 Cc = Components.classes;
15 _initialize:
function() {
16 this._rdf =
Cc[
"@mozilla.org/rdf/rdf-service;1"]
17 .getService(
Ci.nsIRDFService);
18 this._localStore = this._rdf.GetDataSource(
"rdf:local-store");
22 getPersistedAttribute:
function(
file,
id, attribute) {
23 if (!this._localStore)
26 var source = this._rdf.GetResource(
file +
"#" +
id);
27 var
property = this._rdf.GetResource(attribute);
28 var
target = this._localStore.GetTarget(source, property,
true);
29 if (target instanceof
Ci.nsIRDFLiteral)
35 setPersistedAttribute:
function(
file,
id, attribute,
value) {
36 if (!this._localStore)
39 var source = this._rdf.GetResource(
file +
"#" +
id);
40 var
property = this._rdf.GetResource(attribute);
42 var oldTarget = this._localStore.GetTarget(source, property,
true);
45 this._localStore.Change(source, property, oldTarget,
46 this._rdf.GetLiteral(
value));
48 this._localStore.Unassert(source, property, oldTarget);
51 this._localStore.Assert(source, property,
52 this._rdf.GetLiteral(
value),
true);
57 Components.utils.reportError(ex);
62 flush:
function flush() {
63 if (this._localStore && this._dirty) {
64 this._localStore.QueryInterface(
Ci.nsIRDFRemoteDataSource).Flush();