Class StringUtils

java.lang.Object
org.openjdk.asmtools.asmutils.StringUtils

public class StringUtils extends Object
Utility class to share common tools/methods.
  • Field Details

  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • removeCommentFrom

      public 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.
      Parameters:
      str - string that contains comments
      Returns:
      string without comments
    • Utf8ToString

      public static String Utf8ToString(String utf8, String... enclosingString)
      Converts CONSTANT_Utf8_info string to a printable string for jdis/jdes.
      Parameters:
      utf8 - UTF8 string taken from within ConstantPool of a class file
      enclosingString - 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 testing
      list - 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 printing
      length - number of bytes
      CHARS_IN_LINE - max chars in line prepared for printing
      Returns:
      list of lines for printing
      Throws:
      IOException - exception might happen while reading DataInputStream
    • getPrintable

      public static List<String> getPrintable(byte[] buffer, int CHARS_IN_LINE)
      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

      public static List<String> getPrintable(String rawString, int CHARS_IN_LINE)
      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

      public static String mapToHexString(int[] array)
    • repeat

      public static String repeat(String str, int count)
    • isPrintableChar

      public static boolean isPrintableChar(char c)