org.semanticweb.HermiT
Class Namespaces

java.lang.Object
  extended by org.semanticweb.HermiT.Namespaces
All Implemented Interfaces:
java.io.Serializable

public class Namespaces
extends java.lang.Object
implements java.io.Serializable

This class is responsible for mapping between URIs and "identifiers", which can be given in any of three different formats: 1) <uri> 2) prefix:localpart 3) localpart Forms 2 and 3 are dependent upon a set of namespace declarations which associates namespaces with prefices. An identifier encoded in form 2 which uses an unregistered prefix is invalid---expanding it will result in an exception. Form 3 can only be used if a "default namespace" (a namespace associated with an empty prefix) has been declared. Neither prefices nor localparts may contain colon characters.

See Also:
Serialized Form

Field Summary
private  java.util.regex.Pattern abbrPattern
           
private  java.util.Map<java.lang.String,java.lang.String> namespaceByPrefix
          The map of prefixes to the corresponding URI.
static Namespaces none
           
private  java.util.Map<java.lang.String,java.lang.String> prefixByNamespace
          The map of URIs to prefixes.
static Namespaces semanticWebNamespaces
          Commonly-used semantic web namespaces (OWL, RDF, SWRL, etc.)
private static long serialVersionUID
           
 
Constructor Summary
Namespaces(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations, Namespaces... sources)
          Create a new Namespaces object from a set of prefix declarations and a sequence of other Namespaces objects to copy.
Namespaces(java.lang.String defaultNamespace, Namespaces... sources)
          Create a new Namespaces object with declarations copied from `sources` (given in order of precedence) and using `defaultNamespace` as (surprisingly enough) a default namespace.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> getDeclarations()
          Return an unmodifiable map from prefices to their expansions.
 java.lang.String idFromUri(java.lang.String uri)
          Abbreviate the given string, which must be a full URI.
private  void init(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations, Namespaces... sources)
           
 java.lang.String uriFromId(java.lang.String id)
          Expand a full URI from `id`, which is of one of the following forms: `name`, where `name` is an identifier containing no colon characters, `prefix:name`, where `prefix` is a registered namespace prefix, or `<uri>`, where `uri` is a URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

namespaceByPrefix

private java.util.Map<java.lang.String,java.lang.String> namespaceByPrefix
The map of prefixes to the corresponding URI.


prefixByNamespace

private java.util.Map<java.lang.String,java.lang.String> prefixByNamespace
The map of URIs to prefixes.


abbrPattern

private java.util.regex.Pattern abbrPattern

semanticWebNamespaces

public static final Namespaces semanticWebNamespaces
Commonly-used semantic web namespaces (OWL, RDF, SWRL, etc.)


none

public static final Namespaces none
Constructor Detail

Namespaces

public Namespaces(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations,
                  Namespaces... sources)
Create a new Namespaces object from a set of prefix declarations and a sequence of other Namespaces objects to copy. If multiple prefices are associated with the same namespace name in `declarations`, then one of the prefices will be chosen arbitrarily as the canonical abbreviation. To bind multiple prefices to the same namespace name but use the specific prefix `p` as the canonical abbreviation, first create a Namespaces object `n` defining all the prefices and then derive a new Namespaces object from `n` and declarations for the canonical prefices.

Parameters:
prefixDeclarations - map from prefices to namespace names
sources - other declarations to include, in order of precedence

Namespaces

public Namespaces(java.lang.String defaultNamespace,
                  Namespaces... sources)
Create a new Namespaces object with declarations copied from `sources` (given in order of precedence) and using `defaultNamespace` as (surprisingly enough) a default namespace.

Method Detail

init

private void init(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations,
                  Namespaces... sources)

getDeclarations

public java.util.Map<java.lang.String,java.lang.String> getDeclarations()
Return an unmodifiable map from prefices to their expansions. Note that there is not (currently) an API to determine the "canonical" prefix for a particular namespace name which is associated with multiple prefices. (Having multiple such prefices is probably bad practice, anyway.)


idFromUri

public java.lang.String idFromUri(java.lang.String uri)
Abbreviate the given string, which must be a full URI.


uriFromId

public java.lang.String uriFromId(java.lang.String id)
Expand a full URI from `id`, which is of one of the following forms: `name`, where `name` is an identifier containing no colon characters, `prefix:name`, where `prefix` is a registered namespace prefix, or `<uri>`, where `uri` is a URI.