org.ow2.asmdex.util
Class AsmDexPrinter

java.lang.Object
  extended by org.ow2.asmdex.util.AsmDexPrinter

public class AsmDexPrinter
extends java.lang.Object

An abstract visitor for the AsmDexifier.

Author:
Julien Névo, based on the ASM framework.

Field Summary
protected  int currentTabulation
          The tabulation of the current element.
protected  java.lang.StringBuffer text
          A buffer that can be used to create strings.
 
Constructor Summary
AsmDexPrinter()
           
 
Method Summary
 void addAccessFlags(int accessFlags, boolean addComma)
          Appends the Access flags to the given buffer.
 void addBoolean(boolean bool, boolean addComma)
          Adds a boolean string to the current text.
 void addComma()
          Appends a comma and a space to the current text.
 void addConstant(java.lang.Object cst, boolean addComma)
          Appends a string representation of the given constant to the given buffer, with quotes if necessary.
 void addEOL()
          Adds an End Of Line tag at the end of the current text.
 void addLabelArray(java.lang.String[] labelNames, boolean addComma)
          Adds the declaration of an Array of Labels to the current text, from their names.
 void addNumber(double nb, boolean addComma)
          Adds a long number at the end of the current text.
 void addNumber(float nb, boolean addComma)
          Adds a Float number at the end of the current text.
 void addNumber(int nb, boolean addComma)
          Adds a number at the end of the current text.
 void addNumber(long nb, boolean addComma)
          Adds a long number at the end of the current text.
 void addOpcode(int opcode, boolean addComma)
          Adds to the current text the name of the given opcode, or the number in hexadecimal if the opcode isn't known.
 void addStringArrayList(java.util.List<java.lang.String> list, boolean addComma)
          Adds the declaration of an ArrayList of Strings to the current text.
 void addTabulation()
          Adds tabulation according to the tabulation count stored in the current element.
 void addText(java.lang.String textToAdd)
          Adds a given text to the current text.
 void addText(java.lang.String textToAdd, boolean addComma)
          Adds a given text to the current text.
 void addTextToList(TextComponent tc)
          Adds the given Text Component to the list of this element.
 void appendString(java.lang.String s)
          Appends a quoted string to a given buffer.
 void closeText()
          Adds the current text to the list of texts, and resets the text.
protected  TextComponent getTextComponent()
          Returns the Text Component this element holds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentTabulation

protected int currentTabulation
The tabulation of the current element.


text

protected java.lang.StringBuffer text
A buffer that can be used to create strings.

Constructor Detail

AsmDexPrinter

public AsmDexPrinter()
Method Detail

getTextComponent

protected TextComponent getTextComponent()
Returns the Text Component this element holds.

Returns:
the Text Component this element holds.

closeText

public void closeText()
Adds the current text to the list of texts, and resets the text. Must be done for each text (or part of it) that is over.


addTextToList

public void addTextToList(TextComponent tc)
Adds the given Text Component to the list of this element.

Parameters:
tc - the Text Component to add.

addComma

public void addComma()
Appends a comma and a space to the current text.


addEOL

public void addEOL()
Adds an End Of Line tag at the end of the current text.


addBoolean

public void addBoolean(boolean bool,
                       boolean addComma)
Adds a boolean string to the current text. This last one needs to be closed (with the closeText() method) in order to be actually used.

Parameters:
bool - the boolean value to encode.
addComma - true to add a comma at the end of the text.

addText

public void addText(java.lang.String textToAdd)
Adds a given text to the current text. This last one needs to be closed (with the closeText() method) in order to be actually used.

Parameters:
textToAdd - the text to add.

addText

public void addText(java.lang.String textToAdd,
                    boolean addComma)
Adds a given text to the current text. This last one needs to be closed (with the closeText() method) in order to be actually used.

Parameters:
textToAdd - the text to add.
addComma - true to add a comma at the end of the text.

addConstant

public void addConstant(java.lang.Object cst,
                        boolean addComma)
Appends a string representation of the given constant to the given buffer, with quotes if necessary.

Parameters:
cst - a single or array of ints, Integer, Float, Long, Double or String object. May be null.
addComma - true to add a comma at the end.

addStringArrayList

public void addStringArrayList(java.util.List<java.lang.String> list,
                               boolean addComma)
Adds the declaration of an ArrayList of Strings to the current text.

Parameters:
list - the List of Strings to add.
addComma - true to add a comma at the end.

addLabelArray

public void addLabelArray(java.lang.String[] labelNames,
                          boolean addComma)
Adds the declaration of an Array of Labels to the current text, from their names.

Parameters:
labelNames - the names of the Labels.
addComma - true to add a comma at the end.

addAccessFlags

public void addAccessFlags(int accessFlags,
                           boolean addComma)
Appends the Access flags to the given buffer.

Parameters:
accessFlags - the access flags to encode.
addComma - true to add a comma at the end.

appendString

public void appendString(java.lang.String s)
Appends a quoted string to a given buffer.

Parameters:
s - the string to be added.

addNumber

public void addNumber(int nb,
                      boolean addComma)
Adds a number at the end of the current text.

Parameters:
nb - the number to add.
addComma - true to add a comma at the end.

addNumber

public void addNumber(float nb,
                      boolean addComma)
Adds a Float number at the end of the current text.

Parameters:
nb - the number to add.
addComma - true to add a comma at the end.

addNumber

public void addNumber(long nb,
                      boolean addComma)
Adds a long number at the end of the current text.

Parameters:
nb - the number to add.
addComma - true to add a comma at the end.

addNumber

public void addNumber(double nb,
                      boolean addComma)
Adds a long number at the end of the current text.

Parameters:
nb - the number to add.
addComma - true to add a comma at the end.

addOpcode

public void addOpcode(int opcode,
                      boolean addComma)
Adds to the current text the name of the given opcode, or the number in hexadecimal if the opcode isn't known.

Parameters:
opcode - the opcode.
addComma - true to add a comma after the opcode name.

addTabulation

public void addTabulation()
Adds tabulation according to the tabulation count stored in the current element.