org.semanticweb.owlapi.util
Class NamespaceUtil

java.lang.Object
  extended by org.semanticweb.owlapi.util.NamespaceUtil

public class NamespaceUtil
extends java.lang.Object

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 04-Apr-2007

A utility class which can generate namespaces, local names and namespace prefixes in accordance with the XML spec.


Constructor Summary
NamespaceUtil()
           
 
Method Summary
 java.lang.String generatePrefix(java.lang.String namespace)
          Generates a candidate prefix for the specified namespace.
 java.util.Map<java.lang.String,java.lang.String> getNamespace2PrefixMap()
           
 java.lang.String getPrefix(java.lang.String namespace)
          Gets a prefix for the given namespace.
static boolean isDigit(char ch)
           
static boolean isLetter(char ch)
           
static boolean isNCNameChar(char ch)
           
static boolean isNCNameStartChar(char ch)
           
 void setPrefix(java.lang.String namespace, java.lang.String prefix)
          Sets the prefix for the specified namespace.
 java.lang.String[] split(java.lang.String s, java.lang.String[] result)
          Splits a string into a namespace and local name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceUtil

public NamespaceUtil()
Method Detail

isLetter

public static boolean isLetter(char ch)

isDigit

public static boolean isDigit(char ch)

isNCNameChar

public static boolean isNCNameChar(char ch)

isNCNameStartChar

public static boolean isNCNameStartChar(char ch)

split

public java.lang.String[] split(java.lang.String s,
                                java.lang.String[] result)
Splits a string into a namespace and local name.

Parameters:
s - The string to be split.
result - May be null. If not null the method will fill the array with the result and return the passed in array. This allows a String array to be reused. If this parameter is null then a new String array will be created to hold the result. The size of the array must be 2
Returns:
The result of the split. The first element corresponds to the namespace and the second element corresponds to the local name. If the string could not be split into a namespace and local name then the first element will be an empty string and the second element will an empty string

getPrefix

public java.lang.String getPrefix(java.lang.String namespace)
Gets a prefix for the given namespace. If a mapping has not been specified then a prefix will be computed and stored for the specified namespace.

Parameters:
namespace - The namespace whose prefix is to be retrieved.
Returns:
The prefix for the specified namespace.

getNamespace2PrefixMap

public java.util.Map<java.lang.String,java.lang.String> getNamespace2PrefixMap()

generatePrefix

public java.lang.String generatePrefix(java.lang.String namespace)
Generates a candidate prefix for the specified namespace.

Parameters:
namespace - The namespace that a prefix should be generated for. The implementation attempts to generate a prefix based on the namespace. If it cannot do this, a prefix of the form pn is generated, where n is an integer.
Returns:
The generated prefix. Note that this method will not store the namespace -> prefix mapping.

setPrefix

public void setPrefix(java.lang.String namespace,
                      java.lang.String prefix)
Sets the prefix for the specified namespace. This will override any computed prefix and take precedence over any computed prefix.

Parameters:
namespace - The namespace whose prefix is to be set.
prefix - The prefix for the namespace