Package com.comphenix.protocol.utility
Class HexDumper
java.lang.Object
com.comphenix.protocol.utility.HexDumper
Represents a class for printing hexadecimal dumps.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTo(Appendable appendable, byte[] data) Append the hex dump of the given data to the string builder, using the current formatting settings.voidappendTo(Appendable appendable, byte[] data, int start, int length) Append the hex dump of the given data to the string builder, using the current formatting settings.voidappendTo(StringBuilder builder, byte[] data) Append the hex dump of the given data to the string builder, using the current formatting settings.voidappendTo(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.static HexDumperRetrieve 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"Set the delimiter to write in between each group of hexadecimal characters.static EquivalentConverter<Object> findConverter(Class<?> clazz) Retrieve the closest equivalent converter to a specific class.intgetLineLength(int byteCount) Calculate the length of each line.static StringgetPacketDescription(PacketContainer packetContainer) Retrieve a detailed string representation of the given packet.groupCount(int groupCount) Set the number of groups in each line.groupLength(int groupLength) Set the length of each group in hexadecimal characters.lineDelimiter(String lineDelimiter) Set the delimiter between each new line.positionLength(int positionLength) Set the number of hex characters in the position.positionSuffix(String positionSuffix) Set a suffix to write after each position.
-
Constructor Details
-
HexDumper
public HexDumper()
-
-
Method Details
-
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
Set the delimiter between each new line.- Parameters:
lineDelimiter- - the line delimiter.- Returns:
- This instance, for chaining.
-
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
Set a suffix to write after each position.- Parameters:
positionSuffix- - non-null string to write after the positions.- Returns:
- This instance, for chaining.
-
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
Set the length of each group in hexadecimal characters.- Parameters:
groupLength- - the length of each group.- Returns:
- This instance, for chaining.
-
groupCount
Set the number of groups in each line. This is limited by the supply of bytes in the byte array.Use
Integer.MAX_VALUEto effectively disable lines.- Parameters:
groupCount- - the count of groups.- Returns:
- This instance, for chaining.
-
appendTo
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
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
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
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
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.
-