Class UTFStringParser
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.internal.parser.v0.UTFStringParser
-
- All Implemented Interfaces:
IArrayElementParser<java.lang.String>,IValueReader
final class UTFStringParser extends java.lang.Object implements IArrayElementParser<java.lang.String>, IValueReader
Reads a UTF-8 string.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCHARSETstatic UTFStringParserINSTANCE
-
Constructor Summary
Constructors Constructor Description UTFStringParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]createArray(int length)Creates an arrayContentType<?>getValueType()java.lang.StringreadElement(byte[] bytes, Offset offset)Reads an objects from a byte array starting at a given offset.static java.lang.StringreadString(byte[] bytes, Offset offset)private static intreadUnsignedShort(byte[] bytes, int offset)java.lang.ObjectreadValue(byte[] bytes, Offset offset, long timestamp)Reads an objects from a byte array starting at a given offset.
-
-
-
Field Detail
-
CHARSET
private static final java.lang.String CHARSET
- See Also:
- Constant Field Values
-
INSTANCE
public static final UTFStringParser INSTANCE
-
-
Method Detail
-
readValue
public java.lang.Object readValue(byte[] bytes, Offset offset, long timestamp) throws InvalidJfrFileExceptionDescription copied from interface:IValueReaderReads an objects from a byte array starting at a given offset.- Specified by:
readValuein interfaceIValueReaderoffset- the offset to start read from. Will be moved to the end of the parsed datatimestamp- the timestamp of the object to read- Returns:
- the parsed object
- Throws:
InvalidJfrFileException
-
readElement
public java.lang.String readElement(byte[] bytes, Offset offset) throws InvalidJfrFileExceptionDescription copied from interface:IArrayElementParserReads an objects from a byte array starting at a given offset.- Specified by:
readElementin interfaceIArrayElementParser<java.lang.String>- Parameters:
bytes- the data to read the element fromoffset- the offset to start read from. Will be moved to the end of the parsed data- Returns:
- the parsed element
- Throws:
InvalidJfrFileException
-
readString
public static java.lang.String readString(byte[] bytes, Offset offset) throws InvalidJfrFileException- Throws:
InvalidJfrFileException
-
readUnsignedShort
private static int readUnsignedShort(byte[] bytes, int offset)
-
createArray
public java.lang.String[] createArray(int length)
Description copied from interface:IArrayElementParserCreates an array- Specified by:
createArrayin interfaceIArrayElementParser<java.lang.String>- Parameters:
length- the length of the array to create- Returns:
-
getValueType
public ContentType<?> getValueType()
- Specified by:
getValueTypein interfaceIValueReader- Returns:
- the content type of the created objects
-
-