FileDocCategorySizeDatePackage
DescendingVisitor.javaAPI DocJava SE 6 API9942Tue Jun 10 00:22:18 BST 2008com.sun.org.apache.bcel.internal.classfile

DescendingVisitor

public class DescendingVisitor extends Object implements Visitor
Traverses a JavaClass with another Visitor object 'piggy-backed' that is applied to all components of a JavaClass object. I.e. this class supplies the traversal strategy, other classes can make use of it.
version
$Id: DescendingVisitor.java,v 1.1.2.1 2005/07/31 23:46:23 jeffsuttor Exp $
author
M. Dahm

Fields Summary
private JavaClass
clazz
private Visitor
visitor
private Stack
stack
Constructors Summary
public DescendingVisitor(JavaClass clazz, Visitor visitor)

param
clazz Class to traverse
param
visitor visitor object to apply to all components

    this.clazz   = clazz;
    this.visitor = visitor;
  
Methods Summary
public java.lang.Objectcurrent()

return
current object

    return stack.peek();
  
public java.lang.Objectpredecessor()

return
container of current entitity, i.e., predecessor during traversal


              
     
    return predecessor(0);
  
public java.lang.Objectpredecessor(int level)

param
level nesting level, i.e., 0 returns the direct predecessor
return
container of current entitity, i.e., predecessor during traversal

    int size = stack.size();

    if((size < 2) || (level < 0))
      return null;
    else
      return stack.elementAt(size - (level + 2)); // size - 1 == current
  
public voidvisit()
Start traversal.

 clazz.accept(this); 
public voidvisitCode(com.sun.org.apache.bcel.internal.classfile.Code code)

    stack.push(code);
    code.accept(visitor);

    CodeException[] table = code.getExceptionTable();
    for(int i=0; i < table.length; i++)
      table[i].accept(this);

    Attribute[] attributes = code.getAttributes();
    for(int i=0; i < attributes.length; i++)
      attributes[i].accept(this);
    stack.pop();
  
public voidvisitCodeException(com.sun.org.apache.bcel.internal.classfile.CodeException ce)

    stack.push(ce);
    ce.accept(visitor);
    stack.pop();
  
