Class HexDumper

java.lang.Object
com.comphenix.protocol.utility.HexDumper

public class HexDumper extends Object
Represents a class for printing hexadecimal dumps.
  • Constructor Details

    • HexDumper

      public HexDumper()
  • Method Details

    • defaultDumper

      public static HexDumper defaultDumper()
      Retrieve a hex dumper tuned for lines of 80 characters:
      Values
      Property Value
      Position Length 6
      Position Suffix ": "
      Delimiter " "
      Group Length 2
      Group Count 24
      Line Delimiter "\n"
      Returns:
      The default dumper.
    • lineDelimiter

      public HexDumper lineDelimiter(String lineDelimiter)
      Set the delimiter between each new line.
      Parameters:
      lineDelimiter - - the line delimiter.
      Returns:
      This instance, for chaining.
    • positionLength

      public HexDumper positionLength(int positionLength)
      Set the number of hex characters in the position.
      Parameters:
      positionLength - - number of characters, from 0 to 8.
      Returns:
      This instance, for chaining.
    • positionSuffix

      public HexDumper positionSuffix(String positionSuffix)
      Set a suffix to write after each position.
      Parameters:
      positionSuffix - - non-null string to write after the positions.
      Returns:
      This instance, for chaining.
    • delimiter

      public HexDumper delimiter(String delimiter)
      Set the delimiter to write in between each group of hexadecimal characters.
      Parameters:
      delimiter - - non-null string to write between each group.
      Returns:
      This instance, for chaining.
    • groupLength

      public HexDumper groupLength(int groupLength)
      Set the length of each group in hexadecimal characters.
      Parameters:
      groupLength - - the length of each group.
      Returns:
      This instance, for chaining.
    • groupCount

      public HexDumper groupCount(int groupCount)
      Set the number of groups in each line. This is limited by the supply of bytes in the byte array.

      Use Integer.MAX_VALUE to effectively disable lines.

      Parameters:
      groupCount - - the count of groups.
      Returns:
      This instance, for chaining.
    • appendTo

      public void appendTo(Appendable appendable, byte[] data) throws IOException
      Append the hex dump of the given data to the string builder, using the current formatting settings.
      Parameters:
      appendable - - appendable source.
      data - - the data to dump.
      Throws:
      IOException - Any underlying IO exception.
    • appendTo

      public void appendTo(Appendable appendable, byte[] data, int start, int length) throws IOException
      Append the hex dump of the given data to the string builder, using the current formatting settings.
      Parameters:
      appendable - - appendable source.
      data - - the data to dump.
      start - - the starting index of the data.
      length - - the number of bytes to dump.
      Throws:
      IOException - Any underlying IO exception.
    • appendTo

      public void appendTo(StringBuilder builder, byte[] data)
      Append the hex dump of the given data to the string builder, using the current formatting settings.
      Parameters:
      builder - - the builder.
      data - - the data to dump.
    • appendTo

      public void appendTo(StringBuilder builder, byte[] data, int start, int length)
      Append the hex dump of the given data to the string builder, using the current formatting settings.
      Parameters:
      builder - - the builder.
      data - - the data to dump.
      start - - the starting index of the data.
      length - - the number of bytes to dump.
    • getLineLength

      public int getLineLength(int byteCount)
      Calculate the length of each line.
      Parameters:
      byteCount - - the maximum number of bytes
      Returns:
      The lenght of the final line.
    • findConverter

      public static EquivalentConverter<Object> findConverter(Class<?> clazz)
      Retrieve the closest equivalent converter to a specific class.
      Parameters:
      clazz - - the class.
      Returns:
      The closest converter, or NULL if not found,
    • getPacketDescription

      public static String getPacketDescription(PacketContainer packetContainer) throws IllegalAccessException
      Retrieve a detailed string representation of the given packet.
      Parameters:
      packetContainer - - the packet to describe.
      Returns:
      The detailed description.
      Throws:
      IllegalAccessException - An error occured.