Package org.openjdk.asmtools.asmutils
Class StringUtils
java.lang.Object
org.openjdk.asmtools.asmutils.StringUtils
Utility class to share common tools/methods.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPrintable
(byte[] buffer, int CHARS_IN_LINE) getPrintable
(String rawString, int CHARS_IN_LINE) static boolean
isOneOf
(int i, char... list) Checks that ch is in the liststatic boolean
isPrintableChar
(char c) static String
mapToHexString
(int[] array) readUtf8String
(DataInputStream in, int length, int CHARS_IN_LINE) Reads the set of bytes if all bytes are printable then they will be printed as the string "String"; otherwise the byte array 0x0F 0xB6 0x00 0x11; The result is the list of lines for printing.static String
removeCommentFrom
(String str) Removes Java comments from String Spaces ahead of comments will be removed; alternatively, if no spaces precede the comment, the space after it will be deleted.static String
static String
Utf8ToString
(String utf8, String... enclosingString) Converts CONSTANT_Utf8_info string to a printable string for jdis/jdes.
-
Field Details
-
hexTable
public static final char[] hexTable -
endWith
-
contains
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
removeCommentFrom
Removes Java comments from String Spaces ahead of comments will be removed; alternatively, if no spaces precede the comment, the space after it will be deleted.- Parameters:
str
- string that contains comments- Returns:
- string without comments
-
Utf8ToString
Converts CONSTANT_Utf8_info string to a printable string for jdis/jdes.- Parameters:
utf8
- UTF8 string taken from within ConstantPool of a class fileenclosingString
- strings to enclose output string- Returns:
- output string for jcod/jasm
-
isOneOf
public static boolean isOneOf(int i, char... list) Checks that ch is in the list- Parameters:
i
- char for testinglist
- of chars- Returns:
- true if char ch found in the list
-
readUtf8String
public static List<String> readUtf8String(DataInputStream in, int length, int CHARS_IN_LINE) throws IOException Reads the set of bytes if all bytes are printable then they will be printed as the string "String"; otherwise the byte array 0x0F 0xB6 0x00 0x11; The result is the list of lines for printing.- Parameters:
in
- input stream to get bytes for printinglength
- number of bytesCHARS_IN_LINE
- max chars in line prepared for printing- Returns:
- list of lines for printing
- Throws:
IOException
- exception might happen while reading DataInputStream
-
getPrintable
- Parameters:
buffer
- array of bytes- Returns:
- null if buffer contains at least one of non-printable bytes otherwise the list of strings encoded in the buffer
-
getPrintable
- Parameters:
rawString
- String- Returns:
- null if buffer contains at least one of non-printable bytes otherwise the list of strings split by CHARS_IN_LINE
-
mapToHexString
-
repeat
-
isPrintableChar
public static boolean isPrintableChar(char c)
-