org.topbraid.core.registry.impl
Class FileRegistry

java.lang.Object
  extended by org.topbraid.core.registry.impl.FileRegistry
All Implemented Interfaces:
IFileRegistry
Direct Known Subclasses:
TBCFileRegistry

public class FileRegistry
extends java.lang.Object
implements IFileRegistry


Constructor Summary
FileRegistry()
           
 
Method Summary
 void clearImportedURIs(org.eclipse.core.resources.IFile file)
           
protected  int compareFiles(org.eclipse.core.resources.IFile file1, org.eclipse.core.resources.IFile file2)
          Compares two files so that the preferred file is ordered before the less preferred.
 void dump(java.io.PrintStream ps)
          A debug method allowing users to see the current bindings.
 java.net.URI getBaseURI(org.eclipse.core.resources.IFile file)
          Gets the base URI that is known to be represented by a given file.
 java.util.Set<org.eclipse.core.resources.IFile> getDependingFiles(java.net.URI uri)
          Gets all files that somehow depend on a given base namespace.
 java.util.List<org.eclipse.core.resources.IFile> getFiles(java.net.URI uri)
          Gets a List of all files that are known to contain a given URI.
 java.util.Set<java.net.URI> getImportedURIs(org.eclipse.core.resources.IFile file)
          Assuming an IFile has been scanned, this method returns the owl:imports that that have been found in it.
 java.util.Set<org.eclipse.core.resources.IFile> getImportingFiles(java.net.URI uri)
           
 java.util.List<java.lang.String> getModelFileExtensions()
           
 org.eclipse.core.resources.IFile getPreferredFile(java.net.URI uri)
           
 java.lang.String getSuitableFileName(java.net.URI uri)
           
 void init()
          Initializes the FileRegistry.
protected  void inspectFile(org.eclipse.core.resources.IFile file)
           
protected  void inspectFileSafe(org.eclipse.core.resources.IFile file)
           
 boolean isModelFile(org.eclipse.core.resources.IFile file)
          Checks if a given file should be scanned for a base URI for possible inclusion in the registry.
 boolean isModelFileExtension(java.lang.String extension)
          Checks if a given extension is among the usual extensions for model files, i.e.
 java.util.Iterator<org.eclipse.core.resources.IFile> listFiles()
          Lists all files that are currently known to the registry.
 void refresh(org.eclipse.core.resources.IFile file)
          Refreshes an IFile with the latest base URI from the file.
 void register(org.eclipse.core.resources.IFile file, java.net.URI uri)
           
 void setBaseURI(org.eclipse.core.resources.IFile file, java.net.URI oldURI, java.net.URI newURI)
           
 void setImportedURIs(org.eclipse.core.resources.IFile file, java.util.Set<java.net.URI> importedURIs)
           
