changeset 117:b375045a6197

Add doc comments to PatchMethodVisitor
author forax
date Mon, 04 Apr 2011 18:59:04 +0200
parents 8ae57ade33c4
children 56844aab0e5c
files src/main/java/org/icedrobot/daneel/rewriter/PatchMethodVisitor.java
diffstat 1 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/icedrobot/daneel/rewriter/PatchMethodVisitor.java	Mon Apr 04 18:57:42 2011 +0200
+++ b/src/main/java/org/icedrobot/daneel/rewriter/PatchMethodVisitor.java	Mon Apr 04 18:59:04 2011 +0200
@@ -68,6 +68,10 @@
     private final MethodVisitor mv;
     private MethodNode methodNode;
 
+    /**
+     * Create a method visitor that can be patched.
+     * @param mv the adapted method visitor.
+     */
     public PatchMethodVisitor(MethodVisitor mv) {
         this.mv = mv;
     }
@@ -105,6 +109,9 @@
     /**
      * Switch to patch mode. If the patch mode is already activated, this method
      * does nothing.
+     * 
+     * @see #getLastInsnNode()
+     * @see #patch(AbstractInsnNode, AbstractInsnNode)
      */
     public void setPatchMode() {
         if (methodNode == null) {
@@ -112,6 +119,16 @@
         }
     }
 
+    /**
+     * Returns the last instruction node added by visiting an instruction or
+     * explicitly by {@link #addNode(AbstractInsnNode)}.
+     * 
+     * @return the last instruction node added to the current visitor.
+     * @throws IllegalStateException if the {@link #setPatchMode() patch mode}
+     *         is not activated.
+     * 
+     * @see #setPatchMode()
+     */
     public AbstractInsnNode getLastInsnNode() {
         if (methodNode == null) {
             throw new IllegalStateException("patchMode is not activated");
@@ -119,6 +136,15 @@
         return methodNode.instructions.getLast();
     }
     
+    /**
+     * Adds a new instruction node to the current visitor.
+     * 
+     * @param node the instruction to add.
+     * @throws IllegalStateException if the {@link #setPatchMode() patch mode}
+     *         is not activated.
+     *         
+     * @see #setPatchMode()
+     */
     public void addNode(AbstractInsnNode node) {
         if (methodNode == null) {
             throw new IllegalStateException("patchMode is not activated");
@@ -126,6 +152,17 @@
         methodNode.instructions.add(node);
     }
 
+    /**
+     * Patch i.e. replace an instruction node previously added to
+     * a new instruction node. 
+     * 
+     * @param node node to be replaced.
+     * @param newNode node to be inserted.
+     * @throws IllegalStateException if the {@link #setPatchMode() patch mode}
+     *         is not activated.
+     *         
+     * @see #setPatchMode()
+     */
     public void patch(AbstractInsnNode node, AbstractInsnNode newNode) {
         if (methodNode == null) {
             throw new IllegalStateException("patchMode is not activated");
@@ -202,7 +239,7 @@
 
     @Override
     public void visitTableSwitchInsn(int min, int max, Label dflt,
-            Label... labels) {
+            Label[] labels) {
         mv().visitTableSwitchInsn(min, max, dflt, labels);
     }