org.semanticweb.kaon2.api
Class Namespaces

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

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

This interface contains some well-known namespaces.

See Also:
Serialized Form

Field Summary
static Namespaces INSTANCE
          The global static instance.
static java.lang.String KAON2_NS
          The namespaces for KAON2 elements.
protected  java.lang.String m_defaultNamespace
          The default namespace, of null if none is set.
protected  java.util.Map<java.lang.String,java.lang.String> m_namespaceByPrefix
          The map of prefixes to the corresponding URI.
protected  int m_nextAutomaticPrefix
          The index of the next automatic prefix.
protected  java.util.Map<java.lang.String,java.lang.String> m_prefixByNamespace
          The map of URIs to prefixes.
static java.lang.String OWL_NS
          The namespace for OWL ontologies.
static java.lang.String OWLX_NS
          The namespace for OWL XML syntax.
static java.lang.String RDF_NS
          The namespace for RDF elements.
static java.lang.String RDFS_NS
          The namespace for RDFS elements.
static java.lang.String RULEML_NS
          The namespaces for RULE-ML syntax elements.
protected static java.util.Set<java.lang.String> s_reservedPrefixes
          The set of reserved namespaces and prefixes.
protected static java.util.Map<java.lang.String,java.lang.String> s_wellKnownNamespaces
          The map of well-known namespaces and prefixes.
static java.lang.String SWRL_NS
          The namespace for SWRL elements.
static java.lang.String SWRLB_NS
          The namespace for SWRL built-ins.
static java.lang.String SWRLX_NS
          The namespace for SWRL XML syntax elements.
static java.lang.String XSD_NS
          The namespace for XSD datatypes.
 
Constructor Summary
Namespaces()
          Creates an instance of this class not containing any mappings.
Namespaces(Namespaces source)
          Creates an instance of this class not containing any mappings.
 
Method Summary
 java.lang.String abbreviateAsEntity(java.lang.String uri)
          Abbreviates given URI into the form &prefix;local_name if possible.
 java.lang.String abbreviateAsEntity(java.lang.String namespace, java.lang.String localName)
          Abbreviates given URI into the form &prefix;local_name if possible.
 java.lang.String abbreviateAsNamespace(java.lang.String uri)
          Abbreviates given URI into the form prefix:local_name if possible.
 java.lang.String abbreviateAsNamespace(java.lang.String namespace, java.lang.String localName)
          Abbreviates given namespace URI and local name into the form prefix:local_name if possible.
 java.lang.String abbreviateAsNamespaceNoDefault(java.lang.String uri)
          Abbreviates given URI into the form prefix:local_name if possible.
 java.lang.String abbreviateAsNamespaceNoDefault(java.lang.String namespace, java.lang.String localName)
          Abbreviates given URI into the form prefix:local_name if possible.
 java.lang.String ensureNamespacePrefixExists(java.lang.String uri)
          Makes sure that a prefix for given uri exists.
 java.lang.String expandString(java.lang.String string)
          Attempts to expand given string (either of the form prefix:local_name or of the form &prefix;local_name) into an URI.
 java.lang.String getAbbreviationPrefix(java.lang.String uri)
          Returns the prefix used to abbreviate the URI.
 java.lang.String getDefaultNamespace()
          Returns the default namespace.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          Returns the namespace URI for the given prefix.
protected  java.lang.String getNextNamespacePrefix()
          Returns the next new namespace prefix.
 java.lang.String getPrefixForNamespace(java.lang.String namespace)
          Returns the prefix for the given namespace URI.
static java.lang.String guessLocalName(java.lang.String uri)
          Guesses the local name of a URI.
static java.lang.String guessNamespace(java.lang.String uri)
          Guesses a namespace prefix of a URI.
