public class UMLPath extends Object
INameSpace
in the composition graph.
The UMLPath
allows developers to:
UMLPath(INameSpace, String, String)
constructor.getPath(String)
method.getHierarchy()
method.
UMLPath
:
import com.modeliosoft.modelio.api.model.INameSpace;
// Model : com.tool.utils.ExampleClass (the 'com' package is localised under a root namespace)
// 1. Get a namespace in the model using its symbol representation
UMLPath examplePath = new UMLPath ("com.tool.utils.ExampleClass");
INameSpace example = examplePath.getLastElement();
// 2. Get a specific symbol from an existing namespace
String symbol = null;
if ( examplePath.isValid() )
symbol = examplePath.getPath ("."); // returns "com.tool.utils.ExampleClass"
// 3. Get the composition hierarchy
for ( INameSpace hierarchy : examplePath.getHierarchy() )
Modelio.out.println(hierarchy.getName());
Constructor and Description |
---|
UMLPath(INameSpace element)
Builds a new path using an existing hierarchy.
|
UMLPath(INameSpace rootNamespace,
String path)
Builds a UMLPath using a specific delimiter ('.')
|
UMLPath(INameSpace rootNamespace,
String path,
String delim)
Builds a new
UMLPath using a string that represent the UML path of a namespace from a root
namespace. |
Modifier and Type | Method and Description |
---|---|
List<INameSpace> |
getHierarchy()
Gets all the composition hierarchy of the namespace.
|
INameSpace |
getLastElement()
Returns the last element of the hierarchy.
|
UMLPath |
getParentPath()
Gets the UMLPath corresponding to the composition owner of the last element.
|
String |
getPath(String separator)
Gets the symbol that corresponds to the UMLPath.
|
boolean |
isValid()
Used to check that the UMLPath is valid or not.
|
public UMLPath(INameSpace rootNamespace, String path)
rootNamespace
- The initial lookup context.path
- The namespacing symbol delimited with the '.' characterUMLPath(INameSpace, String, String)
public UMLPath(INameSpace rootNamespace, String path, String delim)
UMLPath
using a string that represent the UML path of a namespace from a root
namespace.
A specific delimiter is used to split the path into specific namespace names to permit the namespace hierarchy construction.
The root namespace name must not be declared in this path.
Usage example :
// The following path is available if:
// a class named 'MyClass' exists and is defined under a 'test' package
// a package named 'test' exists and is defined under a 'com' package
// a package named 'com' exists and is defined under the root namespace
UMLPath path = new UMLPath ("com.test.MyClass");
rootNamespace
- The initial lookup context.path
- The namespacing symbol that represents the UMLPathdelim
- The delimiter that is used in the previous stringpublic UMLPath(INameSpace element)
getParentPath()
method.element
- The last element of the pathpublic List<INameSpace> getHierarchy() throws InvalidPathException
InvalidPathException
- Thrown the path references a namespace that does not exist.public INameSpace getLastElement() throws InvalidPathException, IllegalArgumentException
InvalidPathException
- if the path references a namespace that does not exist.IllegalArgumentException
- if the path contains no parent.public UMLPath getParentPath() throws InvalidPathException, IllegalArgumentException
This corresponds to the following code :
new UMLPath (apath.getLastElement().getCompositionOwner());
InvalidPathException
- if the path references a namespace that does not exist.IllegalArgumentException
- if the path contains no parent.public String getPath(String separator) throws InvalidPathException
separator
- The separator that is used to glue the namespaces names.InvalidPathException
- Thrown the path references a namespace that does not exist.public boolean isValid()