public final class CstString extends TypedConstant
CONSTANT_Utf8_info or CONSTANT_String_info.| Modifier and Type | Field and Description |
|---|---|
static CstString |
EMPTY_STRING
non-null; instance representing "", that is, the
empty string |
| Constructor and Description |
|---|
CstString(ByteArray bytes)
Constructs an instance from some UTF-8 bytes.
|
CstString(java.lang.String string)
Constructs an instance from a
String. |
| Modifier and Type | Method and Description |
|---|---|
protected int |
compareTo0(Constant other)
Compare the values of this and another instance, which are guaranteed
to be of the same class.
|
boolean |
equals(java.lang.Object other) |
ByteArray |
getBytes()
Gets the UTF-8 value as UTF-8 encoded bytes.
|
java.lang.String |
getString()
Gets the UTF-8 value as a string.
|
Type |
getType()
Gets the type associated with this instance.
|
int |
getUtf16Size()
Gets the size of this instance as UTF-16 code points.
|
int |
getUtf8Size()
Gets the size of this instance as UTF-8 code points.
|
int |
hashCode() |
boolean |
isCategory2()
Returns
true if this instance is a category-2 constant,
meaning it takes up two slots in the constant pool, or
false if this instance is category-1. |
static byte[] |
stringToUtf8Bytes(java.lang.String string)
Converts a string into its MUTF-8 form.
|
java.lang.String |
toHuman()
Return the "human" string form of this instance.
|
java.lang.String |
toQuoted()
Gets the value as a human-oriented string, surrounded by double
quotes.
|
java.lang.String |
toQuoted(int maxLength)
Gets the value as a human-oriented string, surrounded by double
quotes, but ellipsizes the result if it is longer than the given
maximum length
|
java.lang.String |
toString() |
java.lang.String |
typeName()
Returns the human name for the particular type of constant
this instance is.
|
static java.lang.String |
utf8BytesToString(ByteArray bytes)
Converts an array of UTF-8 bytes into a string.
|
getBasicFrameType, getBasicType, getFrameType, isConstantpublic static final CstString EMPTY_STRING
non-null; instance representing "", that is, the
empty stringpublic CstString(java.lang.String string)
String.string - non-null; the UTF-8 value as a stringpublic CstString(ByteArray bytes)
bytes - non-null; array of the UTF-8 bytespublic static byte[] stringToUtf8Bytes(java.lang.String string)
string - non-null; the string to convertnon-null; the UTF-8 bytes for itpublic static java.lang.String utf8BytesToString(ByteArray bytes)
bytes - non-null; the bytes to convertnon-null; the converted stringpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprotected int compareTo0(Constant other)
compareTo0 in class Constantother - non-null; the instance to compare to-1, 0, or 1, as usual
for a comparisonpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String typeName()
public boolean isCategory2()
true if this instance is a category-2 constant,
meaning it takes up two slots in the constant pool, or
false if this instance is category-1.isCategory2 in class Constanttrue iff this instance is category-2public java.lang.String toHuman()
toString().non-null; the human string formpublic java.lang.String toQuoted()
non-null; the quoted stringpublic java.lang.String toQuoted(int maxLength)
maxLength - >= 5; the maximum length of the string to returnnon-null; the quoted stringpublic java.lang.String getString()
non-null; the UTF-8 value as a stringpublic ByteArray getBytes()
non-null; an array of the UTF-8 bytespublic int getUtf8Size()
>= 0; the UTF-8 sizepublic int getUtf16Size()
length of the
Java String representation of this instance.>= 0; the UTF-16 sizepublic Type getType()
TypeBearernon-null; the typeCopyright © 2020. All Rights Reserved.