annotate xul/annota/rdfds.js @ 193:5d483d9c149a

Long overdue adaption to new parameter infrastrucure.
author robcast
date Fri, 28 Nov 2003 13:26:15 +0100
parents bf6d9b7a77d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
2 * The contents of this file are subject to the Mozilla Public
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
3 * License Version 1.1 (the "License"); you may not use this file
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
4 * except in compliance with the License. You may obtain a copy of
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
5 * the License at http://www.mozilla.org/MPL/
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
6 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
7 * Software distributed under the License is distributed on an "AS
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
9 * implied. See the License for the specific language governing
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
10 * rights and limitations under the License.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
11 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
12 * The Original Code is rdfds
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
13 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
14 * The Initial Developer of the Original Code is Neil Deakin
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
15 * Portions created by Neil Deakin are Copyright (C) 2002 Neil Deakin.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
16 * All Rights Reserved.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
17 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
18 * Contributor(s):
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
19 */
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
20
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
21 /* This is a library for easier access to RDF datasources and resources.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
22 * It contains four objects, RDFDataSource, RDFNode, RDFLiteral. and
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
23 * RDFEnumerator.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
24 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
25 * An RDF DataSource is a graph of nodes and literals. The constructor
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
26 * for RDFDataSource takes one argument, a URI of an RDF file to use.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
27 * If the URI exists, the contents of the RDF file are loaded. If it
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
28 * does not exist, resources can be added to it and then written using
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
29 * this save method. If the URL argument is null, a blank datasource
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
30 * is created.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
31 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
32 * This library is designed for convenience not for efficiency.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
33 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
34 * The API is documented at:
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
35 * http://www.xulplanet.com/tutorials/xultu/rdfds/
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
36 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
37 * Example:
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
38 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
39 * var ds=new RDFDataSource("file:///main/mozilla/mimtest.rdf");
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
40 * var node=ds.getNode("urn:xpimaker:packlist");
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
41 * var child=ds.getNode("urn:xpimaker:packlist:appinfo");
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
42 * child=node.addChild(child);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
43 * child.addTarget("http://www.xulplanet.com/rdf/xpimaker#appname","Find Files");
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
44 * ds.save();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
45 *
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
46 */
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
47
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
48 var RDFService = "@mozilla.org/rdf/rdf-service;1";
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
49 RDFService = Components.classes[RDFService].getService();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
50 RDFService = RDFService.QueryInterface(Components.interfaces.nsIRDFService);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
51
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
52 var RDFContainerUtilsService = "@mozilla.org/rdf/container-utils;1";
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
53 RDFContainerUtilsService = Components.classes[RDFContainerUtilsService].getService();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
54 RDFContainerUtilsService = RDFContainerUtilsService.QueryInterface(Components.interfaces.nsIRDFContainerUtils);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
55
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
56 /* RDFLoadObserver
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
57 * this object is necessary to listen to RDF files being loaded. The Init
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
58 * function should be called to initialize the callback when the RDF file is
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
59 * loaded.
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
60 */
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
61 function RDFLoadObserver(){}
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
62
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
63 RDFLoadObserver.prototype =
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
64 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
65 callback: null,
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
66 callbackDataSource: null,
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
67
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
68 Init: function(c,cDS){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
69 this.callback=c;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
70 this.callbackDataSource=cDS;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
71 },
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
72
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
73 QueryInterface: function(iid){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
74 if (iid.equals(Components.interfaces.nsIRDFXMLSinkObserver)) return this;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
75 else throw Components.results.NS_ERROR_NO_INTERFACE;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
76 },
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
77
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
78 onBeginLoad : function(sink){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
79 onInterrupt : function(sink){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
80 onResume : function(sink){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
81 onError : function(sink,status,msg){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
82
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
83 onEndLoad : function(sink){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
84 if (this.callback!=null) this.callback(this.callbackDataSource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
85 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
86 };
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
87
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
88 function RDFDataSource(uri,callbackFn)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
89 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
90 if (uri==null) this.datasource=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
91 else this.load(uri,callbackFn);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
92 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
93
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
94 RDFDataSource.prototype.load=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
95 function(uri,callbackFn)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
96 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
97 if (uri.indexOf(":") == -1){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
98 var docurl=document.location.href;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
99 if (document.location.pathname == null) uri=docurl+"/"+uri;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
100 else uri=docurl.substring(0,docurl.lastIndexOf("/")+1)+uri;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
101 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
102
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
103 if (callbackFn == null){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
104 this.datasource=RDFService.GetDataSourceBlocking(uri);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
105 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
106 else {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
107 this.datasource=RDFService.GetDataSource(uri);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
108 var ds;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
109 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
110 var ds=this.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
111 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
112 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
113 callbackFn(this);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
114 return;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
115 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
116 if (ds.loaded){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
117 callbackFn(this);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
118 return;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
119 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
120
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
121 var packObserver=new RDFLoadObserver();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
122 packObserver.Init(callbackFn,this);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
123
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
124 var rawsource=this.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
125 rawsource=rawsource.QueryInterface(Components.interfaces.nsIRDFXMLSink);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
126 rawsource.addXMLSinkObserver(packObserver);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
127 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
128 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
129
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
130 RDFDataSource.prototype.Init=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
131 function (dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
132 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
133 this.datasource=dsource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
134 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
135
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
136 RDFDataSource.prototype.parseFromString=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
137 function (str,baseUri)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
138 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
139 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
140 var ios=Components.classes["@mozilla.org/network/io-service;1"]
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
141 .getService(Components.interfaces.nsIIOService);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
142 baseUri=ios.newURI(baseUri,null,null);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
143 var xmlParser=Components.classes["@mozilla.org/rdf/xml-parser;1"]
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
144 .createInstance(Components.interfaces.nsIRDFXMLParser);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
145 xmlParser.parseString(this.datasource,baseUri,str);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
146 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
147
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
148 RDFDataSource.prototype.serializeToString=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
149 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
150 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
151 var outputStream = {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
152 data: "",
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
153 close : function(){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
154 flush : function(){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
155 write : function (buffer,count){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
156 this.data += buffer;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
157 return count;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
158 },
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
159 writeFrom : function (stream,count){},
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
160 isNonBlocking: false
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
161 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
162 this.serializeToStream(outputStream);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
163 return outputStream.data;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
164 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
165
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
166 RDFDataSource.prototype.serializeToStream=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
167 function (outputStream)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
168 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
169 var ser=Components.classes["@mozilla.org/rdf/xml-serializer;1"]
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
170 .createInstance(Components.interfaces.nsIRDFXMLSerializer);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
171 ser.init(this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
172 ser.QueryInterface(Components.interfaces.nsIRDFXMLSource).Serialize(outputStream);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
173 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
174
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
175 RDFDataSource.prototype.makeemptyds=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
176 function (uri)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
177 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
178 this.datasource=Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"]
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
179 .createInstance(Components.interfaces.nsIRDFDataSource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
180 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
181
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
182 RDFDataSource.prototype.getAllResources=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
183 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
184 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
185 if (this.datasource==null) return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
186 return new RDFEnumerator(this.datasource.GetAllResources(),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
187 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
188
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
189 RDFDataSource.prototype.getRawDataSource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
190 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
191 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
192 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
193 return this.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
194 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
195
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
196 RDFDataSource.prototype.getNode=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
197 function (uri)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
198 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
199 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
200 var node=new RDFNode(uri,this);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
201 return node;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
202 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
203
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
204 RDFDataSource.prototype.getAnonymousNode=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
205 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
206 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
207 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
208
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
209 var anon=RDFService.GetAnonymousResource();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
210 var node=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
211 node.Init(anon,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
212 return node;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
213 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
214
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
215 RDFDataSource.prototype.getLiteral=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
216 function (uri)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
217 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
218 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
219
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
220 return new RDFLiteral(uri,this);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
221 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
222
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
223 RDFDataSource.prototype.refresh=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
224 function (sync)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
225 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
226 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
227 var ds=this.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
228 ds.Refresh(sync);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
229 return true;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
230 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
231 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
232 return false;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
233 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
234 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
235
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
236 RDFDataSource.prototype.save=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
237 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
238 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
239 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
240 var ds=this.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
241 ds.Flush();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
242 return true;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
243 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
244 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
245 return false;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
246 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
247 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
248
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
249 RDFDataSource.prototype.copyAllToDataSource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
250 function (dsource2)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
251 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
252 if (this.datasource==null) this.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
253 if (dsource2.datasource==null) dsource2.makeemptyds();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
254
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
255 var dsource1=this.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
256 dsource2=dsource2.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
257
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
258 var sourcelist=dsource1.GetAllResources();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
259 while(sourcelist.hasMoreElements()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
260 var source=sourcelist.getNext();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
261 var props=dsource1.ArcLabelsOut(source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
262 while(props.hasMoreElements()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
263 var prop=props.getNext();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
264 prop=prop.QueryInterface(Components.interfaces.nsIRDFResource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
265 var target=dsource1.GetTarget(source,prop,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
266 if (target!=null) dsource2.Assert(source,prop,target,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
267 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
268 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
269 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
270
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
271 RDFDataSource.prototype.deleteRecursive=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
272 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
273 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
274 var node;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
275 var dsource=this.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
276
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
277 if (dsource==null) return;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
278
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
279 if (typeof val == "string") node=RDFService.GetResource(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
280 else node=val.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
281
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
282 this.deleteRecursiveH(dsource,node); // remove descendants
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
283
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
284 // remove the node itself
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
285 var props=dsource.ArcLabelsIn(node);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
286 while(props.hasMoreElements()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
287 var prop=props.getNext();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
288 var source=dsource.GetSource(prop,node,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
289 dsource.Unassert(source,prop,node);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
290 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
291 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
292
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
293 RDFDataSource.prototype.deleteRecursiveH=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
294 function (dsource,node)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
295 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
296 var props=dsource.ArcLabelsOut(node);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
297 while(props.hasMoreElements()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
298 var prop=props.getNext();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
299 var target=dsource.GetTarget(node,prop,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
300 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
301 target=target.QueryInterface(Components.interfaces.nsIRDFResource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
302 this.deleteRecursiveH(dsource,target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
303 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
304 catch (e){}
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
305 dsource.Unassert(node,prop,target)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
306 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
307 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
308
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
309 function RDFNode(uri,dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
310 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
311 if (uri==null) this.source=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
312 else this.source=RDFService.GetResource(uri);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
313
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
314 if (dsource==null) this.datasource=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
315 else this.datasource=dsource.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
316
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
317 this.container=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
318 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
319
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
320 RDFNode.prototype.Init=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
321 function (source,dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
322 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
323 this.source=source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
324 this.datasource=dsource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
325 this.container=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
326 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
327
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
328 RDFNode.prototype.getValue=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
329 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
330 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
331 return this.source.Value;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
332 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
333
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
334 RDFNode.prototype.rlify=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
335 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
336 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
337 var res=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
338
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
339 if (val!=null){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
340 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
341 val=val.QueryInterface(Components.interfaces.nsIRDFResource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
342 res=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
343 res.Init(val,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
344 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
345 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
346 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
347 val=val.QueryInterface(Components.interfaces.nsIRDFLiteral);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
348 res=new RDFLiteral();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
349 res.Init(val,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
350 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
351 catch (ex2){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
352 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
353 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
354 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
355 return res;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
356 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
357
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
358 RDFNode.prototype.makeres=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
359 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
360 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
361 if (typeof val == "string") return RDFService.GetResource(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
362 else return val.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
363 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
364
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
365 RDFNode.prototype.makelit=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
366 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
367 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
368 if (typeof val == "string") return RDFService.GetLiteral(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
369 else return val.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
370 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
371
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
372 RDFNode.prototype.makecontain=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
373 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
374 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
375 if (this.container!=null) return true;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
376
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
377 var RDFContainer = '@mozilla.org/rdf/container;1';
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
378 RDFContainer = Components.classes[RDFContainer].createInstance();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
379 RDFContainer = RDFContainer.QueryInterface(Components.interfaces.nsIRDFContainer);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
380
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
381 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
382 RDFContainer.Init(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
383 this.container=RDFContainer;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
384 return true;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
385 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
386 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
387 return false;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
388 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
389 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
390
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
391 RDFNode.prototype.addTarget=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
392 function (prop,target)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
393 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
394 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
395 target=this.makelit(target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
396 this.datasource.Assert(this.source,prop,target,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
397 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
398
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
399 RDFNode.prototype.addTargetOnce=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
400 function (prop,target)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
401 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
402 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
403 target=this.makelit(target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
404
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
405 var oldtarget=this.datasource.GetTarget(this.source,prop,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
406 if (oldtarget!=null){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
407 this.datasource.Change(this.source,prop,oldtarget,target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
408 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
409 else {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
410 this.datasource.Assert(this.source,prop,target,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
411 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
412 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
413
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
414 RDFNode.prototype.modifyTarget=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
415 function (prop,oldtarget,newtarget)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
416 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
417 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
418 oldtarget=this.makelit(oldtarget);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
419 newtarget=this.makelit(newtarget);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
420 this.datasource.Change(this.source,prop,oldtarget,newtarget);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
421 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
422
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
423 RDFNode.prototype.modifySource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
424 function (prop,oldsource,newsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
425 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
426 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
427 oldsource=this.makeres(oldsource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
428 newsource=this.makeres(newsource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
429 this.datasource.Move(oldsource,newsource,prop,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
430 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
431
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
432 RDFNode.prototype.targetExists=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
433 function (prop,target)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
434 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
435 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
436 target=this.makelit(target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
437 return this.datasource.HasAssertion(this.source,prop,target,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
438 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
439
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
440 RDFNode.prototype.removeTarget=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
441 function (prop,target)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
442 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
443 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
444 target=this.makelit(target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
445 this.datasource.Unassert(this.source,prop,target);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
446 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
447
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
448 RDFNode.prototype.getProperties=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
449 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
450 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
451 return new RDFEnumerator(this.datasource.ArcLabelsOut(this.source),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
452 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
453
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
454 RDFNode.prototype.getInProperties=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
455 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
456 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
457 return new RDFEnumerator(this.datasource.ArcLabelsIn(this.source),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
458 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
459
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
460 RDFNode.prototype.propertyExists=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
461 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
462 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
463 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
464 return this.datasource.hasArcOut(this.source,prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
465 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
466
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
467 RDFNode.prototype.inPropertyExists=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
468 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
469 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
470 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
471 return this.datasource.hasArcIn(this.source,prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
472 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
473
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
474 RDFNode.prototype.getTarget=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
475 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
476 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
477 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
478 return this.rlify(this.datasource.GetTarget(this.source,prop,true));
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
479 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
480
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
481 RDFNode.prototype.getSource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
482 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
483 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
484 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
485 var src=this.datasource.GetSource(prop,this.source,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
486 if (src==null) return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
487 var res=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
488 res.Init(src,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
489 return res;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
490 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
491
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
492 RDFNode.prototype.getTargets=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
493 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
494 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
495 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
496 return new RDFEnumerator(
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
497 this.datasource.GetTargets(this.source,prop,true),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
498 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
499
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
500 RDFNode.prototype.getSources=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
501 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
502 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
503 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
504 return new RDFEnumerator(
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
505 this.datasource.GetSources(prop,this.source,true),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
506 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
507
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
508 RDFNode.prototype.makeBag=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
509 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
510 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
511 this.container=RDFContainerUtilsService.MakeBag(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
512 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
513
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
514 RDFNode.prototype.makeSeq=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
515 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
516 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
517 this.container=RDFContainerUtilsService.MakeSeq(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
518 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
519
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
520 RDFNode.prototype.makeAlt=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
521 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
522 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
523 this.container=RDFContainerUtilsService.MakeAlt(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
524 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
525
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
526 RDFNode.prototype.isBag=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
527 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
528 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
529 return RDFContainerUtilsService.isBag(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
530 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
531
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
532 RDFNode.prototype.isSeq=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
533 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
534 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
535 return RDFContainerUtilsService.isSeq(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
536 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
537
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
538 RDFNode.prototype.isAlt=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
539 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
540 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
541 return RDFContainerUtilsService.isAlt(dsource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
542 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
543
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
544 RDFNode.prototype.isContainer=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
545 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
546 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
547 return RDFContainerUtilsService.IsContainer(this.datasource,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
548 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
549
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
550 RDFNode.prototype.getChildCount=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
551 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
552 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
553 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
554 return this.container.GetCount();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
555 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
556 return -1;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
557 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
558
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
559 RDFNode.prototype.getChildren=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
560 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
561 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
562 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
563 return new RDFEnumerator(this.container.GetElements(),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
564 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
565 else return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
566 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
567
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
568 RDFNode.prototype.addChild=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
569 function (child,exists)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
570 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
571 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
572 var childres=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
573 if (typeof child == "string"){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
574 childres=RDFService.GetResource(child);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
575 child=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
576 child.Init(childres,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
577 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
578 else childres=child.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
579
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
580 if (!exists && this.container.IndexOf(childres)>=0) return child;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
581
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
582 this.container.AppendElement(childres);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
583 return child;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
584 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
585 else return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
586 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
587
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
588 RDFNode.prototype.addChildAt=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
589 function (child,idx)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
590 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
591 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
592 var childres=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
593 if (typeof child == "string"){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
594 childres=RDFService.GetResource(child);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
595 child=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
596 child.Init(childres,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
597 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
598 else childres=child.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
599 this.container.InsertElementAt(childres,idx,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
600 return child;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
601 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
602 else return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
603 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
604
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
605 RDFNode.prototype.removeChild=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
606 function (child)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
607 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
608 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
609 var childres=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
610 if (typeof child == "string"){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
611 childres=RDFService.GetResource(child);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
612 child=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
613 child.Init(childres,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
614 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
615 else childres=child.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
616 this.container.RemoveElement(childres,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
617 return child;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
618 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
619 else return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
620 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
621
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
622 RDFNode.prototype.removeChildAt=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
623 function (idx)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
624 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
625 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
626 var childres=this.container.RemoveElementAt(idx,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
627 return this.rlify(childres);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
628 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
629 else return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
630 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
631
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
632 RDFNode.prototype.getChildIndex=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
633 function (child)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
634 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
635 if (this.makecontain()){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
636 return this.container.IndexOf(child.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
637 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
638 else return -1;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
639 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
640
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
641 RDFNode.prototype.type="Node";
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
642
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
643
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
644 function RDFLiteral(val,dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
645 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
646 if (val==null) this.source=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
647 else this.source=RDFService.GetLiteral(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
648
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
649 if (dsource==null) this.datasource=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
650 else this.datasource=dsource.datasource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
651 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
652
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
653 RDFLiteral.prototype.Init=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
654 function (source,dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
655 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
656 this.source=source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
657 this.datasource=dsource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
658 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
659
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
660 RDFLiteral.prototype.getValue=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
661 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
662 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
663 return this.source.Value;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
664 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
665
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
666 RDFLiteral.prototype.makeres=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
667 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
668 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
669 if (typeof val == "string") return RDFService.GetResource(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
670 else return val.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
671 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
672
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
673 RDFLiteral.prototype.makelit=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
674 function (val)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
675 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
676 if (typeof val == "string") return RDFService.GetLiteral(val);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
677 else return val.source;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
678 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
679
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
680 RDFLiteral.prototype.modifySource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
681 function (prop,oldsource,newsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
682 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
683 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
684 oldsource=this.makeres(oldsource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
685 newsource=this.makeres(newsource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
686 this.datasource.Move(oldsource,newsource,prop,this.source);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
687 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
688
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
689 RDFLiteral.prototype.getInProperties=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
690 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
691 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
692 return new RDFEnumerator(this.datasource.ArcLabelsIn(this.source),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
693 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
694
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
695 RDFLiteral.prototype.inPropertyExists=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
696 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
697 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
698 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
699 return this.datasource.hasArcIn(this.source,prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
700 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
701
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
702 RDFLiteral.prototype.getSource=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
703 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
704 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
705 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
706 var src=this.datasource.GetSource(prop,this.source,true);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
707 if (src==null) return null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
708 var res=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
709 res.Init(src,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
710 return res;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
711 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
712
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
713 RDFLiteral.prototype.getSources=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
714 function (prop)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
715 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
716 prop=this.makeres(prop);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
717 return new RDFEnumerator(
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
718 this.datasource.GetSources(prop,this.source,true),this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
719 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
720
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
721 RDFLiteral.prototype.type="Literal";
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
722
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
723
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
724 function RDFEnumerator(enumeration,dsource)
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
725 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
726 this.enumeration=enumeration;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
727 this.datasource=dsource;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
728 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
729
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
730 RDFEnumerator.prototype.hasMoreElements=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
731 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
732 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
733 return this.enumeration.hasMoreElements();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
734 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
735
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
736 RDFEnumerator.prototype.getNext=
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
737 function ()
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
738 {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
739 var res=null;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
740 var val=this.enumeration.getNext();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
741
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
742 if (val!=null){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
743 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
744 val=val.QueryInterface(Components.interfaces.nsIRDFResource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
745 res=new RDFNode();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
746 res.Init(val,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
747 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
748 catch (ex){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
749 try {
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
750 val=val.QueryInterface(Components.interfaces.nsIRDFLiteral);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
751 res=new RDFLiteral();
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
752 res.Init(val,this.datasource);
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
753 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
754 catch (ex2){
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
755 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
756 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
757 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
758 return res;
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
759 }
bf6d9b7a77d4 Annotation Tool to integrate in chrome sidebar
engler
parents:
diff changeset
760