KickJava   Java API By Example, From Geeks To Geeks.

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


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

6
7 package com.hp.hpl.jena.rdf.model;
8
9 import com.hp.hpl.jena.graph.*;
10 import com.hp.hpl.jena.util.iterator.*;
11
12 /**
13     A ModelMaker contains a collection of named models, methods for creating
14     new models [both named and anonymous] and opening previously-named
15     models, removing models, and accessing a single "default" Model for this
16     Maker.
17     
18     <p>Additional constraints are placed on a ModelMaker as compared to its
19     ancestor <code>ModelSource</code>. ModelMakers do not arbitrarily forget
20     their contents - once they contain a named model, that model stays inside
21     the ModelMaker until that ModelMaker goes away, and maybe for longer
22     (eg if the ModelMaker fronted a database or directory). And new models
23     can be added to a ModelMaker.
24     
25     @author kers
26 */

27
28 public interface ModelMaker extends ModelSpec
29     {
30     /**
31         Create a new Model associated with the given name. If there is no such
32         association, create one and return it. If one exists but <code>strict</code>
33         is false, return the associated Model. Otherwise throw an AlreadyExistsException.
34     
35         @param name the name to give to the new Model
36         @param strict true to cause existing bindings to throw an exception
37         @exception AlreadyExistsException if that name is already bound.
38     */

39     public Model createModel( String JavaDoc name, boolean strict );
40     
41     /**
42         Create a Model that does not already exist - equivalent to
43         <br><code>createModel( name, false )</code>.
44     */

45     public Model createModel( String JavaDoc name );
46
47     /**
48         Find an existing Model that this factory knows about under the given
49         name. If such a Model exists, return it. Otherwise, if <code>strict</code>
50         is false, create a new Model, associate it with the name, and return it.
51         Otherwise throw a DoesNotExistException.
52         
53         <p>When called with <code>strict=false</code>, is equivalent to the
54         ancestor <code>openModel(String)</code> method.
55     
56         @param name the name of the Model to find and return
57         @param strict false to create a new one if one doesn't already exist
58         @exception DoesNotExistException if there's no such named Model
59     */

60     public Model openModel( String JavaDoc name, boolean strict );
61
62     /**
63         Remove the association between the name and the Model. create
64         will now be able to create a Model with that name, and open will no
65         longer be able to find it. Throws an exception if there's no such Model.
66         The Model itself is not touched.
67     
68         @param name the name to disassociate
69         @exception DoesNotExistException if the name is unbound
70     */

71     public void removeModel( String JavaDoc name );
72
73     /**
74         return true iff the factory has a Model with the given name
75     
76         @param name the name of the Model to look for
77         @return true iff there's a Model with that name
78     */

79     public boolean hasModel( String JavaDoc name );
80
81     /**
82         Close the factory - no more requests need be honoured, and any clean-up
83         can be done.
84     */

85     public void close();
86     
87     /**
88         Answer a GraphMaker that makes graphs the same way this ModelMaker
89         makes models. In general this will be an underlying GraphMaker.
90     */

91     public GraphMaker getGraphMaker();
92     
93     /**
94         Answer an [extended] iterator where each element is the name of a model in
95         the maker, and the complete sequence exhausts the set of names. No particular
96         order is expected from the list.
97         @return an extended iterator over the names of models known to this Maker.
98     */

99     public ExtendedIterator listModels();
100     }
101
102
103 /*
104     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
105     All rights reserved.
106
107     Redistribution and use in source and binary forms, with or without
108     modification, are permitted provided that the following conditions
109     are met:
110
111     1. Redistributions of source code must retain the above copyright
112        notice, this list of conditions and the following disclaimer.
113
114     2. Redistributions in binary form must reproduce the above copyright
115        notice, this list of conditions and the following disclaimer in the
116        documentation and/or other materials provided with the distribution.
117
118     3. The name of the author may not be used to endorse or promote products
119        derived from this software without specific prior written permission.
120
121     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
122     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
123     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
124     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
125     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
126     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
127     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
128     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
129     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
130     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131 */
Popular Tags