Class AnnotatedBytes

java.lang.Object
org.jf.dexlib2.util.AnnotatedBytes
Direct Known Subclasses:
DexAnnotator

public class AnnotatedBytes extends Object
Collects/presents a set of textual annotations, each associated with a range of bytes or a specific point between bytes. Point annotations cannot occur within the middle of a range annotation, only at the endpoints, or some other area with no range annotation. Multiple point annotations can be defined for a given point. They will be printed in insertion order. Only a single range annotation may exist for any given range of bytes. Range annotations may not overlap.
  • Field Details

    • annotatations

      @Nonnull private TreeMap<Integer,AnnotatedBytes.AnnotationEndpoint> annotatations
      This defines the bytes ranges and their associated range and point annotations. A range is defined by 2 consecutive keys in the map. The first key is the inclusive start point, the second key is the exclusive end point. The range annotation for a range is associated with the first key for that range. The point annotations for a point are associated with the key at that point.
    • cursor

      private int cursor
    • indentLevel

      private int indentLevel
    • outputWidth

      private int outputWidth
      >= 40 (if used); the desired maximum output width
    • hexCols

      private int hexCols
      >= 8 (if used); the number of bytes of hex output to use in annotations
    • startLimit

      private int startLimit
    • endLimit

      private int endLimit
  • Constructor Details

    • AnnotatedBytes

      public AnnotatedBytes(int width)
  • Method Details

    • moveTo

      public void moveTo(int offset)
      Moves the cursor to a new location
      Parameters:
      offset - The offset to move to
    • moveBy

      public void moveBy(int offset)
      Moves the cursor forward or backward by some amount
      Parameters:
      offset - The amount to move the cursor
    • annotateTo

      public void annotateTo(int offset, @Nonnull String msg, Object... formatArgs)
    • annotate

      public void annotate(int length, @Nonnull String msg, Object... formatArgs)
      Add an annotation of the given length at the current location. The location
      Parameters:
      length - the length of data being annotated
      msg - the annotation message
      formatArgs - format arguments to pass to String.format
    • formatAnnotation

      private String formatAnnotation(int offset, String annotationMsg)
    • formatAnnotation

      private String formatAnnotation(int offset, Integer endOffset, String annotationMsg)
    • indent

      public void indent()
    • deindent

      public void deindent()
    • getCursor

      public int getCursor()
    • getAnnotationWidth

      public int getAnnotationWidth()
      Returns:
      The width of the right side containing the annotations
    • writeAnnotations

      public void writeAnnotations(Writer out, byte[] data, int offset) throws IOException
      Writes the annotated content of this instance to the given writer.
      Parameters:
      out - non-null; where to write to
      Throws:
      IOException
    • setLimit

      public void setLimit(int start, int end)
    • clearLimit

      public void clearLimit()