Class CstString
java.lang.Object
com.android.dx.rop.cst.Constant
com.android.dx.rop.cst.TypedConstant
com.android.dx.rop.cst.CstString
- All Implemented Interfaces:
TypeBearer, ToHuman, Comparable<Constant>
Constants of type
CONSTANT_Utf8_info or CONSTANT_String_info.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CstStringnon-null;instance representing"", that is, the empty string -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcompareTo0(Constant other) Compare the values of this and another instance, which are guaranteed to be of the same class.booleangetBytes()Gets the UTF-8 value as UTF-8 encoded bytes.Gets the UTF-8 value as a string.getType()Gets the type associated with this instance.intGets the size of this instance as UTF-16 code points.intGets the size of this instance as UTF-8 code points.inthashCode()booleanReturnstrueif this instance is a category-2 constant, meaning it takes up two slots in the constant pool, orfalseif this instance is category-1.static byte[]stringToUtf8Bytes(String string) Converts a string into its MUTF-8 form.toHuman()Return the "human" string form of this instance.toQuoted()Gets the value as a human-oriented string, surrounded by double quotes.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 lengthtoString()typeName()Returns the human name for the particular type of constant this instance is.static Stringutf8BytesToString(ByteArray bytes) Converts an array of UTF-8 bytes into a string.Methods inherited from class TypedConstant
getBasicFrameType, getBasicType, getFrameType, isConstant
-
Field Details
-
EMPTY_STRING
non-null;instance representing"", that is, the empty string
-
-
Constructor Details
-
CstString
Constructs an instance from aString.- Parameters:
string-non-null;the UTF-8 value as a string
-
CstString
Constructs an instance from some UTF-8 bytes.- Parameters:
bytes-non-null;array of the UTF-8 bytes
-
-
Method Details
-
stringToUtf8Bytes
Converts a string into its MUTF-8 form. MUTF-8 differs from normal UTF-8 in the handling of character '\0' and surrogate pairs.- Parameters:
string-non-null;the string to convert- Returns:
non-null;the UTF-8 bytes for it
-
utf8BytesToString
-
equals
-
hashCode
-
compareTo0
Compare the values of this and another instance, which are guaranteed to be of the same class. Subclasses must implement this.- Specified by:
compareTo0in classConstant- Parameters:
other-non-null;the instance to compare to- Returns:
-1,0, or1, as usual for a comparison
-
toString
-
typeName
-
isCategory2
public boolean isCategory2()Returnstrueif this instance is a category-2 constant, meaning it takes up two slots in the constant pool, orfalseif this instance is category-1.- Specified by:
isCategory2in classConstant- Returns:
trueiff this instance is category-2
-
toHuman
Return the "human" string form of this instance. This is generally less "debuggy" thantoString().- Returns:
non-null;the human string form
-
toQuoted
Gets the value as a human-oriented string, surrounded by double quotes.- Returns:
non-null;the quoted string
-
toQuoted
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- Parameters:
maxLength->= 5;the maximum length of the string to return- Returns:
non-null;the quoted string
-
getString
Gets the UTF-8 value as a string. The returned string is always already interned.- Returns:
non-null;the UTF-8 value as a string
-
getBytes
Gets the UTF-8 value as UTF-8 encoded bytes.- Returns:
non-null;an array of the UTF-8 bytes
-
getUtf8Size
public int getUtf8Size()Gets the size of this instance as UTF-8 code points. That is, get the number of bytes in the UTF-8 encoding of this instance.- Returns:
>= 0;the UTF-8 size
-
getUtf16Size
public int getUtf16Size()Gets the size of this instance as UTF-16 code points. That is, get the number of 16-bit chars in the UTF-16 encoding of this instance. This is the same as thelengthof the JavaStringrepresentation of this instance.- Returns:
>= 0;the UTF-16 size
-
getType
Description copied from interface:TypeBearerGets the type associated with this instance.- Returns:
non-null;the type
-