Class NameAsPathCoder

java.lang.Object
com.emc.documentum.rest.utils.NameAsPathCoder

public class NameAsPathCoder extends Object
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 Details

    • encode

      public static String encode(String name)
      Encode a name, e.g. user name. The name will be encoded twice by URLEncoder.encode(String, String) to make the special characters passing correctly in the URI.
      Parameters:
      name - the textual name
      Returns:
      the encoded name
    • decode

      public static String decode(String path)
      Decode a path value into name. The path value will be decoded once by URLDecoder.decode(String, String)
      Parameters:
      path - the URI path value
      Returns:
      the decoded name