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.
Some of Atom's methods are deprecated. They are not used within WALA itself except by
correctness tests, and we do not believe they are used anywhere outside of WALA. If you do use
them outside of WALA, please let the WALA
maintainers know so that we don't remove them in the future.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.This method is used only by WALA's own unit tests.static Atomconcat(byte c, ImmutableByteArray b) Deprecated.This method is used only by WALA's own unit tests.static Atombooleancontains(byte b) Deprecated.This method is used only by WALA's own unit tests.booleanThese are canonicalstatic @NonNull AtomfindOrCreate(byte[] bytes) static AtomfindOrCreate(byte[] utf8, int off, int len) create an Atom from utf8[off] of length lenstatic Atomstatic AtomfindOrCreate(ImmutableByteArray b, int start, int length) Deprecated.This method is used only by WALA's own unit tests.static AtomFind or create an atom.static @NonNull AtomFind or create an atom.static AtomfindOrCreateUtf8Atom(byte[] utf8) Deprecated.This method is used only by WALA's own unit tests.bytegetVal(int i) byte[]return an array of bytes representing the utf8 characters in thisinthashCode()booleanDeprecated.This method is used only by WALA's own unit tests.static booleanDeprecated.This method is used only by WALA's own unit tests.booleanDeprecated.This method is used only by WALA's own unit tests.booleanDeprecated.This method is used only by WALA's own unit tests.booleanDeprecated.This method is used only by WALA's own unit tests.left(int count) Deprecated.This method is used only by WALA's own unit tests.intlength()intDeprecated.This method is used only by WALA's own unit tests.Deprecated.This method is used only by WALA's own unit tests.Deprecated.This method is used only by WALA's own unit tests.right(int count) New Atom containing last count bytesintrIndex(byte b) booleanstartsWith(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
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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 create an Atom from utf8[off] of length len- Throws:
IllegalArgumentException- if utf8.length <= off
-
findOrCreate
-
findOrCreate
-
findOrCreate
@Deprecated(since="1.9.0") public static Atom findOrCreate(ImmutableByteArray b, int start, int length) Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Find or create an atom fromb[start]of lengthlength.- Parameters:
b- the immutable byte arraystart- the offset of the first bytelength- the number of bytes- Returns:
- atom
-
toString
-
toUnicodeString
Return printable representation of "this" atom.- Throws:
UTFDataFormatException
-
left
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.New Atom containing first count bytes. -
right
New Atom containing last count bytes -
startsWith
-
arrayDescriptorFromElementDescriptor
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Is "this" atom a class descriptor? -
isArrayDescriptor
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Is "this" atom an array descriptor? -
isMethodDescriptor
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Is "this" atom a method descriptor?- Throws:
IllegalArgumentException
-
length
public int length() -
parseForArrayElementDescriptor
@Deprecated(since="1.9.0") public Atom parseForArrayElementDescriptor() throws IllegalArgumentExceptionDeprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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
@Deprecated(since="1.9.0") public Atom parseForInnermostArrayElementDescriptor() throws IllegalArgumentExceptionDeprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.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
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.- Returns:
- true iff this atom contains the specified byte
-
rIndex
public int rIndex(byte b) -
concat
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Concatenate a byte with an immutable byte array to form an atom.- Parameters:
c- the leading byteb- the following bytes- Returns:
- atom
-
concat
-
isArrayDescriptor
Deprecated.This method is used only by WALA's own unit tests. It may be removed in a future release.Is the given immutable byte array an array descriptor?- Parameters:
b- the immutable byte array- Returns:
- true iff the first byte is '['
-