org.talend.esb.servicelocator.client.internal
Class NodePath

java.lang.Object
  extended by org.talend.esb.servicelocator.client.internal.NodePath

public class NodePath
extends Object

Representation of a ZooKeeper node path. The path is always absolute. As node names in ZooKeeper must not contain the path separator ("/") NodePath takes care to encode the names, so they can be stored in ZooKeeper.


Field Summary
static char SEPARATOR
           
 
Constructor Summary
protected NodePath(NodePath parentPath, String childPathSegment)
           
protected NodePath(NodePath parentPath, String childPathSegment, boolean encoded)
           
  NodePath(String... pathSegments)
          Create an NodePath that consists of the given path segments.
 
Method Summary
 NodePath child(String childNodeName)
          Create a NodePath, which is a child of this one.
protected  NodePath child(String childNodeName, boolean encoded)
          Create a NodePath, which is a child of this one.
static String decode(String encoded)
          Decode the given String.
static String encode(String raw)
          Encode the given String.
 boolean equals(Object obj)
           
 int hashCode()
           
 String toString()
          Encoded String representation of this NodePath.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPARATOR

public static final char SEPARATOR
See Also:
Constant Field Values
Constructor Detail

NodePath

public NodePath(String... pathSegments)
Create an NodePath that consists of the given path segments.

Parameters:
pathSegments - the sequence of path segments the NodePath consists of, must not be null or empty

NodePath

protected NodePath(NodePath parentPath,
                   String childPathSegment)

NodePath

protected NodePath(NodePath parentPath,
                   String childPathSegment,
                   boolean encoded)
Method Detail

child

public NodePath child(String childNodeName)
Create a NodePath, which is a child of this one.

Parameters:
childNodeName - name of the child node, must not be null

child

protected NodePath child(String childNodeName,
                         boolean encoded)
Create a NodePath, which is a child of this one.

Parameters:
childNodeName - name of the child node, must not be null

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Encoded String representation of this NodePath.

Overrides:
toString in class Object
Returns:
the String representation

encode

public static String encode(String raw)
Encode the given String. All occurrences of "/" are mapped to "%2A" and all occurrences of "%" to "%2F".

Parameters:
raw - the String to encode, must not be null
Returns:
the encoded version
See Also:
decode(String)

decode

public static String decode(String encoded)
Decode the given String. It is the inverse operation of encode(String). For all Strings s, decode(encode(s)).equals(s) should be true.

Parameters:
encoded - the String to decode, must not be null
Returns:
the raw version
See Also:
encode(String)


Copyright © 2011-2012 Talend Inc.. All Rights Reserved.