FileDocCategorySizeDatePackage
ClassMethod.javaAPI DocGlassfish v2 API5975Fri May 04 22:34:28 BST 2007com.sun.jdo.api.persistence.enhancer.classfile

ClassMethod

public class ClassMethod extends ClassMember
ClassMethod models the static and non-static methods of a class within a class file. This includes constructors and initializer code.

Fields Summary
public static final String
intializerName
public static final String
staticIntializerName
private int
accessFlags
private ConstUtf8
methodName
private ConstUtf8
methodSignature
private AttributeVector
methodAttributes
Constructors Summary
public ClassMethod(int accFlags, ConstUtf8 name, ConstUtf8 sig, AttributeVector methodAttrs)
Construct a class method object

    accessFlags = accFlags;
    methodName = name;
    methodSignature = sig;
    methodAttributes = methodAttrs;
  
Methods Summary
public intaccess()
Return the access flags for the method - see VMConstants

  
  
  /* public accessors */

               
     
    return accessFlags;
  
public AttributeVectorattributes()
Return the attributes associated with the method

    return methodAttributes;
  
public voidchangeName(ConstUtf8 name)
Change the name of the method

    methodName = name;
  
public voidchangeSignature(ConstUtf8 newSig)
Change the type signature of the method

    methodSignature = newSig;
  
public CodeAttributecodeAttribute()
Returns the CodeAttribute associated with this method (if any)

    Enumeration e = methodAttributes.elements();
    while (e.hasMoreElements()) {
      ClassAttribute attr = (ClassAttribute) e.nextElement();
      if (attr instanceof CodeAttribute)
	return (CodeAttribute) attr;
    }
    return null;
  
intcodeSize()
Returns the size of the method byteCode (if any)

    CodeAttribute codeAttr = codeAttribute();
    return (codeAttr == null) ? 0  : codeAttr.codeSize();
  
public booleanisAbstract()
Is the method abstract?

    return (accessFlags & ACCAbstract) != 0;
  
public booleanisNative()
Is the method native?

    return (accessFlags & ACCNative) != 0;
  
public ConstUtf8name()
Return the name of the method

    return methodName;
  
voidprint(java.io.PrintStream out, int indent)

    ClassPrint.spaces(out, indent);
    out.print("'" + methodName.asString() + "'");//NOI18N
    out.print(" sig = " + methodSignature.asString());//NOI18N
    out.print(" accessFlags = " + Integer.toString(accessFlags));//NOI18N
    out.println(" attributes:");//NOI18N
    methodAttributes.print(out, indent+2);
  
static com.sun.jdo.api.persistence.enhancer.classfile.ClassMethodread(java.io.DataInputStream data, ConstantPool pool)

    int accessFlags = data.readUnsignedShort();
    int nameIndex = data.readUnsignedShort();
    int sigIndex = data.readUnsignedShort();
    ClassMethod f = 
      new ClassMethod(accessFlags, 
		      (ConstUtf8) pool.constantAt(nameIndex),
		      (ConstUtf8) pool.constantAt(sigIndex),
		      null);

    f.methodAttributes = AttributeVector.readAttributes(data, pool);
    return f;
  
public voidsetAccess(int newFlags)
Update the access flags for the field - see VMConstants

    accessFlags = newFlags;
  
public ConstUtf8signature()
Return the type signature of the method

    return methodSignature;
  
voidwrite(java.io.DataOutputStream data)

    CodeAttribute codeAttr = codeAttribute();
    data.writeShort(accessFlags);
    data.writeShort(methodName.getIndex());
    data.writeShort(methodSignature.getIndex());
    methodAttributes.write(data);