Class Atom
java.lang.Object
com.ibm.wala.core.util.strings.Atom
- All Implemented Interfaces:
Serializable
An utf8-encoded byte string.
Atom's are interned (canonicalized) so they may be compared for equality using the "==" operator.
Atoms are used to represent names, descriptors, and string literals appearing in a class's constant pool.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturn array descriptor corresponding to "this" array-element descriptor.static Atom
concat
(byte c, ImmutableByteArray b) static Atom
boolean
contains
(byte b) boolean
static Atom
findOrCreate
(byte[] bytes) static Atom
findOrCreate
(byte[] utf8, int off, int len) create an Atom from utf8[off] of length lenstatic Atom
static Atom
findOrCreate
(ImmutableByteArray b, int start, int length) static Atom
Find or create an atom.static Atom
Find or create an atom.static Atom
findOrCreateUtf8Atom
(byte[] utf8) Find or create an atom.byte
getVal
(int i) byte[]
return an array of bytes representing the utf8 characters in thisint
hashCode()
boolean
Is "this" atom an array descriptor?static boolean
boolean
Is "this" atom a class descriptor?boolean
Is "this" atom a method descriptor?boolean
Is "this" atom a reserved member name? Note: Sun has reserved all member names starting with '<' for future use.left
(int count) New Atom containing first count bytesint
length()
int
Parse "this" array descriptor to obtain number of dimensions in corresponding array type.Parse "this" array descriptor to obtain descriptor for array's element type.Return the innermost element type reference for an arrayright
(int count) New Atom containing last count bytesint
rIndex
(byte b) boolean
startsWith
(Atom start) toString()
Return printable representation of "this" atom.Return printable representation of "this" atom.
-
Method Details
-
findOrCreateUnicodeAtom
-
findOrCreateAsciiAtom
Find or create an atom.- Parameters:
str
- atom value, as string literal whose characters are from ascii subset of unicode (not including null)- Returns:
- atom
- Throws:
IllegalArgumentException
- if str is null
-
findOrCreateUtf8Atom
Find or create an atom.- Parameters:
utf8
- atom value, as utf8 encoded bytes- Returns:
- atom
- Throws:
IllegalArgumentException
- if utf8 is null
-
findOrCreate
public static Atom findOrCreate(byte[] utf8, int off, int len) throws IllegalArgumentException, IllegalArgumentException, IllegalArgumentException create an Atom from utf8[off] of length len- Throws:
IllegalArgumentException
- if utf8.length <= off
-
findOrCreate
-
findOrCreate
-
findOrCreate
-
toString
-
toUnicodeString
Return printable representation of "this" atom.- Throws:
UTFDataFormatException
-
left
New Atom containing first count bytes -
right
New Atom containing last count bytes -
startsWith
-
arrayDescriptorFromElementDescriptor
Return array descriptor corresponding to "this" array-element descriptor. this: array-element descriptor - something like "I" or "Ljava/lang/Object;"- Returns:
- array descriptor - something like "[I" or "[Ljava/lang/Object;"
-
isReservedMemberName
public boolean isReservedMemberName()Is "this" atom a reserved member name? Note: Sun has reserved all member names starting with '<' for future use. At present, only <init> and <clinit> are used. -
isClassDescriptor
public boolean isClassDescriptor()Is "this" atom a class descriptor? -
isArrayDescriptor
public boolean isArrayDescriptor()Is "this" atom an array descriptor? -
isMethodDescriptor
Is "this" atom a method descriptor?- Throws:
IllegalArgumentException
-
length
public int length() -
parseForArrayElementDescriptor
Parse "this" array descriptor to obtain descriptor for array's element type. this: array descriptor - something like "[I"- Returns:
- array element descriptor - something like "I"
- Throws:
IllegalArgumentException
-
parseForArrayDimensionality
Parse "this" array descriptor to obtain number of dimensions in corresponding array type. this: descriptor - something like "[Ljava/lang/String;" or "[[I"- Returns:
- dimensionality - something like "1" or "2"
- Throws:
IllegalStateException
- if this Atom does not represent an arrayIllegalArgumentException
-
parseForInnermostArrayElementDescriptor
Return the innermost element type reference for an array- Throws:
IllegalStateException
- if this Atom does not represent an array descriptorIllegalArgumentException
-
hashCode
-
equals
-
getValArray
public byte[] getValArray()return an array of bytes representing the utf8 characters in this -
getVal
- Throws:
IllegalArgumentException
-
contains
public boolean contains(byte b) - Returns:
- true iff this atom contains the specified byte
-
rIndex
public int rIndex(byte b) -
concat
-
concat
-
isArrayDescriptor
-