edu.stanford.smi.protegex.owl.jena.parser
Interface URI2NameConverter

All Known Implementing Classes:
DefaultURI2NameConverter

public interface URI2NameConverter

An interface for objects that are capable of creating a Protege resource name from an URI. This is used in the Jena2Protege to convert (Jena) resource URIs into names for the corresponding Protege objects.

The use pattern of the Jena2Protege class is to first see if it can resolve a URI with the current namespace prefix definitions. For example, if a URI "http://www.w3.org/2002/07/owl#Class" is referenced, then the system can resolve this to "owl:Class", because "owl" is a defined prefix for that namespace. However, during loading, a URI may be a forward reference to a namespace which is prefixed in some other imported file, e.g. "http://aldi.de/products.owl#Apple" where the name "aldi:Apple" cannot be created yet because the corresponding namespace declaration hasn't been reached yet, or doesn't exist at all. In the latter case, the system will later create a default prefix, such as "p1". In the normal case though, the prefix will be reached later. Anyway, the resource needs to still have a name so that it can be looked up successfully in future references. So, if no default name could be resolved, the system will use a temporary name (e.g. the whole URI) and later replace the temp name with the "real" resource name.

This interface also allows to create names for anonymous resources.

Author:
Holger Knublauch

Method Summary
 String addPrefix(String uri, String prefix)
          Adds a new prefix-namespace pair to this converter.
 String createAnonymousRDFResourceName()
           
 String createNewPrefix(String uri)
          Creates a dummy prefix and adds it to the OWLModel
 String getRDFExternalResourceName()
           
 String getRDFResourceName(String uri)
          Gets the Protege resource name for a given URI.
 String getResourceNamespace(String uri)
          Gets the namespace part of a resource URI.
 String getTemporaryRDFResourceName(com.hp.hpl.jena.rdf.arp.AResource node)
           
 String getTemporaryRDFResourceName(String uri)
           
 String getURIFromTemporaryName(String temporaryName)
          The inverse of getTemporaryRDFResourceName().
 boolean isAnonymousRDFResourceName(String name)
          Checks whether a given name describes an anonymous resource.
 boolean isTemporaryRDFResourceName(String name)
          Checks if this is a name that was created as a temporary name before.
 void updateInternalState()
          Called after the triples have been copied and new namespace prefixes assigned.
 

Method Detail

addPrefix

public String addPrefix(String uri,
                        String prefix)
Adds a new prefix-namespace pair to this converter. If the namespace is already used under a different prefix then the already existing one will be used and returned. If the prefix is already used for a different namespace, then the prefix will not be used.

Parameters:
uri - the URI/namespace
prefix - the new prefix
Returns:
the prefix that will be used for the namespace

createNewPrefix

public String createNewPrefix(String uri)
Creates a dummy prefix and adds it to the OWLModel

Parameters:
uri - the URI of the resource to create a new prefix for

createAnonymousRDFResourceName

public String createAnonymousRDFResourceName()

getResourceNamespace

public String getResourceNamespace(String uri)
Gets the namespace part of a resource URI. This typically wraps the Jena namespace split algorithm.

Parameters:
uri - the URI to get the namespace of
Returns:
the namespace (usually including the '#')

getRDFExternalResourceName

public String getRDFExternalResourceName()

getRDFResourceName

public String getRDFResourceName(String uri)
Gets the Protege resource name for a given URI.

Parameters:
uri - the URI to get the name of
Returns:
the Protege name (not null)

getTemporaryRDFResourceName

public String getTemporaryRDFResourceName(String uri)

getTemporaryRDFResourceName

public String getTemporaryRDFResourceName(com.hp.hpl.jena.rdf.arp.AResource node)

getURIFromTemporaryName

public String getURIFromTemporaryName(String temporaryName)
The inverse of getTemporaryRDFResourceName().

Parameters:
temporaryName - the temporary name
Returns:
the URI encoded by the temp name

isAnonymousRDFResourceName

public boolean isAnonymousRDFResourceName(String name)
Checks whether a given name describes an anonymous resource.

Parameters:
name - the name of the resource to test
Returns:
true if name is an anonymous name

isTemporaryRDFResourceName

public boolean isTemporaryRDFResourceName(String name)
Checks if this is a name that was created as a temporary name before. Temporary names should follow a naming convention which keeps them clearly separate from real names.

Parameters:
name - the name to test
Returns:
true if name is a temporary test

updateInternalState

public void updateInternalState()
Called after the triples have been copied and new namespace prefixes assigned. This method must update the internal state of the converter to reflect possible changes during loading (e.g. add new prefixes).