Package adams.core
Class RObjectPath
- java.lang.Object
-
- adams.core.RObjectPath
-
- All Implemented Interfaces:
Serializable
,Comparable<RObjectPath>
public class RObjectPath extends Object implements Comparable<RObjectPath>, Serializable
Breaks up a string denoting a full name of an object within an R SEXP data structure into the individual path elements. TODO: [x] to indicate indices of lists/vectors- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_FullPath
the full path.protected String[]
m_Parts
the elements of the path.
-
Constructor Summary
Constructors Constructor Description RObjectPath()
Initializes the path.RObjectPath(String path)
Initializes the path.RObjectPath(String[] path)
Initializes the path with the specified elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RObjectPath
addChild(String path)
Creates a new path object that is the direct descendant of this path.int
compareTo(RObjectPath o)
Compares this object with the specified object for order.boolean
equals(Object o)
Checks whether the provided object is the same as this one.RObjectPath
getChildPath()
Returns the path without the first element.RObjectPath
getCommonAncestor(RObjectPath objectPath)
Returns the path that denotes the common ancestor of this and the specified object path.String
getFirstPathComponent()
Returns the first path component, if available.String
getLastPathComponent()
Returns the last path component, if available.RObjectPath
getParentPath()
Returns the path without the last element.String[]
getPath()
Returns a clone of the path elements.String
getPathComponent(int element)
Returns the specified element of the path.int
getPathCount()
Returns the number of path elements this path is made of.int
hashCode()
Returns the hashcode of the underlying array.boolean
isDescendant(RObjectPath objectPath)
Checks whether the specified object path is a descendant of this object path object.boolean
isEmpty()
Returns whether the path is empty or not.String
toString()
Returns the path as a single string.
-
-
-
Constructor Detail
-
RObjectPath
public RObjectPath()
Initializes the path.
-
RObjectPath
public RObjectPath(String path)
Initializes the path.- Parameters:
path
- the path to break up
-
RObjectPath
public RObjectPath(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 RObjectPath getParentPath()
Returns the path without the last element.- Returns:
- the new path
-
getChildPath
public RObjectPath 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(RObjectPath objectPath)
Checks whether the specified object path is a descendant of this object 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:
objectPath
- the path to check whether it is a descendant- Returns:
- true if a descendant
-
getCommonAncestor
public RObjectPath getCommonAncestor(RObjectPath objectPath)
Returns the path that denotes the common ancestor of this and the specified object path.- Parameters:
objectPath
- the object path to get the common ancestor for- Returns:
- the common ancestor (can have length 0!)
-
addChild
public RObjectPath addChild(String path)
Creates a new path object that is the direct descendant of this path.- Parameters:
path
- the path element to use for the child- Returns:
- the child
-
compareTo
public int compareTo(RObjectPath 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:
compareTo
in interfaceComparable<RObjectPath>
- 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.
-
-