com.bbn.swede.editor.contentassist
Class NamespaceManager

java.lang.Object
  extended bycom.bbn.swede.editor.contentassist.NamespaceManager

class NamespaceManager
extends Object

This class helps to manage the mappings from namespaces to URIs and back for a particular OWL document.

Author:
aperezlo

Field Summary
static int BASE_URI
          BASE_URI used to request the base URI of the document.
static int DEFAULT_NAMESPACE
          DEFAULT_NAMESPACE - used to request the default namespace.
 
Constructor Summary
NamespaceManager()
          Default constructor.
 
Method Summary
 boolean addNamespace(Namespace ns)
          Adds a namespace to the manager.
 boolean addNamespace(String namespace, String sURI)
          Adds a namespace to the manager.
 boolean containsNamespace(String ns)
          Indicates whether the manager contains a given namespace abbreviation.
 boolean containsURI(String uri)
          Indicates whether the manager contains a given namespace URI.
 List getAllNamespaces()
          Lists all namespaces managed by this instance.
 List getAllURIs()
          Lists all namespace URIs managed by this instance.
 String getBaseURI()
          Retrieves the base URI of this document.
 String getDefaultNamespaceURI()
          Retrieves the URI of the document's default namespace.
 List getNamespacesForURI(String sURI)
          The namespace manager can support multiple aliases for a namespace abbreviation to a URI.
 String getURI(int special)
          This method retrieves one of two "special" URIs, the URI for the default namespace specified by the document, and the base URI of the document.
 String getURI(String namespace)
          Retrieves the full URI that corresponds to a namespace abbreviation in this document.
 boolean hasExplicitBase()
          Indicates whether the document has an explicit XML base.
 boolean hasExplicitDefault()
          Indicates whether the document has an explicit default namespace.
 boolean removeNamespace(String namespace)
          Removes a namespace from the manager.
 boolean removeURI(String sURI)
          This method will remove all mappings of namespaces to a particular URI.
 void setBaseURI(String newBase)
          Sets the base URI of the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE

public static final int DEFAULT_NAMESPACE
DEFAULT_NAMESPACE - used to request the default namespace.

See Also:
getDefaultNamespaceURI(), Constant Field Values

BASE_URI

public static final int BASE_URI
BASE_URI used to request the base URI of the document.

See Also:
getBaseURI(), Constant Field Values
Constructor Detail

NamespaceManager

public NamespaceManager()
Default constructor.

Method Detail

getAllNamespaces

public List getAllNamespaces()
Lists all namespaces managed by this instance.

Returns:
A java.util.List of all managed namespace abbreviations

getAllURIs

public List getAllURIs()
Lists all namespace URIs managed by this instance.

Returns:
A java.util.List of all managed namespace URIs.

hasExplicitBase

public boolean hasExplicitBase()
Indicates whether the document has an explicit XML base.

Returns:
true if this document has an explicitly declared base URI, false otherwise

hasExplicitDefault

public boolean hasExplicitDefault()
Indicates whether the document has an explicit default namespace.

Returns:
true if this document has an explicitly declared default namespace, false otherwise.

setBaseURI

public void setBaseURI(String newBase)
Sets the base URI of the document. This will also cause future calls to hasExplicitBase() to return true.

Parameters:
newBase - the new base URI

getBaseURI

public String getBaseURI()
Retrieves the base URI of this document.

Returns:
the document's base URI

addNamespace

public boolean addNamespace(Namespace ns)
Adds a namespace to the manager.

Parameters:
ns - the namespace node for which to add a mapping
Returns:
true if the namespace was sucessfully added, false otherwise

getDefaultNamespaceURI

public String getDefaultNamespaceURI()
Retrieves the URI of the document's default namespace.

Returns:
the URI of the default namespace for this manager. If no default namespace has been explicitly identified, then the base URI is returned.

addNamespace

public boolean addNamespace(String namespace,
                            String sURI)
Adds a namespace to the manager.

Parameters:
namespace - the abbreviated representation of this URI
sURI - the URI
Returns:
true if this is the first mapping to this URI, false if this URI has other aliases.

removeNamespace

public boolean removeNamespace(String namespace)
Removes a namespace from the manager.

Parameters:
namespace - the abbreviated form of the namespace mapping to remove
Returns:
true if the mapping was removed, false otherwise

containsNamespace

public boolean containsNamespace(String ns)
Indicates whether the manager contains a given namespace abbreviation.

Parameters:
ns - the abbreviated form of a URI
Returns:
true if this manager contains a mapping to a URI from the specified abbreviation, false otherwise

containsURI

public boolean containsURI(String uri)
Indicates whether the manager contains a given namespace URI.

Parameters:
uri - a URI
Returns:
true if this manager contains a mapping from a namespace abbreviation to the specified URI

removeURI

public boolean removeURI(String sURI)
This method will remove all mappings of namespaces to a particular URI.

Parameters:
sURI - the URI to remove
Returns:
true if at least one namespace was removed, false otherwise

getNamespacesForURI

public List getNamespacesForURI(String sURI)
The namespace manager can support multiple aliases for a namespace abbreviation to a URI. This method returns all of the abbreviations for a particular URI.

Parameters:
sURI - a URI
Returns:
a list of the namespaces which are abbreviations for the specified URI

getURI

public String getURI(String namespace)
Retrieves the full URI that corresponds to a namespace abbreviation in this document.

Parameters:
namespace - the namespace abbreviation for a paricular URI
Returns:
the String representation of the URI for that namespace, or null if no URI exists for that namespace

getURI

public String getURI(int special)
This method retrieves one of two "special" URIs, the URI for the default namespace specified by the document, and the base URI of the document. The parameter should be one of the static constants defined in this class, either BASE_URI or DEFAULT_NAMESPACE.

Parameters:
special - which special URI to retrieve
Returns:
the String representation of the base URI or default namespace, depending


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.