Package adams.flow.core
Class ActorPath
- java.lang.Object
-
- adams.flow.core.ActorPath
-
- All Implemented Interfaces:
Serializable,Comparable<ActorPath>
public class ActorPath extends Object implements Comparable<ActorPath>, Serializable
Breaks up a string denoting a full name of an actor into the individual path elements.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_FullPaththe full path.protected String[]m_Partsthe elements of the path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ActorPath o)Compares this object with the specified object for order.booleanequals(Object o)Checks whether the provided object is the same as this one.ActorPathgetChildPath()Returns the path without the first element.ActorPathgetCommonAncestor(ActorPath actorPath)Returns the path that denotes the common ancestor of this and the specified actor path.StringgetFirstPathComponent()Returns the first path component, if available.StringgetLastPathComponent()Returns the last path component, if available.ActorPathgetParentPath()Returns the path without the last element.String[]getPath()Returns a clone of the path elements.StringgetPathComponent(int element)Returns the specified element of the path.intgetPathCount()Returns the number of path elements this path is made of.inthashCode()Returns the hashcode of the underlying array.booleanisDescendant(ActorPath actorPath)Checks whether the specified actor path is a descendant of this actor path object.booleanisEmpty()Returns whether the path is empty or not.StringtoString()Returns the path as a single string.
-
-
-
Constructor Detail
-
ActorPath
public ActorPath()
Initializes the path.
-
ActorPath
public ActorPath(String path)
Initializes the path.- Parameters:
path- the path to break up
-
ActorPath
public ActorPath(String[] path)
Initializes the path with the specified elements.- Parameters:
path- the path elements to use
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Returns whether the path is empty or not.- Returns:
- true if empty
-
getPath
public String[] getPath()
Returns a clone of the path elements.- Returns:
- the elements of the path
-
getPathCount
public int getPathCount()
Returns the number of path elements this path is made of.- Returns:
- the number of path elements
-
getPathComponent
public String getPathComponent(int element)
Returns the specified element of the path.- Parameters:
element- the index of the element to retrieve- Returns:
- the specified path element
-
getParentPath
public ActorPath getParentPath()
Returns the path without the last element.- Returns:
- the new path
-
getChildPath
public ActorPath getChildPath()
Returns the path without the first element.- Returns:
- the new path
-
getLastPathComponent
public String getLastPathComponent()
Returns the last path component, if available.- Returns:
- the last component, null if no path elements stored
-
getFirstPathComponent
public String getFirstPathComponent()
Returns the first path component, if available.- Returns:
- the first component, null if no path elements stored
-
isDescendant
public boolean isDescendant(ActorPath actorPath)
Checks whether the specified actor path is a descendant of this actor path object. A path is always a descendant of itself. [a, b, c] is a descendant of [a, b] and so is [a, b], but not [a].- Parameters:
actorPath- the path to check whether it is a descendant- Returns:
- true if a descendant
-
getCommonAncestor
public ActorPath getCommonAncestor(ActorPath actorPath)
Returns the path that denotes the common ancestor of this and the specified actor path.- Parameters:
actorPath- the actor path to get the common ancestor for- Returns:
- the common ancestor (can have length 0!)
-
compareTo
public int compareTo(ActorPath o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareToin interfaceComparable<ActorPath>- Parameters:
o- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Checks whether the provided object is the same as this one.
-
hashCode
public int hashCode()
Returns the hashcode of the underlying array.
-
-