Public Member Functions | Protected Attributes | Package Functions | Static Private Member Functions | Static Private Attributes

de.fraunhofer.isst.axbench.axlang.utilities.ElementPath Class Reference

An element path is essentially a list of aXLang-elements, considered as an aXLang-element itself. More...

List of all members.

Public Member Functions

void add (IAXLangElement newElement)
 Appends an element to the end of path and registers itself as listener to the element.
void addAll (List< IAXLangElement > newElements)
 Appends a list of elements to the end of the path.
void addAtIndex0 (IAXLangElement newElement)
 Adds an element to the path at index 0 and registers itself as listener to the element.
IAXLangElement clone ()
 Makes a shallow copy of the path (the referenced elements are not cloned).
boolean contains (IAXLangElement axlElement)
 ElementPath ()
 Constructor.
void elementRemoved (IAXLangElement axlElement)
 Reacts on removal of an element.
boolean equals (Object other)
 Defines equality.
IAXLangElement getFirstElement ()
 Returns the first element of the path.
IAXLangElement getLastElement ()
 Returns the last element of the path.
IAXLangElement getNextToLastElement ()
 Returns the next to last element of the path.
String getPathAsString ()
int hashCode ()
 Yields a hashCode.
boolean isEmpty ()
 Returns whether the path is empty, i.e. does not contain any elements.
boolean isInitialSegmentOf (ElementPath otherInstancePath)
 checks whether the path is an initial piece of another path
void removeLastElement ()
 Removes the last element of the path.
void removeNextToLastElement ()
 Removes the next to last element of the path.
List< String > toIdentifierList ()
 Returns a list of identifiers stored in the path.
List< IAXLangElementtoList ()
 Returns the list of elements building the path.
String toString ()
 Returns string representation of the instance path.

Protected Attributes

List< IAXLangElementlstPath = null
 list of aXLang elements that build the path

Package Functions

public< T extends ElementPath >
IAXLangElement 
copy ()
 Makes a shallow copy of the path (the referenced elements are not cloned).
public< T extends ElementPath > T getInitialTail ()
 Returns the "initial tail" of the path, i.e. a path without the last element.
public< T extends ElementPath > T getTail ()
 Returns the tail of the path, i.e. a path without the first element.

Static Private Member Functions

static< TextendsElementPath > T create (Class<?> pathType)
 generic creation method

Static Private Attributes

static final String PATH_SEPARATOR = "_"

Detailed Description

An element path is essentially a list of aXLang-elements, considered as an aXLang-element itself.

There are two concrete classes that extend ElementPath: InstancePath and ConnectionPath.

Remarks:
An element path is an de.fraunhofer.isst.axbench.axlang.api.IAXLangElement, in order to be accessed within elements with normal methods. The access to the path elements is implemented separately.
Todo:
Check if the normal de.fraunhofer.isst.axbench.axlang.api.IAXLangElement#addElement(IAXLangElement, ReferenceKind, Roles) methods can be used for storage of the path, similar to the parameter storage of de.fraunhofer.isst.axbench.axlang.elements.architecturemodel.Operation
Author:
cknoppek
ekleinod
mgrosse
Version:
0.8.0
Since:
0.7.2

Constructor & Destructor Documentation

de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.ElementPath (  ) 

Constructor.


Member Function Documentation

void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.add ( IAXLangElement  newElement  ) 

Appends an element to the end of path and registers itself as listener to the element.

Parameters:
newElement new element
void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.addAll ( List< IAXLangElement newElements  ) 

Appends a list of elements to the end of the path.

Remarks:
We cannot use the Collection#addAll(Collection) method for we have to add the listeners to all referenced elements via add(IAXLangElement).
Parameters:
newElements list of new elements
void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.addAtIndex0 ( IAXLangElement  newElement  ) 

Adds an element to the path at index 0 and registers itself as listener to the element.

Parameters:
newElement new element
IAXLangElement de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.clone (  ) 

Makes a shallow copy of the path (the referenced elements are not cloned).

Returns:
clone of the element

Reimplemented from de.fraunhofer.isst.axbench.axlang.api.AbstractAXLangElement.

