Package org.apache.drill.common.util
Class DrillStringUtils
java.lang.Object
org.apache.drill.common.util.DrillStringUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
escapeJava
(String input) Escapes the characters in aString
according to Java string literal rules.static String
escapeNewLines
(String input) static String
Copied form commons-lang 2.x code as common-lang 3.x has this API removed.static int
parseBinaryString
(io.netty.buffer.ByteBuf str, int strStart, int strEnd, io.netty.buffer.ByteBuf out) parsing a hex encoded binary string and write to an output buffer.static String
readable
(long bytes) Converts the long number into more human readable string.static String
removeLeadingSlash
(String path) Removes all leading slash characters from specified string.static String
sanitizeCSV
(String csv) Removes extra spaces and empty values in a CSV Stringstatic String
toBinaryString
(byte[] buf) Return a printable representation of a byte array, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes.static String
toBinaryString
(byte[] buf, int strStart, int strEnd) Return a printable representation of a byte array, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes.static String
toBinaryString
(io.netty.buffer.ByteBuf buf, int strStart, int strEnd) Return a printable representation of a byte buffer, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes.static String
unescapeJava
(String input) Unescapes any Java literals found in theString
.
-
Constructor Details
-
DrillStringUtils
public DrillStringUtils()
-
-
Method Details
-
readable
Converts the long number into more human readable string. -
unescapeJava
Unescapes any Java literals found in theString
. For example, it will turn a sequence of'\'
and'n'
into a newline character, unless the'\'
is preceded by another'\'
.- Parameters:
input
- theString
to unescape, may be null- Returns:
- a new unescaped
String
,null
if null string input
-
escapeJava
Escapes the characters in aString
according to Java string literal rules. Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.) so, for example, a tab becomes the characters'\\'
and't'
. Example:input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\"
- Parameters:
input
- String to escape values in, may be null- Returns:
- String with escaped values,
null
if null string input
-
escapeNewLines
-
escapeSql
Copied form commons-lang 2.x code as common-lang 3.x has this API removed. (http://commons.apache.org/proper/commons-lang/article3_0.html#StringEscapeUtils.escapeSql)- Parameters:
str
-- Returns:
-
toBinaryString
Return a printable representation of a byte buffer, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes. This function does not modify thereaderIndex
andwriterIndex
of the byte buffer. -
toBinaryString
Return a printable representation of a byte array, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes. -
toBinaryString
Return a printable representation of a byte array, escaping the non-printable bytes as '\\xNN' where NN is the hexadecimal representation of such bytes. -
parseBinaryString
public static int parseBinaryString(io.netty.buffer.ByteBuf str, int strStart, int strEnd, io.netty.buffer.ByteBuf out) parsing a hex encoded binary string and write to an output buffer. This function does not modify thereaderIndex
andwriterIndex
of the byte buffer.- Returns:
- Index in the byte buffer just after the last written byte.
-
sanitizeCSV
Removes extra spaces and empty values in a CSV String- Parameters:
csv
- The CSV string to be sanitized- Returns:
- The sanitized CSV string
-
removeLeadingSlash
Removes all leading slash characters from specified string.- Parameters:
path
- string to remove all leading slash characters- Returns:
- string with removed leading slash characters
-