KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > vocabulary > JenaModelSpec


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

6
7 package com.hp.hpl.jena.vocabulary;
8
9 import com.hp.hpl.jena.graph.*;
10 import com.hp.hpl.jena.rdf.model.*;
11 import com.hp.hpl.jena.shared.*;
12 import com.hp.hpl.jena.util.FileManager;
13
14 /**
15     The Jena Model Specification vocabulary, schema, and some conversion methods.
16     See the modelspec and modelspec-details HOWTOs for discussion on how these
17     fit into the ModelSpec design and implementation.
18     
19     TODO ensure these have explicit tests [they were developed implicitly from the
20     ModelSpec tests].
21     
22     @author kers
23 */

24 public class JenaModelSpec
25     {
26     /**
27         The base URI for all the JenaModelSpec vocabulary items.
28     */

29     public static final String JavaDoc baseURI = "http://jena.hpl.hp.com/2003/08/jms#";
30     
31     /**
32         Answer the base URI for the JenaModelSpec vocabulary items.
33      */

34     public static String JavaDoc getURI()
35         { return baseURI; }
36     
37     /**
38         The property of a ModelSpec that specifies the URI(s) from which it is
39         to be loaded when it has been created.
40     */

41     public static final Property loadWith = property( "loadWith" );
42     
43     /**
44         The property of an OntModelSpec that gives the language URI string.
45     */

46     public static final Property ontLanguage = property( "ontLanguage" );
47     
48     /**
49         The property of an OntModelSpec that gives the document manager resource.
50     */

51     public static final Property docManager = property( "docManager" );
52
53     /**
54         The property of an RDBModelSpec that describes the connection
55     */

56     public static final Property hasConnection = property( "hasConnection" );
57     
58     /**
59         The property of an OntModelSpec that gives the MakerSpec used when
60         manufacturing models for imports.
61     */

62     public static final Property importMaker = property( "importMaker" );
63     
64     /**
65         The property of an InfModelSpec that specifies the ReasonerSpec to use.
66     */

67     public static final Property reasonsWith = property( "reasonsWith" );
68     
69     /**
70          The property of a reasoner spec that specifies a rule-set URL.
71     */

72     public static final Property ruleSetURL = property( "ruleSetURL" );
73     
74     /**
75          The property of a reasoner spec that specifies in-line rule-sets.
76     */

77     public static final Property ruleSet = property( "ruleSet" );
78
79     /**
80         The property of a ModelSpec that specifies the model name.
81     */

82     public static final Property modelName = property( "modelName" );
83     
84     /**
85         The property of a reasoner spec that specifies a schema to load
86     */

87     public static final Property schemaURL = property( "schemaURL" );
88     
89     /**
90          The property of a RuleSet that specifies a rule.
91     */

92     public static final Property hasRule = property( "hasRule" );
93     
94     /**
95         The property of a document manager that gives its policy path string.
96      */

97     public static final Property policyPath = property( "policyPath" );
98     
99     /**
100         The property of an RDBMakerSpec that gives the string to use for the user name
101         when making the connection.
102     */

103     public static final Property dbUser = property( "dbUser" );
104     
105     /**
106         The property of an RDBMakerSpec that gives the string to use for the password
107         when making the connection.
108     */

109     public static final Property dbPassword = property( "dbPassword" );
110     
111     /**
112         The property of an RDBMakerSpec that gives the string to use for the database URL
113         when making the connection.
114     */

115     public static final Property dbURL = property( "dbURL" );
116     
117     /**
118         The property of an RDBMakerSpec that gives the string to use for the database
119         type when making the connection.
120     */

121     public static final Property dbType = property( "dbType" );
122     
123     /**
124         The property of an RDBMakerSpec that gives the string to use for class to load
125         [if any] when making the connection.
126     */

127     public static final Property dbClass = property( "dbClass" );
128     
129     /**
130         The property of a ModelSpec that specifies the resource which describes the maker.
131     */

132     public static final Property maker = property( "maker" );
133     
134     /**
135         The property of a MakerSpec that gives the reification mode for all its models.
136     */

137     public static final Property reificationMode = property( "reificationMode" );
138     
139     /**
140         The property of a ReasonerSpec that gives the resource who's URI is that of
141         the reasoner to use.
142     */

143     public static final Property reasoner = property( "reasoner" );
144     
145     /**
146         The property of a FileMakerSpec that gives the fileBase [root directory] of the
147         FileModelMaker.
148     */

149     public static final Property fileBase = property( "fileBase" );
150     
151     /**
152         The property of some subclass of jms:ModelSpec that specifies the name of the
153         Java class that implements that ModelSpec.
154     */

155     public static final Property typeCreatedBy = property( "typeCreatedBy" );
156     
157     /**
158         The class of MakerSpec resources.
159     */

160     public static final Resource MakerSpec = resource( "MakerSpec" );
161     
162     /**
163         The class of FileMakerSpec resources [subclass of MakerSpec].
164     */

165     public static final Resource FileMakerSpec = resource( "FileMakerSpec" );
166     
167     /**
168         The class of MemMakerSpec resources [subclass of MakerSpec].
169     */

170     public static final Resource MemMakerSpec = resource( "MemMakerSpec" );
171     
172     /**
173         The class of RDBMakerSpec resources [subclass of MakerSpec].
174     */

175     public static final Resource RDBMakerSpec = resource( "RDBMakerSpec" );
176     
177     /**
178         The class of ModelSpec resources.
179     */

180     public static final Resource ModelSpec = resource( "ModelSpec" );
181         
182     /**
183          DefaultModelSpec, a dynamic default ModelSpec
184     */

185     public static final Resource DefaultModelSpec = resource( "DefaultModelSpec" );
186     
187     /**
188         The class of PlainModelSpec resources [subclass of ModelSpec].
189     */

190     public static final Resource PlainModelSpec = resource( "PlainModelSpec" );
191     
192     /**
193         The class of FileModel specifications.
194     */

195     public static Resource FileModelSpec = resource( "FileModelSpec" );
196     
197     /**
198         The class of InfModelSpec resources [subclass of ModelSpec].
199     */

200     public static final Resource InfModelSpec = resource( "InfModelSpec" );
201     
202     /**
203         The class of OntModelSpec resources [subclass of InfModelSpec].
204     */

205     public static final Resource OntModelSpec = resource( "OntModelSpec" );
206     
207     /**
208         The resource representing reification mode Standard.
209     */

210     public static final Resource rsStandard = resource( "rsStandard" );
211     
212     /**
213         The resource representing reification mode Minimal.
214     */

215     public static final Resource rsMinimal = resource( "rsMinimal" );
216     
217     /**
218         The resource representing reification mode Convenient.
219     */

220     public static final Resource rsConvenient = resource( "rsConvenient" );
221
222     /**
223        The JenaModelSpec schema; accessed by <code>getSchema()</code>.
224     */

225     static protected Model schema = null;
226
227     /**
228         Answer the JenaModelSpec schema encoded into a model. This defines the subclass
229         hierarchy and the essential domains of the properties. ["Essential"
230         means "relied on by the ModelSpec engines".] The schema is not loaded
231         until its first use.
232         
233         TODO make this model immutable once created.
234     */

235     public static Model getSchema()
236         {
237         if (schema == null)
238             schema = ModelFactory.createRDFSModel( FileManager.get().loadModel
239                 ( "vocabularies/jena-model-spec.n3" ) );
240         return schema;
241         }
242         
243     /**
244         Utility: answer a resource in the jms namespace with the given local name.
245      */

246     protected static Resource resource( String JavaDoc ln )
247         { return ResourceFactory.createResource( baseURI + ln ); }
248         
249     /**
250         Utility: answer a property in the jms namespave with the given local name.
251      */

252     protected static Property property( String JavaDoc ln )
253         { return ResourceFactory.createProperty( baseURI + ln ); }
254
255     /**
256         Answer the Node which corresponds to the supplied reification style. [Node,
257         not resource, purely because the use happens in BaseGraphMaker, ie at the
258         Graph level.]
259         
260         @param style the reification style for which the JenaModelSpec representation is required
261         @return the Node version of the appropriate JenaModelSpec.rs[name] vocabulary item
262     */

263     public static Node styleAsJMS( ReificationStyle style )
264         {
265         if (style == ReificationStyle.Minimal) return JenaModelSpec.rsMinimal.asNode();
266         if (style == ReificationStyle.Convenient) return JenaModelSpec.rsConvenient.asNode();
267         if (style == ReificationStyle.Standard) return JenaModelSpec.rsStandard.asNode();
268         return null;
269         }
270
271     /**
272         Answer the Reifier.ReificationStyle value named by the argument, which should be a
273         JenaModelSpec.rs[something] value
274         
275         @param style the JenaModelSpec name of the reifier style
276         @return the actual Reifier.ReificationStyle value
277     */

278     public static ReificationStyle findStyle( RDFNode style )
279         { return findStyle( style.asNode() ); }
280         
281     /**
282         Answer the Reifier.ReificationStyle value named by the argument, which should be a
283         JenaModelSpec.rs[something] Node
284         
285         @param style the JenaModelSpec name of the reifier style
286         @return the actual Reifier.ReificationStyle value
287     */

288     public static ReificationStyle findStyle( Node style )
289         {
290         if (style.equals(JenaModelSpec.rsStandard.asNode() )) return ReificationStyle.Standard;
291         if (style.equals(JenaModelSpec.rsMinimal.asNode() )) return ReificationStyle.Minimal;
292         if (style.equals( JenaModelSpec.rsConvenient.asNode() )) return ReificationStyle.Convenient;
293         return null;
294         }
295     }
296
297
298 /*
299     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
300     All rights reserved.
301
302     Redistribution and use in source and binary forms, with or without
303     modification, are permitted provided that the following conditions
304     are met:
305
306     1. Redistributions of source code must retain the above copyright
307        notice, this list of conditions and the following disclaimer.
308
309     2. Redistributions in binary form must reproduce the above copyright
310        notice, this list of conditions and the following disclaimer in the
311        documentation and/or other materials provided with the distribution.
312
313     3. The name of the author may not be used to endorse or promote products
314        derived from this software without specific prior written permission.
315
316     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
317     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
318     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
319     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
320     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
321     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
322     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
323     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
324     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
325     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
326 */
Popular Tags