Package ghidra.util

Class StringFormat


  • public class StringFormat
    extends java.lang.Object
    Class with static methods formatting values in hex.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String hexByteString​(byte b)
      Gets a hexadecimal representation of a byte value.
      static java.lang.String hexWordString​(short s)
      Gets a hexadecimal representation of a short value.
      static java.lang.String padIt​(java.lang.String str, int padlen, char endchar, boolean padded)
      Creates a string prepended with zeros, if padding is indicated, and adds the indicated endchar as the suffix.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • hexByteString

        public static java.lang.String hexByteString​(byte b)
        Gets a hexadecimal representation of a byte value.
        Parameters:
        b - the byte value
        Returns:
        the byte as a hexadecimal string.
      • hexWordString

        public static java.lang.String hexWordString​(short s)
        Gets a hexadecimal representation of a short value.
        Parameters:
        s - the short value
        Returns:
        the short as a hexadecimal string.
      • padIt

        public static java.lang.String padIt​(java.lang.String str,
                                             int padlen,
                                             char endchar,
                                             boolean padded)
        Creates a string prepended with zeros, if padding is indicated, and adds the indicated endchar as the suffix.
        Parameters:
        str - the original string
        padlen - length of the padded string without the suffix character.
        endchar - the suffix character
        padded - if true then prepend with zeros
        Returns:
        return the possibly padded string containing the suffix.