org.topbraid.core.registry.impl
Class GraphRegistry

java.lang.Object
  extended by org.topbraid.core.registry.impl.GraphRegistry
All Implemented Interfaces:
IGraphRegistry

public class GraphRegistry
extends java.lang.Object
implements IGraphRegistry

An object that manages all currently loaded Graphs. The implementation maintains the collection of all open Graphs together with a wrapping Model and the source from where the Graph was loaded.

Author:
Holger Knublauch

Constructor Summary
GraphRegistry()
           
 
Method Summary
 void addListener(IGraphRegistryListener listener)
           
 void dispose()
           
 void disposeConfigModel(java.net.URI baseURI)
           
 void dump(java.io.PrintStream ps)
           
 com.hp.hpl.jena.graph.Graph getBaseGraph(com.hp.hpl.jena.graph.Graph perhapsDelegatingGraph)
           
 com.hp.hpl.jena.graph.Graph getBaseGraph(java.net.URI baseURI)
           
 java.net.URI getBaseURI(java.io.File file)
           
 java.net.URI getBaseURI(com.hp.hpl.jena.graph.Graph graph)
           
 java.net.URI getBaseURI(org.eclipse.core.resources.IFile file)
           
 com.hp.hpl.jena.rdf.model.Model getConfigModel(java.net.URI baseURI)
          Gets the configuration Model that holds metadata for a given Model.
 com.hp.hpl.jena.ontology.OntModel getConfigOntModel(java.net.URI baseURI)
          Gets the OntModel that contains all configuration models of subgraphs as well as the base config model and system configuration models.
 java.net.URI getImportBaseURI(java.net.URI importedURI)
          Gets the base URI of an ontology specified by an import statement.
 java.lang.Object getSource(java.net.URI baseURI)
          Gets the source where a Graph (represented by its base URI) has been loaded from.
 void initConfigModel(java.net.URI baseURI)
           
 void invalidateConfigOntModels()
           
 boolean isDirty(com.hp.hpl.jena.graph.Graph graph)
           
 boolean isMemoryGraph(com.hp.hpl.jena.graph.Graph graph)
           
 java.util.Iterator<java.net.URI> listURIs()
          Lists the URIs of all currently loaded graphs.
 com.hp.hpl.jena.graph.Graph register(java.net.URI baseURI, com.hp.hpl.jena.graph.Graph baseGraph, java.lang.Object source, org.eclipse.core.runtime.IProgressMonitor monitor)
          Registers a given Graph.
 void removeListener(IGraphRegistryListener listener)
           
 void replaceBaseURI(java.net.URI oldURI, java.net.URI newURI)
           
 void setDirty(com.hp.hpl.jena.graph.Graph graph, boolean value)
           
 void setSource(java.net.URI baseURI, java.lang.Object source)
           
 void unregister(java.net.URI baseURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphRegistry

public GraphRegistry()
Method Detail

addListener

public void addListener(IGraphRegistryListener listener)
Specified by:
addListener in interface IGraphRegistry

dispose

public void dispose()
Specified by:
dispose in interface IGraphRegistry

disposeConfigModel

public void disposeConfigModel(java.net.URI baseURI)

dump

public void dump(java.io.PrintStream ps)

getBaseGraph

public com.hp.hpl.jena.graph.Graph getBaseGraph(com.hp.hpl.jena.graph.Graph perhapsDelegatingGraph)

getBaseURI

public java.net.URI getBaseURI(java.io.File file)
Specified by:
getBaseURI in interface IGraphRegistry

getBaseURI

public java.net.URI getBaseURI(org.eclipse.core.resources.IFile file)
Specified by:
getBaseURI in interface IGraphRegistry

getBaseURI

public java.net.URI getBaseURI(com.hp.hpl.jena.graph.Graph graph)
Specified by:
getBaseURI in interface IGraphRegistry

getConfigModel

public com.hp.hpl.jena.rdf.model.Model getConfigModel(java.net.URI baseURI)
Description copied from interface: IGraphRegistry
Gets the configuration Model that holds metadata for a given Model. Note: This is work in progress and should not be used yet externally.

Specified by:
getConfigModel in interface IGraphRegistry
Parameters:
baseURI - the URI to get the config Model for
Returns:
the Config Model or null for any unregistered baseURI

getConfigOntModel

public com.hp.hpl.jena.ontology.OntModel getConfigOntModel(java.net.URI baseURI)
Description copied from interface: IGraphRegistry
Gets the OntModel that contains all configuration models of subgraphs as well as the base config model and system configuration models.

Specified by:
getConfigOntModel in interface IGraphRegistry
Parameters:
baseURI - the URI to get the OntModel for
Returns:
the Config Model or null for any unregistered baseURI

getBaseGraph

public com.hp.hpl.jena.graph.Graph getBaseGraph(java.net.URI baseURI)
Specified by:
getBaseGraph in interface IGraphRegistry

getImportBaseURI

public java.net.URI getImportBaseURI(java.net.URI importedURI)
Description copied from interface: IGraphRegistry
Gets the base URI of an ontology specified by an import statement. This will first check if the URI is already registered in this ModelRegistry, e.g. when it has been loaded from a file. Otherwise, the method will resolve the URI into a URL and consult the URLRegistry to determine whether the URL can be opened to find a declared xml:base.

Specified by:
getImportBaseURI in interface IGraphRegistry
Parameters:
importedURI - the imported URI (object of an owl:imports statement)
Returns:
the URI (often identical to importedURI)

getSource

public java.lang.Object getSource(java.net.URI baseURI)
Description copied from interface: IGraphRegistry
Gets the source where a Graph (represented by its base URI) has been loaded from. If the model was loaded using the ModelLoader, then this will return one of:

Specified by:
getSource in interface IGraphRegistry
Parameters:
baseURI - the base URI of the model
Returns:
the source (IFile, java.io.File, or URL) or null

initConfigModel

public void initConfigModel(java.net.URI baseURI)

invalidateConfigOntModels

public void invalidateConfigOntModels()

isDirty

public boolean isDirty(com.hp.hpl.jena.graph.Graph graph)
Specified by:
isDirty in interface IGraphRegistry

isMemoryGraph

public boolean isMemoryGraph(com.hp.hpl.jena.graph.Graph graph)
Specified by:
isMemoryGraph in interface IGraphRegistry

listURIs

public java.util.Iterator<java.net.URI> listURIs()
Description copied from interface: IGraphRegistry
Lists the URIs of all currently loaded graphs.

Specified by:
listURIs in interface IGraphRegistry
Returns:
the open graph URIs

register

public com.hp.hpl.jena.graph.Graph register(java.net.URI baseURI,
                                            com.hp.hpl.jena.graph.Graph baseGraph,
                                            java.lang.Object source,
                                            org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface: IGraphRegistry
Registers a given Graph. This method is usually called directly after a Graph has been loaded, to announce it to the global registry. If the base Graph is not a memory graph, an implementation may create a delegating CachingGraph and use this instead of the base Graph. This is done in the default implementation - the new graph is then returned.

Specified by:
register in interface IGraphRegistry
Parameters:
baseURI - the base URI to register the new graph under
baseGraph - the base "raw" Graph
source - the source where the graph has been loaded from
monitor - an optional progress monitor (if caches are built up)
Returns:
either baseGraph or a CachingGraph that wraps it

removeListener

public void removeListener(IGraphRegistryListener listener)
Specified by:
removeListener in interface IGraphRegistry

replaceBaseURI

public void replaceBaseURI(java.net.URI oldURI,
                           java.net.URI newURI)
Specified by:
replaceBaseURI in interface IGraphRegistry

setDirty

public void setDirty(com.hp.hpl.jena.graph.Graph graph,
                     boolean value)
Specified by:
setDirty in interface IGraphRegistry

setSource

public void setSource(java.net.URI baseURI,
                      java.lang.Object source)
Specified by:
setSource in interface IGraphRegistry

unregister

public void unregister(java.net.URI baseURI)
Specified by:
unregister in interface IGraphRegistry