static int guessNamespaceEnd(java.lang.String uri)
          Returns the index of the last characted of the namespace.
 java.util.Iterator<java.lang.String> prefixes()
          Returns the iterator of all prefixes.
 void registerPrefix(java.lang.String prefix, java.lang.String namespace)
          Registers a prefix for the URI.
 void registerStandardPrefixes()
          Registers started prefixes to this object.
 void setDefaultNamespace(java.lang.String defaultNamespace)
          Sets the default namespace.
 void unregisterPrefix(java.lang.String prefix)
          Deregisters a prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OWL_NS

public static final java.lang.String OWL_NS
The namespace for OWL ontologies.

See Also:
Constant Field Values

OWLX_NS

public static final java.lang.String OWLX_NS
The namespace for OWL XML syntax.

See Also:
Constant Field Values

XSD_NS

public static final java.lang.String XSD_NS
The namespace for XSD datatypes.

See Also:
Constant Field Values

RDF_NS

public static final java.lang.String RDF_NS
The namespace for RDF elements.

See Also:
Constant Field Values

RDFS_NS

public static final java.lang.String RDFS_NS
The namespace for RDFS elements.

See Also:
Constant Field Values

SWRL_NS

public static final java.lang.String SWRL_NS
The namespace for SWRL elements.

See Also:
Constant Field Values

SWRLB_NS

public static final java.lang.String SWRLB_NS
The namespace for SWRL built-ins.

See Also:
Constant Field Values

SWRLX_NS

public static final java.lang.String SWRLX_NS
The namespace for SWRL XML syntax elements.

See Also:
Constant Field Values

RULEML_NS

public static final java.lang.String RULEML_NS
The namespaces for RULE-ML syntax elements.

See Also:
Constant Field Values

KAON2_NS

public static final java.lang.String KAON2_NS
The namespaces for KAON2 elements.

See Also:
Constant Field Values

s_wellKnownNamespaces

protected static final java.util.Map<java.lang.String,java.lang.String> s_wellKnownNamespaces
The map of well-known namespaces and prefixes.


s_reservedPrefixes

protected static final java.util.Set<java.lang.String> s_reservedPrefixes
The set of reserved namespaces and prefixes.


INSTANCE

public static final Namespaces INSTANCE
The global static instance.


m_defaultNamespace

protected java.lang.String m_defaultNamespace
The default namespace, of null if none is set.


m_namespaceByPrefix

protected final java.util.Map<java.lang.String,java.lang.String> m_namespaceByPrefix
The map of prefixes to the corresponding URI.


m_prefixByNamespace

protected final java.util.Map<java.lang.String,java.lang.String> m_prefixByNamespace
The map of URIs to prefixes.


m_nextAutomaticPrefix

protected int m_nextAutomaticPrefix
The index of the next automatic prefix.

Constructor Detail

Namespaces

public Namespaces()
Creates an instance of this class not containing any mappings.


Namespaces

public Namespaces(Namespaces source)
Creates an instance of this class not containing any mappings.

Parameters:
source - the namespace object whose mappings are copied
Method Detail

registerStandardPrefixes

public void registerStandardPrefixes()
Registers started prefixes to this object.


setDefaultNamespace

public void setDefaultNamespace(java.lang.String defaultNamespace)
Sets the default namespace. It is used only in abbreviateAsNamespace method.

Parameters:
defaultNamespace - the default namespace

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Returns the default namespace.

Returns:
the default namespace

unregisterPrefix

public void unregisterPrefix(java.lang.String prefix)
Deregisters a prefix.

Parameters:
prefix - the prefix of the URI

registerPrefix

public void registerPrefix(java.lang.String prefix,
                           java.lang.String namespace)
Registers a prefix for the URI.

Parameters:
prefix - the prefix of the URI
namespace - the namespace URI

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
Returns the namespace URI for the given prefix.

Parameters:
prefix - the prefix
Returns:
the namespace URI for the prefix (or null if the namespace for the prefix is not registered)

getPrefixForNamespace

public java.lang.String getPrefixForNamespace(java.lang.String namespace)
Returns the prefix for the given namespace URI.