public voidvisitConstantClass(com.sun.org.apache.bcel.internal.classfile.ConstantClass constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantDouble(com.sun.org.apache.bcel.internal.classfile.ConstantDouble constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantFieldref(com.sun.org.apache.bcel.internal.classfile.ConstantFieldref constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantFloat(com.sun.org.apache.bcel.internal.classfile.ConstantFloat constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
 
public voidvisitConstantInteger(com.sun.org.apache.bcel.internal.classfile.ConstantInteger constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantInterfaceMethodref(com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantLong(com.sun.org.apache.bcel.internal.classfile.ConstantLong constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantMethodref(com.sun.org.apache.bcel.internal.classfile.ConstantMethodref constant)

    stack.push(constant);
    constant.accept(visitor); 
    stack.pop();
  
public voidvisitConstantNameAndType(com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantPool(com.sun.org.apache.bcel.internal.classfile.ConstantPool cp)

    stack.push(cp);
    cp.accept(visitor);

    Constant[] constants = cp.getConstantPool();
    for(int i=1; i < constants.length; i++) {
      if(constants[i] != null)
	constants[i].accept(this);
    }

    stack.pop();
  
public voidvisitConstantString(com.sun.org.apache.bcel.internal.classfile.ConstantString constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantUtf8(com.sun.org.apache.bcel.internal.classfile.ConstantUtf8 constant)

    stack.push(constant);
    constant.accept(visitor);
    stack.pop();
  
public voidvisitConstantValue(com.sun.org.apache.bcel.internal.classfile.ConstantValue cv)

    stack.push(cv);
    cv.accept(visitor);
    stack.pop();
  
public voidvisitDeprecated(com.sun.org.apache.bcel.internal.classfile.Deprecated attribute)

    stack.push(attribute);
    attribute.accept(visitor);
    stack.pop();
  
public voidvisitExceptionTable(com.sun.org.apache.bcel.internal.classfile.ExceptionTable table)

    stack.push(table);
    table.accept(visitor);
    stack.pop();
  
public voidvisitField(com.sun.org.apache.bcel.internal.classfile.Field field)

    stack.push(field);
    field.accept(visitor);
    
    Attribute[] attributes = field.getAttributes();
    for(int i=0; i < attributes.length; i++)
      attributes[i].accept(this);
    stack.pop();
  
public voidvisitInnerClass(com.sun.org.apache.bcel.internal.classfile.InnerClass inner)

    stack.push(inner);
    inner.accept(visitor);
    stack.pop();
  
public voidvisitInnerClasses(com.sun.org.apache.bcel.internal.classfile.InnerClasses ic)

    stack.push(ic);
    ic.accept(visitor);

    InnerClass[] ics = ic.getInnerClasses();
    for(int i=0; i < ics.length; i++)
      ics[i].accept(this);
    stack.pop();
  
public voidvisitJavaClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)

    stack.push(clazz);
    clazz.accept(visitor);

    Field[] fields = clazz.getFields();
    for(int i=0; i < fields.length; i++)
      fields[i].accept(this);

    Method[] methods = clazz.getMethods();
    for(int i=0; i < methods.length; i++)
      methods[i].accept(this);

    Attribute[] attributes = clazz.getAttributes();
    for(int i=0; i < attributes.length; i++)
      attributes[i].accept(this);

    clazz.getConstantPool().accept(this);
    stack.pop();
  
public voidvisitLineNumber(com.sun.org.apache.bcel.internal.classfile.LineNumber number)

    stack.push(number);
    number.accept(visitor);
    stack.pop();
  
public voidvisitLineNumberTable(com.sun.org.apache.bcel.internal.classfile.LineNumberTable table)

    stack.push(table);
    table.accept(visitor);

    LineNumber[] numbers = table.getLineNumberTable();
    for(int i=0; i < numbers.length; i++)
      numbers[i].accept(this);
    stack.pop();
  
public voidvisitLocalVariable(com.sun.org.apache.bcel.internal.classfile.LocalVariable var)

    stack.push(var);
    var.accept(visitor);
    stack.pop();
  
public voidvisitLocalVariableTable(com.sun.org.apache.bcel.internal.classfile.LocalVariableTable table)

    stack.push(table);
    table.accept(visitor);

    LocalVariable[] vars = table.getLocalVariableTable();
    for(int i=0; i < vars.length; i++)
      vars[i].accept(this);
    stack.pop();
  
public voidvisitMethod(com.sun.org.apache.bcel.internal.classfile.Method method)

    stack.push(method);
    method.accept(visitor);
    
    Attribute[] attributes = method.getAttributes();
    for(int i=0; i < attributes.length; i++)
      attributes[i].accept(this);

    stack.pop();
  
public voidvisitSignature(com.sun.org.apache.bcel.internal.classfile.Signature attribute)

    stack.push(attribute);
    attribute.accept(visitor);
    stack.pop();
  
public voidvisitSourceFile(com.sun.org.apache.bcel.internal.classfile.SourceFile attribute)

    stack.push(attribute);
    attribute.accept(visitor);
    stack.pop();
  
public voidvisitStackMap(com.sun.org.apache.bcel.internal.classfile.StackMap table)

    stack.push(table);
    table.accept(visitor);

    StackMapEntry[] vars = table.getStackMap();

    for(int i=0; i < vars.length; i++)
      vars[i].accept(this);
    stack.pop();
  
public voidvisitStackMapEntry(com.sun.org.apache.bcel.internal.classfile.StackMapEntry var)

    stack.push(var);
    var.accept(visitor);
    stack.pop();
  
public voidvisitSynthetic(com.sun.org.apache.bcel.internal.classfile.Synthetic attribute)

    stack.push(attribute);
    attribute.accept(visitor);
    stack.pop();
  
public voidvisitUnknown(com.sun.org.apache.bcel.internal.classfile.Unknown attribute)

    stack.push(attribute);
    attribute.accept(visitor);
    stack.pop();