KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > Statement


1 /*
2     (c) Copyright 2000-2004, 2005 Hewlett-Packard Development Company, LP
3     [See end of file]
4     $Id: Statement.java,v 1.12 2005/02/21 12:14:26 andy_seaborne Exp $
5 */

6
7
8 package com.hp.hpl.jena.rdf.model;
9
10 import com.hp.hpl.jena.graph.*;
11
12 /** An RDF Statement.
13  *
14  * <p>A Statement is not a Resource, but can produce a ReifiedStatement
15  * that represents it and from which the Statement can be recovered.</p>
16  *
17  * <p>A statement instance tracks which model it is associated with.</p>
18  *
19  * <p>This interface provides methods supporting typed literals. This means
20  * that methods are provided which will translate a built in type, or an
21  * object to an RDF Literal. This translation is done by invoking the
22  * <CODE>toString()</CODE> method of the object, or its built in equivalent.
23  * The reverse translation is also supported. This is built in for built
24  * in types. Factory objects, provided by the application, are used
25  * for application objects.</p>
26  
27  * @author bwm; additions by kers
28  * @version $Name: $ $Revision: 1.12 $ $Date: 2005/02/21 12:14:26 $
29  */

30
31 public interface Statement extends FrontsTriple
32 {
33     
34     /** determine whether two statements are equal.
35      *
36      * <p> Two statements are considered to be equal if they have the
37      * the same subject, predicate and object. A statement can
38      * only be equal to another statement object.
39      * </p>
40      * @return true if and only if the equality condition is met.
41      * @param o the object to be compared
42      */

43     
44     public boolean equals(Object JavaDoc o);
45     
46     /** Returns asTriple().hashCode()
47      */

48     public int hashCode();
49     
50     /** An accessor method to return the subject of the statements.
51      * @return The subject of the statement.
52      */

53     public Resource getSubject();
54     
55     /** An accessor function to return the predicate of the statement.
56      * @return The predicate of the statement.
57      */

58     public Property getPredicate();
59     
60     /** An accessor funtion to return the object of the statement.
61      * @return Return the object of the statement.
62      */

63     public RDFNode getObject();
64     
65     /** Get a property of the object of the statement.
66      *
67      * <p>There is an unfortunate ambiguity here. GetProperty would normally
68      * treat the statement as a resource, and return a property about this
69      * statement. This is not what is wanted in most cases, so getProperty
70      * on a statement is defined to call getProperty on its object. If
71      * a property of the statement itself is required, getStatementProperty
72      * should be used.</p>
73      *
74      * <p>If the object of the statement is not a resource, an exception is
75      * thrown.</p>
76      * @param p the property sought
77      
78      * @return a statement representing an instance of the required
79      * property
80      */

81     public Statement getProperty(Property p) ;
82     
83     /** Return a property of this statement.
84      *
85      * <p>The model associated with this statement is searched for a statement with
86      * this statement as subject and the specified property as predicate. If
87      * such a statement is found it is return. If more than one exists in the
88      * model, then it is undefined which is returned. If no such statement
89      * exists, an exception is thrown.</p>
90      * @param p the property sought
91      
92      * @return a statement representing an instance of the specified
93      * property.
94      */

95     public Statement getStatementProperty(Property p) ;
96     
97     /** Return the object of the statement.
98      *
99      * <p>An exception will be thrown if the object is not a resource.</p>
100      *
101      * @return The Resource which is the object of the statement.
102      */

103     public Resource getResource() ;
104     
105     /** Return the object of the statement.
106      *
107      * <p>An exception will be thrown if the object is not a Literal.</p>
108      *
109      * @return The Literal which is the object of the statement.
110      */

111     public Literal getLiteral() ;
112     
113     /** Return the object of the statement.
114      *
115      * <p>An exception will be thrown if the object is not a Literal.</p>
116      *
117      * @return The object of the statement interpreted as a value of the
118      * the specified type.
119      */

120     public boolean getBoolean() ;
121     
122     /** Return the object of the statement.
123      *
124      * <p>An exception will be thrown if the object is not a Literal.</p>
125      *
126      * @return The object of the statement interpreted as a value of the
127      * the specified type.
128      */

129     public byte getByte() ;
130     
131     /** Return the object of the statement.
132      *
133      * <p>An exception will be thrown if the object is not a Literal.</p>
134      *
135      * @return The object of the statement interpreted as a value of the
136      * the specified type.
137      */

138     public short getShort() ;
139     
140     /** Return the object of the statement.
141      *
142      * <p>An exception will be thrown if the object is not a Literal.</p>
143      *
144      * @return The object of the statement interpreted as a value of the
145      * the specified type.
146      */

147     public int getInt() ;
148     
149     /** Return the object of the statement.
150      *
151      * <p>An exception will be thrown iof the object is not a Literal.</p>
152      *
153      * @return The object of the statement interpreted as a value of the
154      * the specified type.
155      */

156     public long getLong() ;
157     
158     /** Return the object of the statement.
159      *
160      * <p>An exception will be thrown if the object is not a Literal.</p>
161      *
162      * @return The object of the statement interpreted as a value of the
163      * the specified type.
164      */

165     public char getChar() ;
166     
167     /** Return the object of the statement.
168      *
169      * <p>An exception will be thrown if the object is not a Literal.</p>
170      *
171      * @return The object of the statement interpreted as a value of the
172      * the specified type.
173      */

174     public float getFloat() ;
175     
176     /** Return the object of the statement.
177      *
178      * <p>An exception will be thrown if the object is not a Literal.</p>
179      *
180      * @return The object of the statement interpreted as a value of the
181      * the specified type.
182      */

183     public double getDouble() ;
184     
185     /** Return the object of the statement.
186      *
187      * <p>An exception will be thrown if the object is not a Literal.</p>
188      *
189      * @return The object of the statement interpreted as a value of the
190      * the specified type.
191      */

192     public String JavaDoc getString() ;
193     
194     /** Return the object of the statement.
195      *
196      * <p>An exception will be thrown if the object is not a Resource.</p>
197      * @return The object of the statement.
198      *
199      */

200     public Resource getResource(ResourceF f) ;
201     
202     /** Return the object of the statement.
203      * <p>An exception will be thrown if the object is not a Literal.</p>
204      * @return The object of the statement.
205      * @param f A factory used to create the returned object.
206      *
207      */

208     public Object JavaDoc getObject(ObjectF f) ;
209     
210     /** Return the object of the statement.
211      *
212      * <p>An exception will be thrown if the object is not a Resource.</p>
213      *
214      * @return The object of the statement interpreted as a value of the
215      * the specified type.
216      */

217     public Bag getBag() ;
218     
219     /** Return the object of the statement.
220      *
221      * <p>An exception will be thrown if the object is not a Resource.</p>
222      *
223      * @return The object of the statement interpreted as a value of the
224      * the specified type.
225      */

226     public Alt getAlt() ;
227     
228     /** Return the object of the statement.
229      *
230      * <p>An exception will be thrown if the object is not a Resource.</p>
231      *
232      * @return The object of the statement interpreted as a value of the
233      * the specified type.
234      */

235     public Seq getSeq() ;
236     
237     /** Return the language of the object of the statement.
238      *
239      * <p>An exception will be thrown if the object is not a Literal.</p>
240      *
241      * @return the language of the object of the statement
242      */

243     public String JavaDoc getLanguage() ;
244     
245     /** Return whether the Literal object is well formed XML as would result
246      * from parsing a property element with parseType="Literal".
247      *
248      * <p>An exception will be thrown if the object is not a Literal.</p>
249      *
250      * @return true if the Literal object is well formed
251      */

252     public boolean getWellFormed() ;
253     
254     /** change the object of the statement (S, P, X) to (S, P, o).
255      * @return this object to enable cascading of method calls.
256      * @param o The new value to be set.
257      *
258      */

259     public Statement changeObject(boolean o) ;
260     
261     /** change the object of the statement (S, P, X) to (S, P, o).
262      * <p>The statement with the old value is removed from the model and
263      * a new statement with the new value added and returned.</p>
264      * @param o The value to be set.
265      *
266      * @return the new (S, P, o) statement.
267      */

268     public Statement changeObject(long o) ;
269     
270     /** change the object of the statement (S, P, X) to (S, P, o).
271      * <p>The statement with the old value is removed from the model and
272      * a new statement with the new value added and returned.</p>
273      * @param o The value to be set.
274      *
275      * @return the new (S, P, o) statement.
276      */

277     public Statement changeObject(char o) ;
278     
279     /** change the object of the statement (S, P, X) to (S, P, o).
280      * <p>The statement with the old value is removed from the model and
281      * a new statement with the new value added and returned.</p>
282      * @param o The value to be set.
283      *
284      * @return the new (S, P, o) statement.
285      */

286     public Statement changeObject(float o) ;
287     
288     /** change the object of the statement (S, P, X) to (S, P, o).
289      * <p>The statement with the old value is removed from the model and
290      * a new statement with the new value added and returned.</p>
291      * @param o The value to be set.
292      *
293      * @return the new (S, P, o) statement.
294      */

295     public Statement changeObject(double o) ;
296     
297     /** change the object of the statement (S, P, X) to (S, P, o).
298      * <p>The statement with the old value is removed from the model and
299      * a new statement with the new value added and returned.</p>
300      * @param o The value to be set.
301      *
302      * @return the new (S, P, o) statement.
303      */

304     public Statement changeObject(String JavaDoc o) ;
305     
306     /** change the object of the statement (S, P, X) to (S, P, o).
307      * <p>The statement with the old value is removed from the model and
308      * a new statement with the new value added and returned.</p>
309      * @param o The value to be set.
310      * @param wellFormed true if o is well formed XML
311      *
312      * @return the new (S, P, o) statement.
313      */

314     public Statement changeObject(String JavaDoc o, boolean wellFormed) ;
315     
316     /** change the object of the statement (S, P, X) to (S, P, o).
317      * <p>The statement with the old value is removed from the model and
318      * a new statement with the new value added.</p>
319      * @param o The value to be set.
320      * @param l the language of the String
321      *
322      * @return the new (S, P, o) statement..
323      */

324     public Statement changeObject(String JavaDoc o, String JavaDoc l) ;
325     
326     /** change the object of the statement (S, P, X) to (S, P, o).
327      * <p>The statement with the old value is removed from the model and
328      * a new statement with the new value added.</p>
329      * @param o The value to be set.
330      * @param l the language of the String
331      *
332      * @return the new (S, P, o) statement.
333      */

334     public Statement changeObject(String JavaDoc o, String JavaDoc l, boolean wellFormed)
335       ;
336     
337     /** change the object of the statement (S, P, X) to (S, P, o).
338      * <p>The statement with the old value is removed from the model and
339      * a new statement with the new value added.</p>
340      * @param o The value to be set
341      * @return the new (S, P, o) statement.
342      */

343     public Statement changeObject(RDFNode o) ;
344     
345     /** change the object of the statement (S, P, X) to o.
346      * <p>The statement with the old value is removed from the model and
347      * a new statement with the new value added.</p>
348      * The Object o is converted to a string representation by calling its
349      * <CODE>toString()</CODE> method.
350      * @param o The value to be set.
351      *
352      * @return the new (S, P, o) statement.
353      */

354     public Statement changeObject(Object JavaDoc o) ;
355     
356     /** Remove this statement from its associated model.
357      *
358      * <p>The statement with the same subject, predicate and object as this
359      * statement will be removed from the model associated with this
360      * statement.</p>
361      *
362      * @return this statement.
363      */

364     public Statement remove() ;
365     
366     /**
367         Determine if this statement is the subject of any statements its associated
368         model.
369         @return true iff this statement is the subject of a statement in the model.
370     */

371     boolean isReified();
372     
373     /**
374         answer a ReifiedStatement object that embodies this Statement and
375         is in the same Model (if any).
376     */

377     ReifiedStatement createReifiedStatement();
378     
379     /**
380         answer a ReifiedStatement object that embodies this Statement, has
381         the same Model, and has the given <code>uri</code>.
382     */

383     ReifiedStatement createReifiedStatement( String JavaDoc uri );
384         
385     /**
386         answer an iterator which delivers all the reified statements in the model
387         this Statement belongs to that match this Statement.
388     */

389     RSIterator listReifiedStatements();
390     
391     /**
392         get the Model this Statement was created in.
393     */

394     Model getModel();
395     
396     /**
397      * Finds all possible resources which are
398      * the reification of this statement, and for each
399      * removes all four triples of the reification quad.
400      */

401     void removeReification();
402 }
403 /*
404       (c) Copyright 2000, 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
405       All rights reserved.
406      
407      Redistribution and use in source and binary forms, with or without
408      modification, are permitted provided that the following conditions
409      are met:
410      1. Redistributions of source code must retain the above copyright
411         notice, this list of conditions and the following disclaimer.
412      2. Redistributions in binary form must reproduce the above copyright
413         notice, this list of conditions and the following disclaimer in the
414         documentation and/or other materials provided with the distribution.
415      3. The name of the author may not be used to endorse or promote products
416         derived from this software without specific prior written permission.
417     
418      THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
419      IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
420      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
421      IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
422      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
423      NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
424      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
425      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
426      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
427      THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
428  */
Popular Tags