1 6 7 package com.hp.hpl.jena.rdf.model; 8 9 import com.hp.hpl.jena.graph.*; 10 import com.hp.hpl.jena.graph.compose.Union; 11 import com.hp.hpl.jena.graph.impl.*; 12 import com.hp.hpl.jena.db.*; 13 import com.hp.hpl.jena.db.impl.*; 14 import com.hp.hpl.jena.mem.*; 15 import com.hp.hpl.jena.rdf.model.impl.*; 16 import com.hp.hpl.jena.reasoner.*; 17 import com.hp.hpl.jena.shared.*; 18 import com.hp.hpl.jena.ontology.*; 19 import com.hp.hpl.jena.ontology.daml.DAMLModel; 20 import com.hp.hpl.jena.ontology.daml.impl.DAMLModelImpl; 21 import com.hp.hpl.jena.ontology.impl.OntModelImpl; 22 23 27 28 public class ModelFactory extends ModelFactoryBase 29 { 30 33 private ModelFactory() 34 {} 35 36 40 public static final ReificationStyle Standard = ReificationStyle.Standard; 41 42 46 public static final ReificationStyle Convenient = ReificationStyle.Convenient; 47 48 52 public static final ReificationStyle Minimal = ReificationStyle.Minimal; 53 54 68 public static PrefixMapping setDefaultModelPrefixes( PrefixMapping pm ) 69 { return ModelCom.setDefaultModelPrefixes( pm ); } 70 71 74 public static PrefixMapping getDefaultModelPrefixes() 75 { return ModelCom.getDefaultModelPrefixes(); } 76 77 81 public static ModelSpec createSpec( Model desc ) 82 { return ModelSpecFactory.createSpec( desc ); } 83 84 88 public static ModelSpec createSpec( Resource root, Model desc ) 89 { return ModelSpecFactory.createSpec( ModelSpecFactory.withSchema( desc ), root ); } 90 91 94 public static Model createModel( ModelSpec desc ) 95 { return desc.createModel(); } 96 97 105 public static Model createModelOver( ModelSpec desc, String name ) 106 { return desc.createModelOver( name ); } 107 108 113 public static Model createDefaultModel() 114 { return createDefaultModel( Standard ); } 115 116 119 public static Model createDefaultModel( ReificationStyle style ) 120 { return new ModelCom( new GraphMem( style ) ); } 121 122 127 public static Model withHiddenStatements( Model m ) 128 { return ModelReifier.withHiddenStatements( m ); } 129 130 134 public static Model createNonreifyingModel() 135 { return createDefaultModel( Minimal ); } 136 137 143 public static Model createModelForGraph( Graph g ) { 144 return new ModelCom( g ); 145 } 146 147 156 public static ModelMaker createFileModelMaker( String root ) 157 { return createFileModelMaker( root, Standard ); } 158 159 168 public static ModelMaker createFileModelMaker( String root, ReificationStyle style ) 169 { return new ModelMakerImpl( new FileGraphMaker( root, style ) ); } 170 171 178 public static ModelMaker createMemModelMaker() 179 { return createMemModelMaker( Standard ); } 180 181 188 public static ModelMaker createMemModelMaker( ReificationStyle style ) 189 { return new ModelMakerImpl( new SimpleGraphMaker( style ) ); } 190 191 199 public static ModelMaker createModelRDBMaker( IDBConnection c ) 200 { return createModelRDBMaker( c, Standard ); } 201 202 211 public static ModelMaker createModelRDBMaker 212 ( IDBConnection c, ReificationStyle style ) 213 { return new ModelRDBMaker( new GraphRDBMaker( c, style ) ); } 214 215 static class ModelRDBMaker extends ModelMakerImpl implements ModelMaker 216 { 217 public ModelRDBMaker( GraphRDBMaker gm ) { super( gm ); } 218 219 public Model makeModel( Graph graphRDB ) 220 { return new ModelRDB( (GraphRDB) graphRDB ); } 221 } 222 223 235 public static IDBConnection createSimpleRDBConnection 236 ( String url, String user, String password, String dbType ) 237 { return new DBConnection( url, user, password, dbType ); } 238 239 248 public static IDBConnection createSimpleRDBConnection() 249 { 250 return createSimpleRDBConnection 251 ( guessDBURL(), guessDBUser(), guessDBPassword(), guessDBType() ); 252 } 253 254 262 public static InfModel createRDFSModel(Model model) { 263 Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); 264 InfGraph graph = reasoner.bind( model.getGraph() ); 265 return new InfModelImpl( graph ); 266 } 267 268 277 public static InfModel createRDFSModel( Model schema, Model model ) { 278 Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); 279 InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); 280 return new InfModelImpl( graph ); 281 } 282 283 289 public static InfModel createInfModel( Reasoner reasoner, Model model ) { 290 InfGraph graph = reasoner.bind(model.getGraph()); 291 return new InfModelImpl(graph); 292 } 293 294 304 public static InfModel createInfModel(Reasoner reasoner, Model schema, Model model) { 305 InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); 306 return new InfModelImpl( graph ); 307 } 308 309 320 public static OntModel createOntologyModel() { 321 return createOntologyModel( ProfileRegistry.OWL_LANG ); 322 } 323 324 325 337 public static OntModel createOntologyModel( String languageURI ) { 338 return createOntologyModel( OntModelSpec.getDefaultSpec( languageURI ), null ); 339 } 340 341 342 358 public static OntModel createOntologyModel( OntModelSpec spec, ModelMaker maker, Model base ) { 359 OntModelSpec _spec = new OntModelSpec( spec ); 360 _spec.setImportModelMaker( maker ); 361 362 return createOntologyModel( _spec, base ); 363 } 364 365 366 378 public static OntModel createOntologyModel( OntModelSpec spec, Model base ) { 379 return new OntModelImpl( spec, base ); 380 } 381 382 386 public static OntModel createOntologyModel( OntModelSpec spec ) 387 { return new OntModelImpl( spec ); } 388 389 390 398 public static DAMLModel createDAMLModel() { 399 return new DAMLModelImpl( OntModelSpec.getDefaultSpec( ProfileRegistry.DAML_LANG ), null ); 400 } 401 402 405 public static Model createUnion(Model m1, Model m2) 406 { return createModelForGraph( new Union( m1.getGraph(), m2.getGraph() ) ); } 407 408 } 409 410 411 | Popular Tags |