Parameters:
namespace - the namespace URI
Returns:
the prefix for the namespace URI (or null if the prefix for the namespace is not registered)

getAbbreviationPrefix

public java.lang.String getAbbreviationPrefix(java.lang.String uri)
Returns the prefix used to abbreviate the URI.

Parameters:
uri - the URI
Returns:
the prefix, or null if the URI cannot be abbreviated

abbreviateAsNamespace

public java.lang.String abbreviateAsNamespace(java.lang.String uri)
Abbreviates given URI into the form prefix:local_name if possible.

Parameters:
uri - the URI
Returns:
the abbreviated form, or the original URI if abbreviation is not possible

abbreviateAsNamespace

public java.lang.String abbreviateAsNamespace(java.lang.String namespace,
                                              java.lang.String localName)
Abbreviates given namespace URI and local name into the form prefix:local_name if possible.

Parameters:
namespace - the namespace (can be null)
localName - the local name
Returns:
the abbreviated form, or namespace+localName if abbreviation is not possible

abbreviateAsNamespaceNoDefault

public java.lang.String abbreviateAsNamespaceNoDefault(java.lang.String uri)
Abbreviates given URI into the form prefix:local_name if possible.

Parameters:
uri - the URI
Returns:
the abbreviated form, or the original URI if abbreviation is not possible

abbreviateAsNamespaceNoDefault

public java.lang.String abbreviateAsNamespaceNoDefault(java.lang.String namespace,
                                                       java.lang.String localName)
Abbreviates given URI into the form prefix:local_name if possible.

Parameters:
namespace - the namespace (can be null)
localName - the local name
Returns:
the abbreviated form, or namespace+localName if abbreviation is not possible

abbreviateAsEntity

public java.lang.String abbreviateAsEntity(java.lang.String uri)
Abbreviates given URI into the form &prefix;local_name if possible.

Parameters:
uri - the URI
Returns:
the abbreviated form, or the original URI if abbreviation is not possible

abbreviateAsEntity

public java.lang.String abbreviateAsEntity(java.lang.String namespace,
                                           java.lang.String localName)
Abbreviates given URI into the form &prefix;local_name if possible.

Parameters:
namespace - the namespace (can be null)
localName - the local name
Returns:
the abbreviated form, or namespace+localName if abbreviation is not possible

expandString

public java.lang.String expandString(java.lang.String string)
Attempts to expand given string (either of the form prefix:local_name or of the form &prefix;local_name) into an URI.

Parameters:
string - the string
Returns:
the expanded URI

prefixes

public java.util.Iterator<java.lang.String> prefixes()
Returns the iterator of all prefixes.

Returns:
all prefixes

ensureNamespacePrefixExists

public java.lang.String ensureNamespacePrefixExists(java.lang.String uri)
Makes sure that a prefix for given uri exists. If a prefix for this URI does not exist, a new prefix is generated.

Parameters:
uri - the URI
Returns:
the prefix (null if the URI does not have a namespace)

getNextNamespacePrefix

protected java.lang.String getNextNamespacePrefix()
Returns the next new namespace prefix.

Returns:
the next new namespace prefix

guessNamespaceEnd

public static int guessNamespaceEnd(java.lang.String uri)
Returns the index of the last characted of the namespace.

Parameters:
uri - the URI of the namespace
Returns:
the index of the last characted of the namespace

guessNamespace

public static java.lang.String guessNamespace(java.lang.String uri)
Guesses a namespace prefix of a URI.

Parameters:
uri - the URI for which the namespace prefix is guessed
Returns:
the namespace prefix or empty string if the prefix cannot be guessed

guessLocalName

public static java.lang.String guessLocalName(java.lang.String uri)
Guesses the local name of a URI.

Parameters:
uri - the URI for which the local name is guessed
Returns:
the local name or the whole URI if the local name cannot be guessed