org.argouml.uml.util.namespace
Class StringNamespace

java.lang.Object
  extended byorg.argouml.uml.util.namespace.StringNamespace
All Implemented Interfaces:
Cloneable, Namespace

public class StringNamespace
extends Object
implements Namespace, Cloneable

A StringNamespace is a string based namespace (StringNamespaceElement) object. It faciliates creation of these objects via a number of helper methods.


Field Summary
private  Stack ns
           
private  String token
           
 
Fields inherited from interface org.argouml.uml.util.namespace.Namespace
CPP_NS_TOKEN, JAVA_NS_TOKEN, UML_NS_TOKEN
 
Constructor Summary
StringNamespace()
          Constructor.
StringNamespace(NamespaceElement[] elements)
          Construct a namespace from NamespaceElements with default scope token.
StringNamespace(NamespaceElement[] elements, String theToken)
          Construct a namespace from NamespaceElements with given scope token.
StringNamespace(String theToken)
          empty namespace with given default token.
StringNamespace(String[] elements)
          construct a namespace from an array of strings with default scope token.
StringNamespace(String[] elements, String theToken)
          construct a namespace from strings with given scope token.
 
Method Summary
 boolean equals(Object namespace)
          Two namespaces are equal when they are namespaces and have the same string representation.
 Namespace getBaseNamespace()
          returns the base of a namespace, e.g.
 Namespace getCommonNamespace(Namespace namespace)
          returns the namespace which is common to both namespaces, e.g.
 int hashCode()
           
 boolean isEmpty()
          check if the namespace is empty.
 Iterator iterator()
          return an iterator to the namespace elements.
static Namespace parse(Class c)
          parse the name of a (java) class.
static Namespace parse(String fqn, String token)
          parse a fully qualified namespace to create a Namespace object.
 NamespaceElement peekNamespaceElement()
          return the innermost namespace element without removing it.
 NamespaceElement popNamespaceElement()
          reduces the innermost namespace element, e.g.
 void pushNamespaceElement(NamespaceElement element)
          add another element to a namespace.
 void pushNamespaceElement(String element)
          Store the next namespace element.
 void setDefaultScopeToken(String theToken)
          namespaces usually have a scope operator when used in representational form.
 String toString()
          Create a string representation using the default scope token.
 String toString(String theToken)
          return a string representation of the namespace with the given token.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ns

private Stack ns

token

private String token
Constructor Detail

StringNamespace

public StringNamespace()
Constructor. The empty namespace with java token by default.


StringNamespace

public StringNamespace(String theToken)
empty namespace with given default token.

Parameters:
theToken - the scope seperator to use

StringNamespace

public StringNamespace(String[] elements)
construct a namespace from an array of strings with default scope token.

Parameters:
elements - an array of strings which represent the namespace.

StringNamespace

public StringNamespace(String[] elements,
                       String theToken)
construct a namespace from strings with given scope token.

Parameters:
elements - an array of strings which represent the namespace.
theToken - scope token to use

StringNamespace

public StringNamespace(NamespaceElement[] elements,
                       String theToken)
Construct a namespace from NamespaceElements with given scope token.

Parameters:
elements - array of NamespaceElements
theToken - scope token

StringNamespace

public StringNamespace(NamespaceElement[] elements)
Construct a namespace from NamespaceElements with default scope token.

Parameters:
elements - array of NamespaceElements
Method Detail

pushNamespaceElement

public void pushNamespaceElement(NamespaceElement element)
Description copied from interface: Namespace
add another element to a namespace.

Specified by:
pushNamespaceElement in interface Namespace
Parameters:
element - the element to add
See Also:
Namespace.pushNamespaceElement(NamespaceElement)

peekNamespaceElement

public NamespaceElement peekNamespaceElement()
Description copied from interface: Namespace
return the innermost namespace element without removing it.

Specified by:
peekNamespaceElement in interface Namespace
Returns:
the innermost namespace element
See Also:
Namespace.peekNamespaceElement()

pushNamespaceElement

public void pushNamespaceElement(String element)
Store the next namespace element.

Parameters:
element - The element to store.
See Also:
Namespace.popNamespaceElement()

popNamespaceElement

public NamespaceElement popNamespaceElement()
Description copied from interface: Namespace
reduces the innermost namespace element, e.g. org.argouml.model will return model, and change the namespace to org.argouml.

Specified by:
popNamespaceElement in interface Namespace
Returns:
the popped element.
See Also:
Namespace.popNamespaceElement()

getBaseNamespace

public Namespace getBaseNamespace()
Description copied from interface: Namespace
returns the base of a namespace, e.g. the base of org.argouml.util is org.argouml.

Specified by:
getBaseNamespace in interface Namespace
Returns:
base namespace
See Also:
Namespace.getBaseNamespace()

getCommonNamespace

public Namespace getCommonNamespace(Namespace namespace)
Description copied from interface: Namespace
returns the namespace which is common to both namespaces, e.g. org.argouml.model and org.argouml.util have org.argouml in common.

Specified by:
getCommonNamespace in interface Namespace
Parameters:
namespace - a namespace
Returns:
the common or empty namespace
See Also:
Namespace.getCommonNamespace( org.argouml.uml.util.namespace.Namespace)

iterator

public Iterator iterator()
Description copied from interface: Namespace
return an iterator to the namespace elements.

Specified by:
iterator in interface Namespace
Returns:
an iterator of NamespaceElements.
See Also:
Namespace.iterator()

isEmpty

public boolean isEmpty()
Description copied from interface: Namespace
check if the namespace is empty.

Specified by:
isEmpty in interface Namespace
Returns:
true if empty
See Also:
Namespace.isEmpty()

setDefaultScopeToken

public void setDefaultScopeToken(String theToken)
Description copied from interface: Namespace
namespaces usually have a scope operator when used in representational form. see also the predifined constants.

Specified by:
setDefaultScopeToken in interface Namespace
Parameters:
theToken - the token to use from now on.
See Also:
Namespace.setDefaultScopeToken(java.lang.String)

parse

public static Namespace parse(String fqn,
                              String token)
parse a fully qualified namespace to create a Namespace object.

Parameters:
fqn - string representation of namespace
token - the token of the namespace
Returns:
a namespace object

parse

public static Namespace parse(Class c)
parse the name of a (java) class.

Parameters:
c - the class
Returns:
the namespace object

hashCode

public int hashCode()
See Also:
Object.hashCode()

equals

public boolean equals(Object namespace)
Two namespaces are equal when they are namespaces and have the same string representation.

Parameters:
namespace - the namespace to compare with
Returns:
true if equal
See Also:
Object.equals(java.lang.Object)

toString

public String toString(String theToken)
Description copied from interface: Namespace
return a string representation of the namespace with the given token. The existence of the method implies that classes also must implement toString() in a reasonable manner using the default token.

Specified by:
toString in interface Namespace
Parameters:
theToken - the token to be converted
Returns:
a string representation of the namespace
See Also:
Namespace.toString(java.lang.String)

toString

public String toString()
Create a string representation using the default scope token.

See Also:
Object.toString()


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook