StringEscapeUtils

public class StringEscapeUtils
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.StringEscapeUtils


Utility class for escaping strings for specific formats. Include methods to escape strings that are being passed to the Android Shell.

Summary

Public constructors

StringEscapeUtils()

Public methods

static String escapeShell(String str)

Escapes a String for use in an Android shell command.

static List<String> paramsToArgs(List<String> params)

Converts the provided parameters via options to command line args to sub process

This method will do a simplistic generic unescape for each parameter in the list.

Public constructors

StringEscapeUtils

StringEscapeUtils ()

Public methods

escapeShell

String escapeShell (String str)

Escapes a String for use in an Android shell command.

Parameters
str String: the String to escape

Returns
String the Android shell escaped String

paramsToArgs

List<String> paramsToArgs (List<String> params)

Converts the provided parameters via options to command line args to sub process

This method will do a simplistic generic unescape for each parameter in the list. It replaces \[char] with [char]. For example, \" is converted to ". This allows string with escaped double quotes to stay as a string after being parsed by QuotationAwareTokenizer. Without this QuotationAwareTokenizer will break the string into sections if it has space in it.

Parameters
params List: parameters received via options

Returns
List<String> list of string representing command line args