|
|
Line 1: |
Line 1: |
| To prevent namespace conflicts with the existing interfaces, these new interfaces use the rdfI* prefix, instead of nsI* They use interCaps naming, so that there is no confusion in JS between the old and new interfaces. They also use the subject/predicate/object terminology contained in the RDF specification, instead of source/property/target. | | To prevent namespace conflicts with the existing interfaces, these new interfaces use the rdfI* prefix, instead of nsI* They use interCaps naming, so that there is no confusion in JS between the old and new interfaces. They also use the subject/predicate/object terminology contained in the RDF specification, instead of source/property/target. |
|
| |
|
| The RDF node and service implementations are only available on the main (UI) thread. | | The RDF node and service implementations are thread-safe. Each RDF datasource can define its own thread-safety model. |
|
| |
|
| The enumeration methods are replaced almost entirely with visitors. A visitor uses synchronous callbacks to return results in a "snapshot" without expensive intermediate storage allocations. | | The enumeration methods are replaced almost entirely with visitors. A visitor uses synchronous callbacks to return results in a "snapshot" without expensive intermediate storage allocations. |
Line 62: |
Line 62: |
| readonly attribute AUTF8String identifier; | | readonly attribute AUTF8String identifier; |
| }; | | }; |
|
| |
| == rdfILiteral ==
| |
|
| |
| Literals are always obtained through the RDF service. Any script can obtain a literal.
| |
|
| |
| interface rdfILiteral : rdfINode
| |
| {
| |
| readonly attribute AString value;
| |
| readonly attribute AUTF8String lang;
| |
| readonly attribute rdfIResource datatype;
| |
|
| |
| boolean equalsLiteral(in rdfILiteral aOther);
| |
| };
| |
|
| |
| Literals should probably expose their primitive value (dates, ints, strings) via nsIVariant. I would love to see XML literals hook up with e4x.
| |
|
| |
| We need a generic mapping of more complex schema datatypes to js, probably, think about http://www.w3.org/2001/XMLSchema-datatypes#base64Binary. This should be somewhat sane for C++, too.
| |
|
| |
|
| == rdfITripleVisitor == | | == rdfITripleVisitor == |
Line 104: |
Line 87: |
| in nsIRDFNode aObject, in boolean aTruthValue); | | in nsIRDFNode aObject, in boolean aTruthValue); |
| }; | | }; |
| | |
| | |
| | RdfLiterals |
|
| |
|
| == rdfIDataSource == | | == rdfIDataSource == |
|
| |
| For information and tips to implement this interface check out the [[RDF:rdfIDataSource tests]].
| |
|
| |
|
| interface rdfIDataSource : nsISupports | | interface rdfIDataSource : nsISupports |
Line 131: |
Line 115: |
| void visitAllTriples(in rdfITripleVisitor aVisitor); | | void visitAllTriples(in rdfITripleVisitor aVisitor); |
| }; | | }; |
|
| |
| Methods not yet in the tree follow here. Note that rdfIDataSource contains only query methods. We may factor out modifications to rdfIDataTarget. Datasources are *not* named: untrusted script can implement a datasource, and we can't trust the name it gives.
| |
|
| |
| interface rdfIDataSource : nsISupports
| |
| {
| |
| /**
| |
| * Check if a triple exists.
| |
| */
| |
| boolean hasTriple(in rdfIResource aSubject,
| |
| in rdfIResource aPredicate,
| |
| in rdfIResource aObject,
| |
| in bool aTruthValue);
| |
|
| |
| /**
| |
| * Get all the objects from a particular subject->predicate arc.
| |
| * The order is indeterminate and may change from one invocation to the
| |
| * next.
| |
| */
| |
| void getObjects(in rdfIResource aSubject,
| |
| in rdfIResource aPredicate,
| |
| in rdfITripleVisitor aVisitor);
| |
|
| |
| /**
| |
| * Get all the subjects from a particular predicate->object arc.
| |
| * The order is indeterminate and may change from one invocation to the
| |
| * next.
| |
| */
| |
| void getSubjects(in rdfIResource aPredicate,
| |
| in rdfIResource aObject,
| |
| in rdfITripleVisitor aVisitor);
| |
| };
| |
|
| |
| == rdfIDataTarget ==
| |
|
| |
| Modifications of datasources are implemented on rdfIDataTarget.
| |
|
| |
| interface rdfIDataTarget : rdfIDataSource
| |
| {
| |
| void addObserver(rdfIObserver aObserver);
| |
| void removeObserver(rdfIObserver aObserver);
| |
|
| |
| void beginUpdate();
| |
| void endUpdate();
| |
|
| |
| void set(rdfIResource aSubject,
| |
| rdfIResource aPredicate,
| |
| rdfINode aObject);
| |
|
| |
| void unset(rdfIResource aSubject,
| |
| rdfIResource aPredicate,
| |
| rdfINode aObject);
| |
|
| |
| void reset(rdfIResource aSubject,
| |
| rdfIResource aOldPredicate,
| |
| rdfIResource aNewPredicate,
| |
| rdfINode aObject);
| |
|
| |
| void change(rdfIResource aSubject,
| |
| rdfIResource aPredicate,
| |
| rdfINode aOldObject,
| |
| rdfINode aNewObject);
| |
|
| |
| void move(rdfIResource aOldSubject,
| |
| rdfIResource aNewSubject,
| |
| rdfIResource aPredicate,
| |
| rdfINode aObject);
| |
| };
| |
|
| |
| I'm not sure we need all of these. It really depends on which API we want in the rdfIObserver. As everything else doesn't need to be part of the core API.
| |
|
| |
| == rdfICompositeDataSource ==
| |
| It's an interesting question whether the composite ds should implement rdfIDataTarget or not. Usually, asserting into a composite ds is a fuzzy thing to do, and if we made accessing the child datasources easier, it may not be worth a whole lot. So I'd favor not to.
| |
|
| |
| The composite data source implements nsIMutableArray, so that clients can insert and remove datasources in any order. This should be exposed to C++, js wants an array scriptable helper (which we have to implement ourselves, the DOM one works off of nsIDOMNodeList).
| |
|
| |
| interface rdfICompositeDataSource : rdfIDataSource
| |
| {
| |
| /**
| |
| * When enumerating triples if two triples are exactly the same, don't
| |
| * enumerate both arcs.
| |
| * @note The default value is "false". Setting this to "true" can
| |
| * negatively affect performance of queries.
| |
| */
| |
| attribute boolean ignoreDuplicateTriples;
| |
|
| |
| /**
| |
| * Allow later datasources to override matching triples in earlier
| |
| * datasources: i.e. DS1 has triple subjx->arc->"foo" and DS2 has
| |
| * subjx->arc->"bar". If this attribute is false (the default) both triples
| |
| * will be reflected. If true, only the "bar" arc will be reflected.
| |
| * Setting this to true may affect performance and old-style container
| |
| * aggregation.
| |
| */
| |
| attribute boolean allowOverride;
| |
| };
| |
|
| |
| Note: if allowOverride is supposed to replace allowNegativeAssertions, then the comment is wrong.
| |
|
| |
|
| == rdfISerializer == | | == rdfISerializer == |
Line 254: |
Line 141: |
|
| |
|
| RdfLoadAndSave | | RdfLoadAndSave |
| | |
| | RdfTripleVisitor |