org.andromda.core.configuration
Class Namespaces

java.lang.Object
  extended byorg.andromda.core.configuration.Namespaces
All Implemented Interfaces:
Serializable

public class Namespaces
extends Object
implements Serializable

Directory of configurable Namespace objects. Namespace objects are used for configuring AndroMDA namespaces.

Author:
Chad Brandon
See Also:
Namespace, Serialized Form

Field Summary
static String DEFAULT
          This is passed as the cartridge name for the getProperty(java.lang.String, java.lang.String) method if we wish to use a 'default' Namespace for Plugins.
 
Constructor Summary
Namespaces()
           
 
Method Summary
 void addNamespace(Namespace namespace)
          Adds a namespace to this collection of namespaces.
 void addNamespaces(Namespace[] namespaces)
          Adds all namespaces to this instance.
 void addRegistry(NamespaceRegistry registry)
          Adds a namespace registry to this instance.
 void clear()
          Clears out the current namespaces.
 Namespace getNamespace(String namespaceName)
          Gets the Namespace with the corresponding namespaceName.
 Collection getNamespaceRegistries()
          Gets all available namespace registries (these are namespaces which have been discovered but are not necessarily configured).
 Collection getNamespaces()
          Gets the namespaces registered in this namespaces instance.
 Property getProperty(String namespaceName, String propertyName)
          Retrieves a property from the Namespace with the namespaceName.
 Property getProperty(String namespaceName, String propertyName, boolean showWarning)
          Retrieves a property from the Namespace with the namespaceName.
 PropertyDefinition[] getPropertyDefinitions(String namespaceName)
          Retrieves all property definitions for the given namespace.
 String getPropertyValue(String namespace, String name)
          Attempts to get the value of a property from the given namespace with the given name by first attempting to retrieve it from the namespace and if no property is defined in the namespace we retrieve the default value (if one is defined).
 NamespaceRegistry getRegistry(String namespace)
          Retrieves the namespace registry for the given namespace, or returns null if it doesn't exist.
 URL[] getResourceRoots(String namespace)
          Attempts to retrieve the resource root of the namespace.
static Namespaces instance()
          Returns the singleton instance of this Namespaces
 boolean isComponentPresent(String namespace, String component)
          Indicates whether or not the component is present within the given namespace
 boolean isShared(String namespace)
          Indicates if the given namespace is shared or not.
 boolean namespacePresent(String namespaceName)
          Indicates if the namespace is present within this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final String DEFAULT
This is passed as the cartridge name for the getProperty(java.lang.String, java.lang.String) method if we wish to use a 'default' Namespace for Plugins. This is so we don't need to define a specific mapping for each Plugin if we don't want. If a namespaceName exists with a specific Plugin name, then that will be used instead of the 'default'

See Also:
Constant Field Values
Constructor Detail

Namespaces

public Namespaces()
Method Detail

instance

public static Namespaces instance()
Returns the singleton instance of this Namespaces

Returns:
instance.

getNamespaces

public Collection getNamespaces()
Gets the namespaces registered in this namespaces instance.

Returns:
all namespaces.

addNamespace

public void addNamespace(Namespace namespace)
Adds a namespace to this collection of namespaces.

Parameters:
namespace - the Namespace to add to this instance.

addNamespaces

public void addNamespaces(Namespace[] namespaces)
Adds all namespaces to this instance.

Parameters:
namespaces - the array of namespaces to add.

getNamespace

public Namespace getNamespace(String namespaceName)
Gets the Namespace with the corresponding namespaceName.

Parameters:
namespaceName -
Returns:
the found Namespace

namespacePresent

public boolean namespacePresent(String namespaceName)
Indicates if the namespace is present within this instance.

Parameters:
namespaceName - the name of the namespace.
Returns:
true/false

getProperty

public Property getProperty(String namespaceName,
                            String propertyName)
Retrieves a property from the Namespace with the namespaceName. If the ignore attribute of the Property instance is set to true then lookup of the property will not be attempted and null will just be returned instead. If the propety is not found and ignore is not true a warning message is logged.

Parameters:
namespaceName - name of the Plugin to which the namespace applies
propertyName - name of the namespace property to find.
Returns:
String the namespace property value.

getProperty

public Property getProperty(String namespaceName,
                            String propertyName,
                            boolean showWarning)
Retrieves a property from the Namespace with the namespaceName. If the ignore attribute of the Property instance is set to true then lookup of the property will not be attempted and null will just be returned instead.

Parameters:
namespaceName - name of the Plugin to which the namespace applies
propertyName - name of the namespace property to find.
showWarning - true/false if we'd like to display a warning if the property/namespace can not be found.
Returns:
String the namespace property value.

getPropertyDefinitions

public PropertyDefinition[] getPropertyDefinitions(String namespaceName)
Retrieves all property definitions for the given namespace.

Parameters:
namespaceName - the name of the namespace.
Returns:
the list of properties contained in the namespace.

getNamespaceRegistries

public Collection getNamespaceRegistries()
Gets all available namespace registries (these are namespaces which have been discovered but are not necessarily configured).

Returns:
the collection of namespace registries

addRegistry

public void addRegistry(NamespaceRegistry registry)
Adds a namespace registry to this instance. Namespace registries contain property definitions that are defined within a NamespaceRegistry descriptor (used to describe NamespaceComponent) instances.

Parameters:
registry - the NamespaceRegistry instance to add.

isShared

public boolean isShared(String namespace)
Indicates if the given namespace is shared or not.

Parameters:
namespace - the namespace to check.
Returns:
true/false.

getPropertyValue

public String getPropertyValue(String namespace,
                               String name)
Attempts to get the value of a property from the given namespace with the given name by first attempting to retrieve it from the namespace and if no property is defined in the namespace we retrieve the default value (if one is defined).

Parameters:
namespace - the namespace for which to retreive the value.
name - the name of the value to retrieve.
Returns:
the value (or null if one couldn't be retrieved).

getResourceRoots

public URL[] getResourceRoots(String namespace)
Attempts to retrieve the resource root of the namespace. The resource root is the directory or archive root which contains all namespace resources.

Parameters:
namespace - the namespace of which to retrieve the resource.
Returns:
the resource or null if it could not be found.

isComponentPresent

public boolean isComponentPresent(String namespace,
                                  String component)
Indicates whether or not the component is present within the given namespace

Parameters:
namespace - the name of the namespace.
component - the name of the component type.
Returns:
true/false

getRegistry

public NamespaceRegistry getRegistry(String namespace)
Retrieves the namespace registry for the given namespace, or returns null if it doesn't exist.

Parameters:
namespace - the namespace name.
Returns:
the registry, or null if not found.

clear

public void clear()
Clears out the current namespaces.



Copyright © 2003-2006 The AndroMDA Team. All Rights Reserved.