Package com.android.dx.rop.cst
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
Modifier and TypeFieldDescriptionstatic final CstString
non-null;
instance representing""
, that is, the empty string -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
compareTo0
(Constant other) Compare the values of this and another instance, which are guaranteed to be of the same class.boolean
getBytes()
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.int
Gets the size of this instance as UTF-16 code points.int
Gets the size of this instance as UTF-8 code points.int
hashCode()
boolean
Returnstrue
if this instance is a category-2 constant, meaning it takes up two slots in the constant pool, orfalse
if 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 String
utf8BytesToString
(ByteArray bytes) Converts an array of UTF-8 bytes into a string.Methods inherited from class com.android.dx.rop.cst.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
Converts an array of UTF-8 bytes into a string.- Parameters:
bytes
-non-null;
the bytes to convert- Returns:
non-null;
the converted string
-
equals
-
hashCode
public int 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:
compareTo0
in classConstant
- Parameters:
other
-non-null;
the instance to compare to- Returns:
-1
,0
, or1
, as usual for a comparison
-
toString
-
typeName
Returns the human name for the particular type of constant this instance is. -
isCategory2
public boolean isCategory2()Returnstrue
if this instance is a category-2 constant, meaning it takes up two slots in the constant pool, orfalse
if this instance is category-1.- Specified by:
isCategory2
in classConstant
- Returns:
true
iff 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 thelength
of the JavaString
representation of this instance.- Returns:
>= 0;
the UTF-16 size
-
getType
Description copied from interface:TypeBearer
Gets the type associated with this instance.- Returns:
non-null;
the type
-