Class Utils

java.lang.Object
com.jugubell.bproccli.utils.Utils

public class Utils extends Object
Static class utility class for various tasks
Author:
Jugurtha Bellagh
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • isValidHexNumber

      public static boolean isValidHexNumber(String str)
      Method checking a validity of a string as hexadecimal number
      Parameters:
      str - hex number as String
      Returns:
      boolean true if hex number is valid
    • isIndirect

      public static boolean isIndirect(String str)
      Checks if an address is in indirect mode by checking ig the address is wrapped in [] Only 12bits address allowed It uses is12bitsHexData(String)
      Parameters:
      str - address as String
      Returns:
      boolean true if it is wrapped in []
    • is16bitsHexData

      public static boolean is16bitsHexData(String hex)
      Checks if a string a 16 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, H
      Parameters:
      hex - the hexadecimal number
      Returns:
      boolean true if it is a 16 bits hexadecimal number
    • is12bitsHexData

      public static boolean is12bitsHexData(String hex)
      Checks if a string a 12 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, H
      Parameters:
      hex - the hexadecimal number
      Returns:
      boolean true if it is a 12 bits hexadecimal number
    • getDataAddress

      public static String getDataAddress(String data)
      Returns the address of a given data declaration annotated with .data syntax Uses trimAddress(String) to trim the address.
      Parameters:
      data - the data line as String
      Returns:
      the address as String
    • getDataData

      public static String getDataData(String data)
      Returns the data of a given data declaration annotated with .data syntax Uses trimAddress(String) to trim the data.
      Parameters:
      data - the data line as String
      Returns:
      the data as String
    • trimAddress

      public static String trimAddress(String address)
      Trims and address from suffix, prefix, and indirect [] annotation
      Parameters:
      address - the address to be trimmed as String
      Returns:
      trimmed address as String
    • getDataAddressInt

      public static int getDataAddressInt(String data)
      Returns the address in integer of a given data declaration annotated with .data syntax. Uses getDataAddress(String) to get a clean address then converts it to an integer.
      Parameters:
      data - the data line as String
      Returns:
      address in int
    • cleanLabel

      public static String cleanLabel(String str)
      Cleans the label by removing the ':'
      Parameters:
      str - the label as String
      Returns:
      clean label as String
    • getLabelFromJmp

      public static String getLabelFromJmp(String str)
      Gets the pointed label by the JMP instruction
      Parameters:
      str - the code line of the JMP instruction
      Returns:
      the uppercased label as String
    • checkPath

      public static PathType checkPath(String pth)
      Gets the path type according to the custom path types defined in the enumeration PathType
      Parameters:
      pth - path to be checked as String
      Returns:
      the path type as PathType
    • checkPath

      public static PathType checkPath(String pth, boolean read)
    • hexFile2binFile

      public static List<String> hexFile2binFile(List<String> file)
      Converts a file hex content to a binary format. Every line of the file content should be a hexadecimal number.
      Parameters:
      file - as List of String
      Returns:
      a List of String in binary format
    • supportsColor

      public static boolean supportsColor()
      Checks if the system is not Windows for use in Log with ConsoleColor
      Returns:
      boolean false if the system is Windows