Package com.emc.documentum.rest.utils
Class NameAsPathCoder
java.lang.Object
com.emc.documentum.rest.utils.NameAsPathCoder
A name path coder to encode and decode a textural name when the name is used in the URI path.
One usage is when a textural property value is designed to be a path segment of a resource URI, the path value
should be encoded to escape special characters (e.g. '/', '.)'. A regular encoding method java.net.URLEncoder#encode(String, String)
will lead to decoding error for the special characters, so in any resource implementation that uses
a property value containing special characters as the URI path variable e.g. /users/{userName}, it is suggested to
use this class to encode and decode the property in the resource controller.
-
Method Summary
-
Method Details
-
encode
Encode a name, e.g. user name. The name will be encoded twice byURLEncoder.encode(String, String)
to make the special characters passing correctly in the URI.- Parameters:
name
- the textual name- Returns:
- the encoded name
-
decode
Decode a path value into name. The path value will be decoded once byURLDecoder.decode(String, String)
- Parameters:
path
- the URI path value- Returns:
- the decoded name
-