@InterfaceAudience.LimitedPrivate(value={"HDFS","MapReduce"}) @InterfaceStability.Unstable public class NodeBase extends Object implements Node
Modifier and Type | Field and Description |
---|---|
protected int |
level |
protected String |
location |
protected String |
name |
protected Node |
parent |
static char |
PATH_SEPARATOR
Path separator 47
|
static String |
PATH_SEPARATOR_STR
Path separator as a string "/"
|
static String |
ROOT
string representation of root ""
|
Constructor and Description |
---|
NodeBase()
Default constructor
|
NodeBase(String path)
Construct a node from its path
|
NodeBase(String name,
String location)
Construct a node from its name and its location
|
NodeBase(String name,
String location,
Node parent,
int level)
Construct a node from its name and its location
|
Modifier and Type | Method and Description |
---|---|
int |
getLevel() |
String |
getName() |
String |
getNetworkLocation() |
Node |
getParent() |
static String |
getPath(Node node)
Get the path of a node
|
static int |
locationToDepth(String location) |
static String |
normalize(String path)
Normalize a path by stripping off any trailing
PATH_SEPARATOR |
void |
setLevel(int level)
Set this node's level in the tree
|
void |
setNetworkLocation(String location)
Set this node's network location
|
void |
setParent(Node parent)
Set this node's parent
|
String |
toString() |
public static final char PATH_SEPARATOR
public static final String PATH_SEPARATOR_STR
public static final String ROOT
protected String name
protected String location
protected int level
protected Node parent
public NodeBase()
public NodeBase(String path)
path
- a concatenation of this node's location, the path seperator, and its namepublic NodeBase(String name, String location)
name
- this node's name (can be null, must not contain PATH_SEPARATOR
)location
- this node's locationpublic NodeBase(String name, String location, Node parent, int level)
name
- this node's name (can be null, must not contain PATH_SEPARATOR
)location
- this node's locationparent
- this node's parent nodelevel
- this node's level in the treepublic String getNetworkLocation()
getNetworkLocation
in interface Node
public void setNetworkLocation(String location)
setNetworkLocation
in interface Node
location
- the locationpublic static String getPath(Node node)
node
- a non-null nodepublic String toString()
public static String normalize(String path)
PATH_SEPARATOR
path
- path to normalize.ROOT
is returnedIllegalArgumentException
- if the first character of a non empty path
is not PATH_SEPARATOR
public Node getParent()
public void setParent(Node parent)
public int getLevel()
public void setLevel(int level)
public static int locationToDepth(String location)
Copyright © 2013 Apache Software Foundation. All rights reserved.