KickJava   Java API By Example, From Geeks To Geeks.

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


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

6
7 package com.hp.hpl.jena.rdf.model;
8
9 import com.hp.hpl.jena.vocabulary.*;
10 import com.hp.hpl.jena.rdf.model.impl.*;
11
12 import java.util.*;
13
14 /**
15     A registry of ways of creating ModelMakers, keyed by their JenaModelSpec type. A
16     ModelMakerCreator registered by type here will be used by a ModelSpec
17     description which needs a ModelMaker and supplies a registered type for
18     that maker.
19 <p>
20     The Registry is pre-loaded with the three standard ModelMakerCreator's,
21     for Mem, File, and RDB ModelMakers.
22  
23     @author hedgehog
24 */

25 public class ModelMakerCreatorRegistry
26     {
27     /**
28         No instances of this class exist- it's all static.
29     */

30     private ModelMakerCreatorRegistry()
31         {}
32
33     /**
34         The map from JenaModelSpec ModelMakerSpecs to the ModelMakerCreator.
35     */

36     private static Map creators = new HashMap();
37     
38     /**
39         Answer the Creator which has been registred with the given type, or null
40         if there's no such registered Creator
41         
42         @param type the JenaModelSpec type of the Creator
43         @return that Creator, or null
44     */

45     public static ModelMakerCreator findCreator( Resource type )
46         { return (ModelMakerCreator) creators.get( type ); }
47         
48     /**
49         Register the given ModelMakerCreator under the given JenaModelSpec type.
50         
51         @param type the type to register it as
52         @param mmc the Creator to register
53     */

54     public static void register( Resource type, ModelMakerCreator mmc )
55         { creators.put( type, mmc ); }
56     
57     /**
58         The default maker-creator, hauled out here as a constant in case we
59         consider changing it [and so it has an identifying name].
60     */

61     private static final ModelMakerCreator defaultMakerCreator = new MemMakerCreator();
62     
63     /**
64         Register the three standard MakerCreators under their JenaModelSpec Resources.
65         We also recognise a non-specific MakerSpec as meaning a default
66         maker type.
67     */

68     static
69         {
70         register( JenaModelSpec.MakerSpec, defaultMakerCreator );
71         register( JenaModelSpec.FileMakerSpec, new FileMakerCreator() );
72         register( JenaModelSpec.MemMakerSpec, new MemMakerCreator() );
73         register( JenaModelSpec.RDBMakerSpec, new RDBMakerCreator() );
74         }
75     }
76
77
78 /*
79     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
80     All rights reserved.
81
82     Redistribution and use in source and binary forms, with or without
83     modification, are permitted provided that the following conditions
84     are met:
85
86     1. Redistributions of source code must retain the above copyright
87        notice, this list of conditions and the following disclaimer.
88
89     2. Redistributions in binary form must reproduce the above copyright
90        notice, this list of conditions and the following disclaimer in the
91        documentation and/or other materials provided with the distribution.
92
93     3. The name of the author may not be used to endorse or promote products
94        derived from this software without specific prior written permission.
95
96     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
97     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
98     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
99     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
100     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
101     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
102     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
103     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
105     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
106 */
Popular Tags