001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: Graph.java,v 1.31 2008/01/02 12:06:55 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.graph;
008:
009: import com.hp.hpl.jena.graph.impl.GraphBase;
010: import com.hp.hpl.jena.graph.query.*;
011: import com.hp.hpl.jena.shared.*;
012: import com.hp.hpl.jena.util.iterator.*;
013:
014: /**
015: The interface to be satisfied by implementations maintaining collections
016: of RDF triples. The core interface is small (add, delete, find, contains) and
017: is augmented by additional classes to handle more complicated matters
018: such as reification, query handling, bulk update, event management,
019: and transaction handling.
020: <p>
021: For <code>add(Triple)</code> see GraphAdd.
022:
023: @author Jeremy Carroll, Chris Dollin
024: */
025: public interface Graph extends GraphAdd {
026: /**
027: An immutable empty graph.
028: */
029: public static final Graph emptyGraph = new GraphBase() {
030: public ExtendedIterator graphBaseFind(TripleMatch tm) {
031: return NullIterator.instance;
032: }
033: };
034:
035: /**
036: true if this graph's content depends on the other graph. May be
037: pessimistic (ie return true if it's not sure). Typically true when a
038: graph is a composition of other graphs, eg union.
039:
040: @param other the graph this graph may depend on
041: @return false if this does not depend on other
042: */
043: boolean dependsOn(Graph other);
044:
045: /** returns this Graph's query handler */
046: QueryHandler queryHandler();
047:
048: /** returns this Graph's transaction handler */
049: TransactionHandler getTransactionHandler();
050:
051: /** returns this Graph's bulk-update handler */
052: BulkUpdateHandler getBulkUpdateHandler();
053:
054: /** returns this Graph's capabilities */
055: Capabilities getCapabilities();
056:
057: /**
058: Answer this Graph's event manager.
059: */
060: GraphEventManager getEventManager();
061:
062: /**
063: Answer this Graph's statistics handler, or null if there isn't one. Every
064: call to this method on a particular graph delivers the same (==) answer.
065: */
066: GraphStatisticsHandler getStatisticsHandler();
067:
068: /**
069: returns this Graph's reifier. Each call on a given Graph gets the same
070: Reifier object.
071: */
072: Reifier getReifier();
073:
074: /**
075: returns this Graph's prefix mapping. Each call on a given Graph gets the
076: same PrefixMapping object, which is the one used by the Graph.
077: */
078: PrefixMapping getPrefixMapping();
079:
080: /**
081: Remove the triple t (if possible) from the set belonging to this graph
082:
083: @param t the triple to add to the graph
084: @throws DeleteDeniedException if the triple cannot be removed
085: */
086: void delete(Triple t) throws DeleteDeniedException;
087:
088: /**
089: Returns an iterator over all the Triples that match the triple pattern.
090:
091: @param m a Triple[Match] encoding the pattern to look for
092: @return an iterator of all triples in this graph that match m
093: */
094: ExtendedIterator find(TripleMatch m);
095:
096: /** Returns an iterator over Triple.
097: */
098: ExtendedIterator find(Node s, Node p, Node o);
099:
100: /**
101: * Compare this graph with another using the method
102: * described in
103: * <a href="http://www.w3.org/TR/rdf-concepts#section-Graph-syntax">
104: * http://www.w3.org/TR/rdf-concepts#section-Graph-syntax
105: * </a>
106: * @param g Compare against this.
107: * @return boolean True if the two graphs are isomorphic.
108: */
109: boolean isIsomorphicWith(Graph g);
110:
111: /**
112: Answer true iff the graph contains a triple matching (s, p, o).
113: s/p/o may be concrete or fluid. Equivalent to find(s,p,o).hasNext,
114: but an implementation is expected to optimise this in easy cases.
115: */
116: boolean contains(Node s, Node p, Node o);
117:
118: /**
119: Answer true iff the graph contains a triple that t matches; t may be
120: fluid.
121: */
122: boolean contains(Triple t);
123:
124: /** Free all resources, any further use of this Graph is an error.
125: */
126: void close();
127:
128: /**
129: Answer true iff this graph is empty. "Empty" means "has as few triples as it
130: can manage", because an inference graph may have irremovable axioms
131: and their consequences.
132: */
133: boolean isEmpty();
134:
135: /**
136: * For a concrete graph this returns the number of triples in the graph. For graphs which
137: * might infer additional triples it results an estimated lower bound of the number of triples.
138: * For example, an inference graph might return the number of triples in the raw data graph.
139: */
140: int size();
141:
142: /**
143: Answer true iff .close() has been called onn this Graph.
144: */
145: boolean isClosed();
146: }
147:
148: /*
149: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
150: All rights reserved.
151:
152: Redistribution and use in source and binary forms, with or without
153: modification, are permitted provided that the following conditions
154: are met:
155:
156: 1. Redistributions of source code must retain the above copyright
157: notice, this list of conditions and the following disclaimer.
158:
159: 2. Redistributions in binary form must reproduce the above copyright
160: notice, this list of conditions and the following disclaimer in the
161: documentation and/or other materials provided with the distribution.
162:
163: 3. The name of the author may not be used to endorse or promote products
164: derived from this software without specific prior written permission.
165:
166: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
167: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
168: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
169: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
170: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
171: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
172: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
173: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
174: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
175: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
176: */
|