Package org.apache.hadoop.net
Class NodeBase
java.lang.Object
org.apache.hadoop.net.NodeBase
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
InnerNodeImpl
@LimitedPrivate({"HDFS","MapReduce"})
@Unstable
public class NodeBase
extends Object
implements Node
A base class that implements interface Node
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNodeBase()Default constructorConstruct a node from its pathConstruct a node from its name and its locationConstruct a node from its name and its location -
Method Summary
Modifier and TypeMethodDescriptionbooleanintgetLevel()getName()static StringGet the path of a nodestatic String[]getPathComponents(Node node) Get the path components of a node.inthashCode()static intlocationToDepth(String location) static StringNormalize a path by stripping off any trailingPATH_SEPARATORvoidsetLevel(int level) Set this node's level in the treevoidsetNetworkLocation(String location) Set this node's network locationvoidSet this node's parenttoString()
-
Field Details
-
PATH_SEPARATOR
public static final char PATH_SEPARATORPath separator '/'- See Also:
-
PATH_SEPARATOR_STR
Path separator as a string "/"- See Also:
-
ROOT
string representation of root ""- See Also:
-
name
-
location
-
level
protected int level -
parent
-
-
Constructor Details
-
NodeBase
public NodeBase()Default constructor -
NodeBase
Construct a node from its path- Parameters:
path- a concatenation of this node's location, the path separator, and its name
-
NodeBase
Construct a node from its name and its location- Parameters:
name- this node's name (can be null, must not containPATH_SEPARATOR)location- this node's location
-
NodeBase
Construct a node from its name and its location- Parameters:
name- this node's name (can be null, must not containPATH_SEPARATOR)location- this node's locationparent- this node's parent nodelevel- this node's level in the tree
-
-
Method Details
-
getName
-
getNetworkLocation
- Specified by:
getNetworkLocationin interfaceNode- Returns:
- this node's network location
-
setNetworkLocation
Set this node's network location- Specified by:
setNetworkLocationin interfaceNode- Parameters:
location- the location
-
getPath
Get the path of a node- Parameters:
node- a non-null node- Returns:
- the path of a node
-
getPathComponents
Get the path components of a node.- Parameters:
node- a non-null node- Returns:
- the path of a node
-
equals
-
hashCode
public int hashCode() -
toString
-
normalize
Normalize a path by stripping off any trailingPATH_SEPARATOR- Parameters:
path- path to normalize.- Returns:
- the normalised path
If pathis null or empty
ROOTis returned - Throws:
IllegalArgumentException- if the first character of a non empty path is notPATH_SEPARATOR
-
getParent
-
setParent
Set this node's parent -
getLevel
public int getLevel() -
setLevel
public void setLevel(int level) Set this node's level in the tree -
locationToDepth
-