KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > Graph


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: Graph.java,v 1.26 2005/02/21 11:51:56 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.graph;
8
9 import com.hp.hpl.jena.graph.impl.GraphBase;
10 import com.hp.hpl.jena.graph.query.*;
11 import com.hp.hpl.jena.shared.*;
12 import com.hp.hpl.jena.util.iterator.*;
13
14 /**
15     The interface to be satisfied by implementations maintaining collections
16     of RDF triples. The core interface is small (add, delete, find, contains) and
17     is augmented by additional classes to handle more complicated matters
18     such as reification, query handling, bulk update, event management,
19     and transaction handling.
20 <p>
21     For <code>add(Triple)</code> see GraphAdd.
22     
23     @author Jeremy Carroll, Chris Dollin
24 */

25 public interface Graph extends GraphAdd
26     {
27     /**
28         An immutable empty graph.
29     */

30     public static final Graph emptyGraph = new GraphBase()
31         { public ExtendedIterator graphBaseFind( TripleMatch tm ) { return NullIterator.instance; } };
32         
33     /**
34         true if this graph's content depends on the other graph. May be
35         pessimistic (ie return true if it's not sure). Typically true when a
36         graph is a composition of other graphs, eg union.
37         
38          @param other the graph this graph may depend on
39          @return false if this does not depend on other
40     */

41     boolean dependsOn( Graph other );
42     
43     /** returns this Graph's query handler */
44     QueryHandler queryHandler();
45     
46     /** returns this Graph's transaction handler */
47     TransactionHandler getTransactionHandler();
48     
49     /** returns this Graph's bulk-update handler */
50     BulkUpdateHandler getBulkUpdateHandler();
51     
52     /** returns this Graph's capabilities */
53     Capabilities getCapabilities();
54     
55     /**
56         Answer this Graph's event manager.
57     */

58     GraphEventManager getEventManager();
59    
60     /**
61         returns this Graph's reifier. Each call on a given Graph gets the same
62         Reifier object.
63     */

64     Reifier getReifier();
65     
66     /**
67         returns this Graph's prefix mapping. Each call on a given Graph gets the
68         same PrefixMapping object, which is the one used by the Graph.
69     */

70     PrefixMapping getPrefixMapping();
71
72     /**
73         Remove the triple t (if possible) from the set belonging to this graph
74     
75         @param t the triple to add to the graph
76         @throws DeleteDeniedException if the triple cannot be removed
77     */

78     void delete(Triple t) throws DeleteDeniedException;
79       
80     /**
81         Returns an iterator over all the Triples that match the triple pattern.
82        
83         @param m a Triple[Match] encoding the pattern to look for
84         @return an iterator of all triples in this graph that match m
85     */

86     ExtendedIterator find(TripleMatch m);
87     
88       /** Returns an iterator over Triple.
89        */

90     ExtendedIterator find(Node s,Node p,Node o);
91     
92     /**
93      * Compare this graph with another using the method
94      * described in
95      * <a HREF="http://www.w3.org/TR/rdf-concepts#section-Graph-syntax">
96      * http://www.w3.org/TR/rdf-concepts#section-Graph-syntax
97      * </a>
98      * @param g Compare against this.
99      * @return boolean True if the two graphs are isomorphic.
100      */

101     boolean isIsomorphicWith(Graph g);
102     
103     /**
104         Answer true iff the graph contains a triple matching (s, p, o).
105         s/p/o may be concrete or fluid. Equivalent to find(s,p,o).hasNext,
106         but an implementation is expected to optimise this in easy cases.
107     */

108     boolean contains( Node s, Node p, Node o );
109     
110     /**
111         Answer true iff the graph contains a triple that t matches; t may be
112         fluid.
113     */

114     boolean contains( Triple t );
115     
116     /** Free all resources, any further use of this Graph is an error.
117      */

118     void close();
119     
120     /**
121         Answer true iff this graph is empty. "Empty" means "has as few triples as it
122         can manage", because an inference graph may have irremovable axioms
123         and their consequences.
124     */

125     boolean isEmpty();
126     
127     /**
128      * For a concrete graph this returns the number of triples in the graph. For graphs which
129      * might infer additional triples it results an estimated lower bound of the number of triples.
130      * For example, an inference graph might return the number of triples in the raw data graph.
131      */

132      int size();
133
134 }
135
136 /*
137     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
138     All rights reserved.
139
140     Redistribution and use in source and binary forms, with or without
141     modification, are permitted provided that the following conditions
142     are met:
143
144     1. Redistributions of source code must retain the above copyright
145        notice, this list of conditions and the following disclaimer.
146
147     2. Redistributions in binary form must reproduce the above copyright
148        notice, this list of conditions and the following disclaimer in the
149        documentation and/or other materials provided with the distribution.
150
151     3. The name of the author may not be used to endorse or promote products
152        derived from this software without specific prior written permission.
153
154     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
155     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
156     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
157     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
158     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
159     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
160     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
161     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
162     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
163     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
164 */

165
Popular Tags