Package ghidra.program.model.data
Class StringRenderBuilder
java.lang.Object
ghidra.program.model.data.StringRenderBuilder
Helper class used to build up a formatted (for human consumption) string representation returned
by Unicode and String data types.
Call toString()
to retrieve the formatted string.
Example (quotes are part of result): "Test\tstring",01,02,"Second\npart",00
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStringRenderBuilder
(int charSize) StringRenderBuilder
(int charSize, char quoteChar) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addByteSeq
(byte[] bytes) Add byte values, shown as numeric hex values.void
addCodePointChar
(int codePoint) Add a single character.void
addCodePointValue
(int codePoint) Add a single character that needs to be shown as a numeric hex value.void
addEscapedChar
(char ch) Append the specified char after an escaping backslash "\", ie "x" -> "\x";void
addEscapedCodePoint
(int codePoint) Add an unicode codepoint as its escaped hex value, with a escape character prefix of 'x', 'u' or 'U' depending on the magnitude of the codePoint value.void
Append the characters in the specified string.boolean
Returns true if the current formatted string starts with a quoted text section, instead of a byte value section.toString()
Example (quotes are part of result):"Test\tstring",01,02,"Second\npart",00
-
Field Details
-
DOUBLE_QUOTE
public static final char DOUBLE_QUOTE- See Also:
-
SINGLE_QUOTE
public static final char SINGLE_QUOTE- See Also:
-
-
Constructor Details
-
StringRenderBuilder
public StringRenderBuilder(int charSize) -
StringRenderBuilder
public StringRenderBuilder(int charSize, char quoteChar)
-
-
Method Details
-
startsWithQuotedText
public boolean startsWithQuotedText()Returns true if the current formatted string starts with a quoted text section, instead of a byte value section. Useful to indicate if the string could have a prefix applied to it (ie. u8"text")- Returns:
- boolean true if this string will start with a quoted text section
-
addString
Append the characters in the specified string. The added characters will be shown in a quoted text region.- Parameters:
str
- String to add
-
addEscapedChar
public void addEscapedChar(char ch) Append the specified char after an escaping backslash "\", ie "x" -> "\x";- Parameters:
ch
-
-
addCodePointChar
public void addCodePointChar(int codePoint) Add a single character. It will be shown in a quoted text region.- Parameters:
codePoint
- Character to add
-
addCodePointValue
public void addCodePointValue(int codePoint) Add a single character that needs to be shown as a numeric hex value.- Parameters:
codePoint
- Character to add
-
addByteSeq
public void addByteSeq(byte[] bytes) Add byte values, shown as numeric hex values.{ 0, 1, 2 } -> 00,01,02
- Parameters:
bytes
- to convert to hex and append. If null, append "???"
-
addEscapedCodePoint
public void addEscapedCodePoint(int codePoint) Add an unicode codepoint as its escaped hex value, with a escape character prefix of 'x', 'u' or 'U' depending on the magnitude of the codePoint value.codePoint 15 -> '\' 'x' "0F"
codePoint 65535 -> '\' 'u' "FFFF"
codePoint 65536 -> '\' 'U' "10000"- Parameters:
codePoint
- int value
-
toString
Example (quotes are part of result):"Test\tstring",01,02,"Second\npart",00
-