Class Atom

java.lang.Object
com.ibm.wala.core.util.strings.Atom
All Implemented Interfaces:
Serializable

public final class Atom extends Object implements 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 Details Link icon

    • findOrCreateUnicodeAtom Link icon

      public static Atom findOrCreateUnicodeAtom(String str)
      Find or create an atom.
      Parameters:
      str - atom value, as string literal whose characters are unicode
      Returns:
      atom
    • findOrCreateAsciiAtom Link icon

      public static Atom findOrCreateAsciiAtom(String str)
      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 Link icon

      public static Atom findOrCreateUtf8Atom(byte[] utf8)
      Find or create an atom.
      Parameters:
      utf8 - atom value, as utf8 encoded bytes
      Returns:
      atom
      Throws:
      IllegalArgumentException - if utf8 is null
    • findOrCreate Link icon

      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 Link icon

      public static Atom findOrCreate(byte[] bytes)
    • findOrCreate Link icon

      public static Atom findOrCreate(ImmutableByteArray b)
    • findOrCreate Link icon

      public static Atom findOrCreate(ImmutableByteArray b, int start, int length)
    • toString Link icon

      public String toString()
      Return printable representation of "this" atom. Does not correctly handle UTF8 translation.
      Overrides:
      toString in class Object
    • toUnicodeString Link icon

      public String toUnicodeString() throws UTFDataFormatException
      Return printable representation of "this" atom.
      Throws:
      UTFDataFormatException
    • left Link icon

      public Atom left(int count)
      New Atom containing first count bytes
    • right Link icon

      public Atom right(int count)
      New Atom containing last count bytes
    • startsWith Link icon

      public boolean startsWith(Atom start)
    • arrayDescriptorFromElementDescriptor Link icon

      public Atom 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 Link icon

      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 Link icon

      public boolean isClassDescriptor()
      Is "this" atom a class descriptor?
    • isArrayDescriptor Link icon

      public boolean isArrayDescriptor()
      Is "this" atom an array descriptor?
    • isMethodDescriptor Link icon

      public boolean isMethodDescriptor() throws IllegalArgumentException
      Is "this" atom a method descriptor?
      Throws:
      IllegalArgumentException
    • length Link icon

      public int length()
    • parseForArrayElementDescriptor Link icon

      public Atom parseForArrayElementDescriptor() throws IllegalArgumentException
      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 Link icon

      public int parseForArrayDimensionality() throws IllegalArgumentException
      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 array
      IllegalArgumentException
    • parseForInnermostArrayElementDescriptor Link icon

      public Atom parseForInnermostArrayElementDescriptor() throws IllegalArgumentException
      Return the innermost element type reference for an array
      Throws:
      IllegalStateException - if this Atom does not represent an array descriptor
      IllegalArgumentException
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getValArray Link icon

      public byte[] getValArray()
      return an array of bytes representing the utf8 characters in this
    • getVal Link icon

      public byte getVal(int i) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • contains Link icon

      public boolean contains(byte b)
      Returns:
      true iff this atom contains the specified byte
    • rIndex Link icon

      public int rIndex(byte b)
    • concat Link icon

      public static Atom concat(byte c, ImmutableByteArray b)
    • concat Link icon

      public static Atom concat(Atom ma, Atom mb)
    • isArrayDescriptor Link icon

      public static boolean isArrayDescriptor(ImmutableByteArray b)