protected  void unregister(org.eclipse.core.resources.IFile file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileRegistry

public FileRegistry()
Method Detail

clearImportedURIs

public void clearImportedURIs(org.eclipse.core.resources.IFile file)

compareFiles

protected int compareFiles(org.eclipse.core.resources.IFile file1,
                           org.eclipse.core.resources.IFile file2)
Compares two files so that the preferred file is ordered before the less preferred. This is called for two files if they contain the same base URI, to resolve priorities. The default implementation prefers the younger of the two files (using their local time stamp).

Parameters:
file1 - the first file
file2 - the second file
Returns:
-1 if file1 is preferred over file2 etc

dump

public void dump(java.io.PrintStream ps)
A debug method allowing users to see the current bindings.


getBaseURI

public java.net.URI getBaseURI(org.eclipse.core.resources.IFile file)
Description copied from interface: IFileRegistry
Gets the base URI that is known to be represented by a given file.

Specified by:
getBaseURI in interface IFileRegistry
Parameters:
file - the file to test
Returns:
the base URI of file (if known)

getFiles

public java.util.List<org.eclipse.core.resources.IFile> getFiles(java.net.URI uri)
Description copied from interface: IFileRegistry
Gets a List of all files that are known to contain a given URI.

Specified by:
getFiles in interface IFileRegistry
Parameters:
uri - the URI to get the files for
Returns:
a List of IFiles, with the most suitable match in the beginning

getDependingFiles

public java.util.Set<org.eclipse.core.resources.IFile> getDependingFiles(java.net.URI uri)
Description copied from interface: IFileRegistry
Gets all files that somehow depend on a given base namespace. This includes the files that directly or indirectly import the URI.

Specified by:
getDependingFiles in interface IFileRegistry
Parameters:
uri - the base URI
Returns:
a Set of registered IFiles

getImportedURIs

public java.util.Set<java.net.URI> getImportedURIs(org.eclipse.core.resources.IFile file)
Description copied from interface: IFileRegistry
Assuming an IFile has been scanned, this method returns the owl:imports that that have been found in it. If the file has already been opened into memory, then the values from the actual model are taken.

Specified by:
getImportedURIs in interface IFileRegistry
Parameters:
file - the file to get the imported URIs from
Returns:
a Set of URIs

getImportingFiles

public java.util.Set<org.eclipse.core.resources.IFile> getImportingFiles(java.net.URI uri)
Specified by:
getImportingFiles in interface IFileRegistry

getModelFileExtensions

public java.util.List<java.lang.String> getModelFileExtensions()
Specified by:
getModelFileExtensions in interface IFileRegistry

getPreferredFile

public org.eclipse.core.resources.IFile getPreferredFile(java.net.URI uri)
Specified by:
getPreferredFile in interface IFileRegistry

getSuitableFileName

public java.lang.String getSuitableFileName(java.net.URI uri)
Specified by:
getSuitableFileName in interface IFileRegistry

init

public void init()
Initializes the FileRegistry. This will inspect all files in the current Workspace.

Specified by:
init in interface IFileRegistry

inspectFile

protected void inspectFile(org.eclipse.core.resources.IFile file)
                    throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

inspectFileSafe

protected void inspectFileSafe(org.eclipse.core.resources.IFile file)

isModelFile

public boolean isModelFile(org.eclipse.core.resources.IFile file)
Description copied from interface: IFileRegistry
Checks if a given file should be scanned for a base URI for possible inclusion in the registry. This will call the helper method isModelFileExtension() if the given file has an extension, otherwise return false.

Specified by:
isModelFile in interface IFileRegistry
Parameters:
file - the file to test
Returns:
true if file should be scanned
See Also:
IFileRegistry.isModelFileExtension(String)

isModelFileExtension

public boolean isModelFileExtension(java.lang.String extension)
Description copied from interface: IFileRegistry
Checks if a given extension is among the usual extensions for model files, i.e. "owl", "rdf" or "rdfs".

Specified by:
isModelFileExtension in interface IFileRegistry
Parameters:
extension - the extension to check (not null)
Returns:
true iff the extension is among the model extensions

listFiles

public java.util.Iterator<org.eclipse.core.resources.IFile> listFiles()
Description copied from interface: IFileRegistry
Lists all files that are currently known to the registry.

Specified by:
listFiles in interface IFileRegistry
Returns:
an Iterator of IFiles

refresh

public void refresh(org.eclipse.core.resources.IFile file)
Description copied from interface: IFileRegistry
Refreshes an IFile with the latest base URI from the file.

Specified by:
refresh in interface IFileRegistry
Parameters:
file - the file to refresh

register

public void register(org.eclipse.core.resources.IFile file,
                     java.net.URI uri)
Specified by:
register in interface IFileRegistry

setBaseURI

public void setBaseURI(org.eclipse.core.resources.IFile file,
                       java.net.URI oldURI,
                       java.net.URI newURI)
Specified by:
setBaseURI in interface IFileRegistry

setImportedURIs

public void setImportedURIs(org.eclipse.core.resources.IFile file,
                            java.util.Set<java.net.URI> importedURIs)

unregister

protected void unregister(org.eclipse.core.resources.IFile file)