KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > impl > ModelMakerImpl


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

6
7 package com.hp.hpl.jena.rdf.model.impl;
8
9 import com.hp.hpl.jena.graph.*;
10 import com.hp.hpl.jena.rdf.model.*;
11 import com.hp.hpl.jena.util.iterator.*;
12
13 /**
14     A ModelMakerImpl implements a ModelMaker over a GraphMaker.
15 */

16 public class ModelMakerImpl implements ModelMaker
17     {
18     protected GraphMaker maker;
19     protected Model description;
20     
21     public ModelMakerImpl( GraphMaker maker )
22         { this.maker = maker; }
23         
24     public GraphMaker getGraphMaker()
25         { return maker; }
26         
27     public void close()
28         { maker.close(); }
29        
30     protected Model makeModel( Graph g )
31         { return new ModelCom( g ); }
32     
33     public Model openModelIfPresent( String JavaDoc name )
34         { return maker.hasGraph( name ) ? openModel( name ) : null; }
35     
36     public Model openModel( String JavaDoc name, boolean strict )
37         { return makeModel( maker.openGraph( name, strict ) ); }
38         
39     public Model openModel( String JavaDoc name )
40         { return openModel( name, false ); }
41         
42     public Model createModel( String JavaDoc name, boolean strict )
43         { return makeModel( maker.createGraph( name, strict ) ); }
44         
45     public Model createModel( String JavaDoc name )
46         { return createModel( name, false ); }
47         
48     public Model createModelOver( String JavaDoc name )
49         { return createModel( name ); }
50         
51     public Model createModel()
52         { return makeModel( maker.createGraph() ); }
53         
54     public Model getModel()
55         { return makeModel( maker.getGraph() ); }
56         
57     public Model getDescription()
58         {
59         if (description == null) description = makeModel( maker.getDescription() );
60         return description;
61         }
62         
63     public Model getDescription( Resource root )
64         { return makeModel( maker.getDescription( root.asNode() ) ); }
65         
66     public Model addDescription( Model m, Resource self )
67         { return makeModel( maker.addDescription( m.getGraph(), self.asNode() ) ); }
68         
69     public void removeModel( String JavaDoc name )
70         { maker.removeGraph( name ); }
71         
72     public boolean hasModel( String JavaDoc name )
73         { return maker.hasGraph( name ); }
74         
75     public ExtendedIterator listModels()
76         { return maker.listGraphs(); }
77     }
78
79 /*
80     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
81     All rights reserved.
82
83     Redistribution and use in source and binary forms, with or without
84     modification, are permitted provided that the following conditions
85     are met:
86
87     1. Redistributions of source code must retain the above copyright
88        notice, this list of conditions and the following disclaimer.
89
90     2. Redistributions in binary form must reproduce the above copyright
91        notice, this list of conditions and the following disclaimer in the
92        documentation and/or other materials provided with the distribution.
93
94     3. The name of the author may not be used to endorse or promote products
95        derived from this software without specific prior written permission.
96
97     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
98     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
99     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
100     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
101     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
102     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
103     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
104     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
106     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107 */
Popular Tags