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.String
CHARSET
static UTFStringParser
INSTANCE
-
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.String
readElement(byte[] bytes, Offset offset)
Reads an objects from a byte array starting at a given offset.static java.lang.String
readString(byte[] bytes, Offset offset)
private static int
readUnsignedShort(byte[] bytes, int offset)
java.lang.Object
readValue(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 InvalidJfrFileException
Description copied from interface:IValueReader
Reads an objects from a byte array starting at a given offset.- Specified by:
readValue
in interfaceIValueReader
offset
- 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 InvalidJfrFileException
Description copied from interface:IArrayElementParser
Reads an objects from a byte array starting at a given offset.- Specified by:
readElement
in 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:IArrayElementParser
Creates an array- Specified by:
createArray
in interfaceIArrayElementParser<java.lang.String>
- Parameters:
length
- the length of the array to create- Returns:
-
getValueType
public ContentType<?> getValueType()
- Specified by:
getValueType
in interfaceIValueReader
- Returns:
- the content type of the created objects
-
-