Class UniformItemSection

java.lang.Object
com.android.dx.dex.file.Section
com.android.dx.dex.file.UniformItemSection
Direct Known Subclasses:
CallSiteIdsSection, ClassDefsSection, HeaderSection, MemberIdsSection, MethodHandlesSection, ProtoIdsSection, StringIdsSection, TypeIdsSection

public abstract class UniformItemSection extends Section
A section of a .dex file which consists of a sequence of Item objects. Each of the items must have the same size in the output.
  • Constructor Details

    • UniformItemSection

      public UniformItemSection(String name, DexFile file, int alignment)
      Constructs an instance. The file offset is initially unknown.
      Parameters:
      name - null-ok; the name of this instance, for annotation purposes
      file - non-null; file that this instance is part of
      alignment - > 0; alignment requirement for the final output; must be a power of 2
  • Method Details

    • writeSize

      public final int writeSize()
      Gets the size of this instance when output, in bytes.
      Specified by:
      writeSize in class Section
      Returns:
      >= 0; the size of this instance, in bytes
    • get

      public abstract IndexedItem get(Constant cst)
      Gets the item corresponding to the given Constant. This will throw an exception if the constant is not found, including if this instance isn't the sort that maps constants to IndexedItem instances.
      Parameters:
      cst - non-null; constant to look for
      Returns:
      non-null; the corresponding item found in this instance
    • prepare0

      protected final void prepare0()
      Does the main work of Section.prepare().
      Specified by:
      prepare0 in class Section
    • writeTo0

      protected final void writeTo0(AnnotatedOutput out)
      Writes this instance to the given raw data object. This gets called by Section.writeTo(com.android.dx.util.AnnotatedOutput) after aligning the cursor of out and verifying that either the assigned file offset matches the actual cursor out or that the file offset was not previously assigned, in which case it gets assigned to out's cursor.
      Specified by:
      writeTo0 in class Section
      Parameters:
      out - non-null; where to write to
    • getAbsoluteItemOffset

      public final int getAbsoluteItemOffset(Item item)
      Returns the absolute file offset of the given item which must be contained in this section. This is only valid to call once this instance has been assigned a file offset (via Section.setFileOffset(int)).

      Note: Subclasses must implement this as appropriate for their contents.

      Specified by:
      getAbsoluteItemOffset in class Section
      Parameters:
      item - non-null; the item in question
      Returns:
      >= 0; the item's absolute file offset
    • orderItems

      protected abstract void orderItems()
      Alters or picks the order for items in this instance if desired, so that subsequent calls to Section.items() will yield a so-ordered collection. If the items in this instance are indexed, then this method should also assign indices.