KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: GraphMaker.java,v 1.14 2005/04/10 12:45:47 chris-dollin Exp $
5 */

6
7 package com.hp.hpl.jena.graph;
8
9 import com.hp.hpl.jena.shared.*;
10 import com.hp.hpl.jena.util.iterator.*;
11
12 /**
13     A factory for providing instances of named graphs with appropriate storage models.
14     It represents a directory, or a database, or a mapping: names map to graphs for the
15     lifetime of the GraphMaker. Names can be "arbitrary" character sequences.
16 <p>
17     A GraphMaker has a reification style which is shared by all the graphs it creates.
18 */

19
20 public interface GraphMaker
21 {
22     /**
23         Answer the reification style of all the graphs that this GraphMaker constructs.
24         @return the reification style given to all created graphs
25     */

26     public ReificationStyle getReificationStyle();
27     
28     /**
29         Answer the default graph of this ModelMaker. The same graph is returned on
30         each call. It may only be constructed on the first call of getGraph(), or at any
31         previous time.
32         
33         @return the same default graph each time
34      */

35     public Graph getGraph();
36     
37     /**
38         Answer a graph who's name isn't interesting. Each call delivers a different graph.
39         The GraphMaker may reserve a bunch of names for this purpose, of the form
40         "anon_<digits>", if it cannot support truly anonymous graphs.
41         
42         @return a fresh anonymous graph
43     */

44     public Graph createGraph();
45     
46     /**
47         Create a new graph associated with the given name. If there is no such
48         association, create one and return it. If one exists but <code>strict</code>
49         is false, return the associated graph. Otherwise throw an AlreadyExistsException.
50         
51         @param name the name to give to the new graph
52         @param strict true to cause existing bindings to throw an exception
53         @exception AlreadyExistsException if that name is already bound.
54     */

55     public Graph createGraph( String JavaDoc name, boolean strict );
56     
57     /**
58         Create a graph that does not already exist - equivalent to
59         <br><code>createGraph( name, false )</code>.
60     */

61     public Graph createGraph( String JavaDoc name );
62     
63     /**
64         Find an existing graph that this factory knows about under the given
65         name. If such a graph exists, return it. Otherwise, if <code>strict</code>
66         is false, create a new graph, associate it with the name, and return it.
67         Otherwise throw a DoesNotExistException.
68         
69         @param name the name of the graph to find and return
70         @param strict false to create a new one if one doesn't already exist
71         @exception DoesNotExistException if there's no such named graph
72     */

73     public Graph openGraph( String JavaDoc name, boolean strict );
74     
75     /**
76         Equivalent to <code>openGraph( name, false )</code>
77     */

78     public Graph openGraph( String JavaDoc name );
79     
80     /**
81         Remove the association between the name and the graph. create
82         will now be able to create a graph with that name, and open will no
83         longer be able to find it. Throws an exception if there's no such graph.
84         The graph itself is not touched.
85         
86         @param name the name to disassociate
87         @exception DoesNotExistException if the name is unbound
88     */

89     public void removeGraph( String JavaDoc name );
90     
91     /**
92         return true iff the factory has a graph with the given name
93         
94         @param name the name of the graph to look for
95         @return true iff there's a graph with that name
96     */

97     public boolean hasGraph( String JavaDoc name );
98     
99     /**
100         Answer a Graph describing this GraphMaker using the vocabulary of
101         JenaModelSpec.
102         
103         @return a Graph describing this Maker.
104     */

105     public Graph getDescription();
106     
107     public Graph getDescription( Node root );
108     
109     /**
110         Add the description of this GraphMaker to the description graph desc, under the
111         name self.
112         @param desc the graph to which to add the description
113         @param self the root resource to use for the description
114     */

115     public Graph addDescription( Graph desc, Node self );
116     
117     /**
118         Close the factory - no more requests need be honoured, and any clean-up
119         can be done.
120     */

121     public void close();
122     
123     /**
124         Answer an [extended] iterator where each element is the name of a graph in
125         the maker, and the complete sequence exhausts the set of names. No particular
126         order is expected from the list.
127         @return an extended iterator over the names of graphs known to this Maker.
128      */

129     ExtendedIterator listGraphs();
130 }
131
132 /* ****************************************************************************
133  * Source code information
134  * -----------------------
135  * Original author Ian Dickinson, HP Labs Bristol
136  * Package Jena 2
137  * Web http://sourceforge.net/projects/jena/
138  * Created 06-Mar-2003
139  *
140  * Last modified on $Date: 2005/04/10 12:45:47 $
141  * by $Author: chris-dollin $
142
143  *****************************************************************************/

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

174
Popular Tags