Class UTFUtils
java.lang.Object
org.jboss.marshalling.UTFUtils
Handy utility methods for dealing with strings in the modified UTF-8 format.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final UTFUtils.BytesHolderprivate static final Stringprivate static final Stringprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longGet the number of bytes used by the modified UTF-8 encoded form of the given string.static intGet the number of bytes used by the modified UTF-8 encoded form of the given string.static StringreadUTFBytes(ByteInput input, int len) Read the given number of characters from the given byte input.static StringreadUTFBytesByByteCount(ByteInput input, long len) Read the given number of characters from the given byte input.private static intreadUTFChar(ByteInput input) static StringreadUTFZBytes(ByteInput input) Read a null-terminated modified UTF-8 string from the given byte input.static voidwriteUTFBytes(ByteOutput output, String s) Write the modified UTF-8 form of the given string to the given output.
-
Field Details
-
INVALID_BYTE
- See Also:
-
MALFORMED
- See Also:
-
UTF_BUFS_CHAR_CNT
private static final int UTF_BUFS_CHAR_CNT- See Also:
-
UTF_BUFS_BYTE_CNT
private static final int UTF_BUFS_BYTE_CNT- See Also:
-
BYTES_HOLDER
-
-
Constructor Details
-
UTFUtils
private UTFUtils()
-
-
Method Details
-
getShortUTFLength
Get the number of bytes used by the modified UTF-8 encoded form of the given string. If the length is greater than65536, an exception is thrown.- Parameters:
s- the string- Returns:
- the length
- Throws:
UTFDataFormatException- if the string is longer than65536characters- See Also:
-
getLongUTFLength
Get the number of bytes used by the modified UTF-8 encoded form of the given string.- Parameters:
s- the string- Returns:
- the length
- See Also:
-
writeUTFBytes
Write the modified UTF-8 form of the given string to the given output.- Parameters:
output- the output to write tos- the string- Throws:
IOException- if an I/O error occurs- See Also:
-
readUTFBytes
Read the given number of characters from the given byte input. The length given is in characters, NOT in bytes.- Parameters:
input- the byte sourcelen- the number of characters to read- Returns:
- the string
- Throws:
IOException- if an I/O error occurs- See Also:
-
readUTFBytesByByteCount
Read the given number of characters from the given byte input. The length given is in bytes.- Parameters:
input- the byte sourcelen- the number of bytes to read- Returns:
- the string
- Throws:
IOException- if an I/O error occurs- See Also:
-
readUTFZBytes
Read a null-terminated modified UTF-8 string from the given byte input. Bytes are read until a 0 is found or until the end of the stream, whichever comes first.- Parameters:
input- the input- Returns:
- the string
- Throws:
IOException- if an I/O error occurs- See Also:
-
readUTFChar
- Throws:
IOException
-