boolean de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.contains ( IAXLangElement  axlElement  ) 
public<T extends ElementPath> IAXLangElement de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.copy (  )  [package]

Makes a shallow copy of the path (the referenced elements are not cloned).

Returns:
copy of the element
static <TextendsElementPath> T de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.create ( Class<?>  pathType  )  [static, private]

generic creation method

creates an empty path of one of the two known subtypes (InstancePath, ConnectionPath) of ElementPath

Parameters:
<T> type of the created path, must be a subtype of ElementPath
pathType desired type of the created path, must be a subtype of ElementPath
Returns:
an empty path of type pathType, provided it is a subtype of ElementPath
Return values:
returns null if pathType is neither InstancePath.class nor ConnectionPath.class
void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.elementRemoved ( IAXLangElement  axlElement  ) 

Reacts on removal of an element.

If an element of the path is removed, the whole path is invalid, it therefore has to be deleted.

  1. remove this element as listener from path elements
  2. clear path list
  3. remove path from parent

Check if parent is null, this occurs if the path was deleted before.

Parameters:
axlElement removed element
boolean de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.equals ( Object  other  ) 

Defines equality.

Paths are equal if their contents (lists) are equal.

Parameters:
other other object
Returns:
result of equality check

Reimplemented from de.fraunhofer.isst.axbench.axlang.api.AbstractAXLangElement.

IAXLangElement de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getFirstElement (  ) 

Returns the first element of the path.

Returns:
first element
Return values:
null if the path is empty
public<T extends ElementPath> T de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getInitialTail (  )  [package]

Returns the "initial tail" of the path, i.e. a path without the last element.

Remarks:
The initial tail of the path does not contain the listeners to the referenced elements.
Returns:
initial tail of the path (without listeners)
Return values:
empty path if there is no tail
IAXLangElement de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getLastElement (  ) 

Returns the last element of the path.

Returns:
last element
Return values:
null if the path is empty
IAXLangElement de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getNextToLastElement (  ) 

Returns the next to last element of the path.

Returns:
next to last element
Return values:
null if the path is to small
String de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getPathAsString (  ) 
public<T extends ElementPath> T de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.getTail (  )  [package]

Returns the tail of the path, i.e. a path without the first element.

Remarks:
The tail of the path does not contain the listeners to the referenced elements.
Returns:
tail of the path (without listeners)
Return values:
empty path if there is no tail
int de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.hashCode (  ) 

Yields a hashCode.

In order to be consistent with equals() the following parts of a path are used for the computation of the hashCode:

  • the list
Returns:
hashCode

Reimplemented from de.fraunhofer.isst.axbench.axlang.api.AbstractAXLangElement.

boolean de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.isEmpty (  ) 

Returns whether the path is empty, i.e. does not contain any elements.

Returns:
is path empty?
Return values:
true path is empty
false path is not empty
boolean de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.isInitialSegmentOf ( ElementPath  otherInstancePath  ) 

checks whether the path is an initial piece of another path

Parameters:
otherInstancePath the other (presumably longer) path this path is compared to
Returns:
true if the path is an initial piece of the other path, else false
void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.removeLastElement (  ) 

Removes the last element of the path.

Remarks:
This operations produces mostly an invalid path, therefore do not use it for purposes that require a valid path.
void de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.removeNextToLastElement (  ) 

Removes the next to last element of the path.

Remarks:
This operations produces mostly an invalid path, therefore do not use it for purposes that require a valid path.
List<String> de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.toIdentifierList (  ) 

Returns a list of identifiers stored in the path.

Returns:
list of identifiers
Return values:
empty if path is empty
List<IAXLangElement> de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.toList (  ) 

Returns the list of elements building the path.

Returns:
list of path elements
String de.fraunhofer.isst.axbench.axlang.utilities.ElementPath.toString (  ) 

Returns string representation of the instance path.

Returns:
string representation

Reimplemented from de.fraunhofer.isst.axbench.axlang.api.AbstractAXLangElement.


Member Data Documentation

list of aXLang elements that build the path