Class BaksmaliWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class BaksmaliWriter
    extends org.jf.dexlib2.formatter.DexFormattedWriter
    A specialized version of DexFormattedWriter that handles quoting simple names containing spaces.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected char[] buffer  
      • Fields inherited from class org.jf.dexlib2.formatter.DexFormattedWriter

        writer
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      BaksmaliWriter​(java.io.Writer writer)  
      BaksmaliWriter​(java.io.Writer writer, java.lang.String classContext)
      Constructs a new BaksmaliWriter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deindent​(int indentAmount)  
      void indent​(int indentAmount)  
      org.jf.util.IndentingWriter indentingWriter()  
      protected void writeAnnotation​(org.jf.dexlib2.iface.value.AnnotationEncodedValue annotation)
      Write the given AnnotationEncodedValue.
      void writeAnnotationElements​(java.util.Collection<? extends org.jf.dexlib2.iface.AnnotationElement> annotationElements)  
      protected void writeArray​(org.jf.dexlib2.iface.value.ArrayEncodedValue array)
      Write the given ArrayEncodedValue.
      protected void writeBooleanEncodedValue​(org.jf.dexlib2.iface.value.BooleanEncodedValue encodedValue)  
      void writeCallSite​(org.jf.dexlib2.iface.reference.CallSiteReference callSiteReference)  
      protected void writeCharEncodedValue​(org.jf.dexlib2.iface.value.CharEncodedValue encodedValue)  
      protected void writeClass​(java.lang.CharSequence type)  
      protected void writeDoubleEncodedValue​(org.jf.dexlib2.iface.value.DoubleEncodedValue encodedValue)  
      void writeEncodedValue​(org.jf.dexlib2.iface.value.EncodedValue encodedValue)  
      protected void writeEnum​(org.jf.dexlib2.iface.value.EnumEncodedValue encodedValue)  
      void writeFieldDescriptor​(org.jf.dexlib2.iface.reference.FieldReference fieldReference)  
      protected void writeFloatEncodedValue​(org.jf.dexlib2.iface.value.FloatEncodedValue encodedValue)  
      protected void writeIntegralValue​(long value, java.lang.Character suffix)  
      void writeMethodDescriptor​(org.jf.dexlib2.iface.reference.MethodReference methodReference)  
      void writeSignedIntAsDec​(int value)  
      void writeSignedIntOrLongTo​(long val)  
      void writeSignedLongAsDec​(long value)  
      void writeSimpleName​(java.lang.CharSequence simpleName)  
      void writeSimpleName​(java.lang.CharSequence simpleName, boolean quoted)
      Writes the given simple name, potentially quoting it if requested.
      void writeUnsignedIntAsDec​(int value)  
      void writeUnsignedLongAsHex​(long value)  
      • Methods inherited from class org.jf.dexlib2.formatter.DexFormattedWriter

        append, append, append, close, flush, write, write, write, write, write, writeMethodHandle, writeMethodProtoDescriptor, writeQuotedString, writeReference, writeShortFieldDescriptor, writeShortMethodDescriptor, writeType
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buffer

        protected final char[] buffer
    • Constructor Detail

      • BaksmaliWriter

        public BaksmaliWriter​(java.io.Writer writer)
      • BaksmaliWriter

        public BaksmaliWriter​(java.io.Writer writer,
                              @Nullable
                              java.lang.String classContext)
        Constructs a new BaksmaliWriter
        Parameters:
        writer - The IndentingWriter to write to
        classContext - If provided, the class will be elided from any field/method descriptors whose containing class match this instance's classContext.
    • Method Detail

      • writeMethodDescriptor

        public void writeMethodDescriptor​(org.jf.dexlib2.iface.reference.MethodReference methodReference)
                                   throws java.io.IOException
        Overrides:
        writeMethodDescriptor in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeFieldDescriptor

        public void writeFieldDescriptor​(org.jf.dexlib2.iface.reference.FieldReference fieldReference)
                                  throws java.io.IOException
        Overrides:
        writeFieldDescriptor in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeClass

        protected void writeClass​(java.lang.CharSequence type)
                           throws java.io.IOException
        Overrides:
        writeClass in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeSimpleName

        public void writeSimpleName​(java.lang.CharSequence simpleName)
                             throws java.io.IOException
        Overrides:
        writeSimpleName in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeSimpleName

        public void writeSimpleName​(java.lang.CharSequence simpleName,
                                    boolean quoted)
                             throws java.io.IOException
        Writes the given simple name, potentially quoting it if requested.

        The simple name will be quoted with backticks if quoted is true

        A simple name should typically be quoted if it is meant to be human readable, and it contains spaces.

        Parameters:
        simpleName - The simple name to write. See: https://source.android.com/devices/tech/dalvik/dex-format#simplename
        Throws:
        java.io.IOException
      • writeEncodedValue

        public void writeEncodedValue​(org.jf.dexlib2.iface.value.EncodedValue encodedValue)
                               throws java.io.IOException
        Overrides:
        writeEncodedValue in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeBooleanEncodedValue

        protected void writeBooleanEncodedValue​(org.jf.dexlib2.iface.value.BooleanEncodedValue encodedValue)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIntegralValue

        protected void writeIntegralValue​(long value,
                                          @Nullable
                                          java.lang.Character suffix)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCharEncodedValue

        protected void writeCharEncodedValue​(org.jf.dexlib2.iface.value.CharEncodedValue encodedValue)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFloatEncodedValue

        protected void writeFloatEncodedValue​(org.jf.dexlib2.iface.value.FloatEncodedValue encodedValue)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDoubleEncodedValue

        protected void writeDoubleEncodedValue​(org.jf.dexlib2.iface.value.DoubleEncodedValue encodedValue)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEnum

        protected void writeEnum​(org.jf.dexlib2.iface.value.EnumEncodedValue encodedValue)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeAnnotation

        protected void writeAnnotation​(org.jf.dexlib2.iface.value.AnnotationEncodedValue annotation)
                                throws java.io.IOException
        Write the given AnnotationEncodedValue.
        Overrides:
        writeAnnotation in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeAnnotationElements

        public void writeAnnotationElements​(@Nonnull
                                            java.util.Collection<? extends org.jf.dexlib2.iface.AnnotationElement> annotationElements)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArray

        protected void writeArray​(org.jf.dexlib2.iface.value.ArrayEncodedValue array)
                           throws java.io.IOException
        Write the given ArrayEncodedValue.
        Overrides:
        writeArray in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • writeCallSite

        public void writeCallSite​(org.jf.dexlib2.iface.reference.CallSiteReference callSiteReference)
                           throws java.io.IOException
        Overrides:
        writeCallSite in class org.jf.dexlib2.formatter.DexFormattedWriter
        Throws:
        java.io.IOException
      • indentingWriter

        public org.jf.util.IndentingWriter indentingWriter()
      • writeUnsignedLongAsHex

        public void writeUnsignedLongAsHex​(long value)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSignedLongAsDec

        public void writeSignedLongAsDec​(long value)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSignedIntAsDec

        public void writeSignedIntAsDec​(int value)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUnsignedIntAsDec

        public void writeUnsignedIntAsDec​(int value)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSignedIntOrLongTo

        public void writeSignedIntOrLongTo​(long val)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • indent

        public void indent​(int indentAmount)
      • deindent

        public void deindent​(int indentAmount)