org.topbraidcomposer.core.registry
Class TBCOntModelRegistry

java.lang.Object
  extended by org.topbraidcomposer.core.registry.TBCOntModelRegistry
All Implemented Interfaces:
IOntModelRegistry

public class TBCOntModelRegistry
extends java.lang.Object
implements IOntModelRegistry


Constructor Summary
TBCOntModelRegistry()
           
 
Method Summary
 boolean canUnregister(java.net.URI baseURI)
          A model can be unregistered if no OntModel is using it.
 com.hp.hpl.jena.rdf.model.Model createModel(java.net.URI baseURI, com.hp.hpl.jena.graph.Graph baseGraph, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void dispose()
           
 com.hp.hpl.jena.rdf.model.Model getBaseModel(com.hp.hpl.jena.ontology.OntModel ontModel)
          Gets the base model of a given OntModel.
 com.hp.hpl.jena.rdf.model.Model getInferenceModel(com.hp.hpl.jena.ontology.OntModel ontModel)
           
 com.hp.hpl.jena.ontology.OntModel getOntModel(com.hp.hpl.jena.graph.Graph graph)
           
 com.hp.hpl.jena.ontology.OntModel getOntModel(com.hp.hpl.jena.graph.Graph graph, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 com.hp.hpl.jena.ontology.OntModel getOntModel(java.net.URI baseURI)
           
 com.hp.hpl.jena.ontology.OntModel getOntModel(java.net.URI baseURI, org.eclipse.core.runtime.IProgressMonitor monitor)
          Gets the current OntModel for a given base URI, if one is loaded.
 java.util.Collection<com.hp.hpl.jena.ontology.OntModel> getOntModels()
           
 com.hp.hpl.jena.ontology.OntModel getOrLoadOntModel(java.net.URI baseURI)
          Gets an existing OntModel with a given base URI.
 com.hp.hpl.jena.rdf.model.Model getSystemModel(com.hp.hpl.jena.ontology.OntModel ontModel)
           
 boolean isEditable(com.hp.hpl.jena.ontology.OntModel model)
           
 boolean isEditable(java.net.URI baseURI)
           
 java.util.Iterator listDirtyFiles()
          Lists all currently open Files or IFiles that are marked to be dirty.
 java.util.Iterator<com.hp.hpl.jena.ontology.OntModel> listOntModels()
          Lists all available OntModels (for all sessions).
 java.util.Iterator<com.hp.hpl.jena.ontology.OntModel> listOntModels(com.hp.hpl.jena.graph.Graph graph)
           
 void rebuildCachingGraphs(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void replaceBaseURI(java.net.URI oldURI, java.net.URI newURI)
           
 void save(java.io.File file)
           
 void save(org.eclipse.core.resources.IFile file)
           
 void setDirty(com.hp.hpl.jena.ontology.OntModel ontModel, boolean value)
           
 void unregisterModel(java.net.URI baseURI)
          Unregisters a model completely, so that it will need to be reloaded if it is being accessed again.
 void unregisterOntModel(java.net.URI baseURI, com.hp.hpl.jena.ontology.OntModel ontModel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TBCOntModelRegistry

public TBCOntModelRegistry()
Method Detail

canUnregister

public boolean canUnregister(java.net.URI baseURI)
A model can be unregistered if no OntModel is using it.

Parameters:
baseURI -
Returns:

createModel

public com.hp.hpl.jena.rdf.model.Model createModel(java.net.URI baseURI,
                                                   com.hp.hpl.jena.graph.Graph baseGraph,
                                                   org.eclipse.core.runtime.IProgressMonitor monitor)

dispose

public void dispose()

getBaseModel

public com.hp.hpl.jena.rdf.model.Model getBaseModel(com.hp.hpl.jena.ontology.OntModel ontModel)
Description copied from interface: IOntModelRegistry
Gets the base model of a given OntModel. The OntModel must be know to the registry. This method is preferred over OntModel.getBaseModel() which had a bug in Jena 3.1, and is furthermore inefficient as it creates a new model on each call.

Specified by:
getBaseModel in interface IOntModelRegistry
Returns:

getInferenceModel

public com.hp.hpl.jena.rdf.model.Model getInferenceModel(com.hp.hpl.jena.ontology.OntModel ontModel)
Specified by:
getInferenceModel in interface IOntModelRegistry

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel(com.hp.hpl.jena.graph.Graph graph)

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel(com.hp.hpl.jena.graph.Graph graph,
                                                     org.eclipse.core.runtime.IProgressMonitor monitor)

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel(java.net.URI baseURI)

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel(java.net.URI baseURI,
                                                     org.eclipse.core.runtime.IProgressMonitor monitor)
Gets the current OntModel for a given base URI, if one is loaded. This method only returns not null if registerModel has been called for this URI before, and no invocation of unregister has happened in the meantime. Note that on the first call to this method, the OntModel may be created on-demand from the base model.

Parameters:
baseURI - the URI to get the Model for
Returns:
the OntModel if it has been loaded or null if not

getOntModels

public java.util.Collection<com.hp.hpl.jena.ontology.OntModel> getOntModels()

getOrLoadOntModel

public com.hp.hpl.jena.ontology.OntModel getOrLoadOntModel(java.net.URI baseURI)
                                                    throws java.lang.Exception
Description copied from interface: IOntModelRegistry
Gets an existing OntModel with a given base URI. If the model does not exist yet, it will create it on demand.

Specified by:
getOrLoadOntModel in interface IOntModelRegistry
Parameters:
baseURI - the base URI - must be registered in the workspace
Returns:
the existing or new OntModel
Throws:
java.lang.Exception - on load errors

getSystemModel

public com.hp.hpl.jena.rdf.model.Model getSystemModel(com.hp.hpl.jena.ontology.OntModel ontModel)
Specified by:
getSystemModel in interface IOntModelRegistry

isEditable

public boolean isEditable(com.hp.hpl.jena.ontology.OntModel model)

isEditable

public boolean isEditable(java.net.URI baseURI)

listDirtyFiles

public java.util.Iterator listDirtyFiles()
Lists all currently open Files or IFiles that are marked to be dirty.

Returns:
an Iterator of IFile objects

listOntModels

public java.util.Iterator<com.hp.hpl.jena.ontology.OntModel> listOntModels()
Description copied from interface: IOntModelRegistry
Lists all available OntModels (for all sessions).

Specified by:
listOntModels in interface IOntModelRegistry
Returns:
an Iterator of OntModels

listOntModels

public java.util.Iterator<com.hp.hpl.jena.ontology.OntModel> listOntModels(com.hp.hpl.jena.graph.Graph graph)
Specified by:
listOntModels in interface IOntModelRegistry

rebuildCachingGraphs

public void rebuildCachingGraphs(org.eclipse.core.runtime.IProgressMonitor monitor)

replaceBaseURI

public void replaceBaseURI(java.net.URI oldURI,
                           java.net.URI newURI)

save

public void save(java.io.File file)
          throws java.io.IOException
Throws:
java.io.IOException

save

public void save(org.eclipse.core.resources.IFile file)
          throws java.io.IOException
Throws:
java.io.IOException

setDirty

public void setDirty(com.hp.hpl.jena.ontology.OntModel ontModel,
                     boolean value)

unregisterModel

public void unregisterModel(java.net.URI baseURI)
Unregisters a model completely, so that it will need to be reloaded if it is being accessed again. The method does nothing if the given URI cannot be unregistered right now. A URI can not be unregistered if it is the currently selected OntModel or one of its imports.

Parameters:
baseURI - the URI of the model to unregister

unregisterOntModel

public void unregisterOntModel(java.net.URI baseURI,
                               com.hp.hpl.jena.ontology.OntModel ontModel)