1 cananian 1.1.4.1 // HClassMutator.java, created Mon Jan 10 16:10:45 2000 by cananian 2 cananian 1.1.4.2 // Copyright (C) 2000 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.1.4.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1.4.1 package harpoon.ClassFile; 5 cananian 1.1.4.1 6 cananian 1.1.4.1 /** 7 cananian 1.1.4.1 * An <code>HClassMutator</code> allows you to change members and 8 cananian 1.1.4.1 * properties of an <code>HClass</code>. 9 cananian 1.1.4.1 * @see HClass#getMutator 10 cananian 1.1.4.1 * 11 cananian 1.1.4.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 12 salcianu 1.3 * @version $Id: HClassMutator.java,v 1.3 2003/03/18 03:52:53 salcianu Exp $ 13 cananian 1.1.4.1 */ 14 cananian 1.1.4.1 public interface HClassMutator { 15 salcianu 1.3 16 salcianu 1.3 /** Adds a field to the underlying class. Use 17 salcianu 1.3 <code>HFieldMutator</code> to set the modifiers for the added 18 salcianu 1.3 field. 19 salcianu 1.3 @param name name of the added field 20 salcianu 1.3 @param type type of the added field 21 salcianu 1.3 @return handle for the added field 22 salcianu 1.3 @see HFieldMutator */ 23 cananian 1.1.4.1 public HField addDeclaredField(String name, HClass type) 24 cananian 1.1.4.1 throws DuplicateMemberException; 25 salcianu 1.3 26 salcianu 1.3 /** Adds a field to the underlying class. Use 27 salcianu 1.3 <code>HFieldMutator</code> to set the modifiers for the added 28 salcianu 1.3 field. 29 salcianu 1.3 @param name name of the added field 30 salcianu 1.3 @param descriptor descriptor for the type of the added field, 31 salcianu 1.3 formatted as specified in 32 salcianu 1.3 <a href="http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html#1169">Section 4.3</a> of the JVM specification. 33 salcianu 1.3 @return handle for the added field 34 salcianu 1.3 @see HFieldMutator */ 35 cananian 1.1.4.1 public HField addDeclaredField(String name, String descriptor) 36 cananian 1.1.4.1 throws DuplicateMemberException; 37 salcianu 1.3 38 salcianu 1.3 /** Adds a new field named <code>name</code> to the underlying 39 salcianu 1.3 class. The type and the modifiers are taken from 40 salcianu 1.3 <code>template</code>. */ 41 cananian 1.1.4.1 public HField addDeclaredField(String name, HField template) 42 cananian 1.1.4.1 throws DuplicateMemberException; 43 salcianu 1.3 44 cananian 1.1.4.1 public void removeDeclaredField(HField f) 45 cananian 1.1.4.1 throws NoSuchMemberException; 46 cananian 1.1.4.1 47 salcianu 1.3 48 cananian 1.1.4.1 public HInitializer addClassInitializer() 49 cananian 1.1.4.1 throws DuplicateMemberException; 50 cananian 1.1.4.1 public void removeClassInitializer(HInitializer m) 51 cananian 1.1.4.1 throws NoSuchMemberException; 52 cananian 1.1.4.1 53 cananian 1.1.4.1 public HConstructor addConstructor(String descriptor) 54 cananian 1.1.4.1 throws DuplicateMemberException; 55 cananian 1.1.4.1 public HConstructor addConstructor(HClass[] paramTypes) 56 cananian 1.1.4.1 throws DuplicateMemberException; 57 cananian 1.1.4.1 public HConstructor addConstructor(HConstructor template) 58 cananian 1.1.4.1 throws DuplicateMemberException; 59 cananian 1.1.4.1 public void removeConstructor(HConstructor c) 60 cananian 1.1.4.1 throws NoSuchMemberException; 61 cananian 1.1.4.1 62 salcianu 1.3 /** Adds a method to the underlying <code>HClass</code>. Use 63 salcianu 1.3 <code>HMethodMutator</code> to set the method modifiers 64 salcianu 1.3 (public, static etc.) 65 salcianu 1.3 @param name name of the added method 66 salcianu 1.3 @param descriptor descriptor for the type of 67 salcianu 1.3 the added method, as specified 68 salcianu 1.3 in <a href="http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html#1169">Section 4.3</a> of the JVM specification. 69 salcianu 1.3 @return handler for the added method 70 salcianu 1.3 @see HMethodMutator */ 71 cananian 1.1.4.1 public HMethod addDeclaredMethod(String name, String descriptor) 72 cananian 1.1.4.1 throws DuplicateMemberException; 73 salcianu 1.3 74 salcianu 1.3 /** Adds a method to the underlying <code>HClass</code>. Later, 75 salcianu 1.3 you can use <code>HMethodMutator</code> to set the method 76 salcianu 1.3 modifiers (public, static etc.) 77 salcianu 1.3 @param name name of the added method 78 salcianu 1.3 @param paramTypes parameter types for the added method 79 salcianu 1.3 @param returnType return type for the added method 80 salcianu 1.3 @return handler for the added method 81 salcianu 1.3 @see HMethodMutator */ 82 cananian 1.1.4.1 public HMethod addDeclaredMethod(String name, HClass[] paramTypes, 83 cananian 1.1.4.1 HClass returnType) 84 cananian 1.1.4.1 throws DuplicateMemberException; 85 salcianu 1.3 86 salcianu 1.3 /** Adds a method named <code>name</code> to the underlying 87 salcianu 1.3 <code>HClass</code>. The method type and modifiers are taken 88 salcianu 1.3 from <code>template</code>. */ 89 cananian 1.1.4.1 public HMethod addDeclaredMethod(String name, HMethod template) 90 cananian 1.1.4.1 throws DuplicateMemberException; 91 salcianu 1.3 92 cananian 1.1.4.1 public void removeDeclaredMethod(HMethod m) 93 cananian 1.1.4.1 throws NoSuchMemberException; 94 salcianu 1.3 95 cananian 1.1.4.1 96 cananian 1.1.4.1 public void addInterface(HClass in); 97 cananian 1.1.4.1 public void removeInterface(HClass in) 98 cananian 1.1.4.1 throws NoSuchClassException; 99 cananian 1.1.4.1 public void removeAllInterfaces(); 100 cananian 1.1.4.1 101 cananian 1.1.4.1 public void addModifiers(int m); 102 cananian 1.1.4.1 public void setModifiers(int m); 103 cananian 1.1.4.1 public void removeModifiers(int m); 104 cananian 1.1.4.1 105 cananian 1.1.4.1 public void setSuperclass(HClass sc); 106 cananian 1.1.4.1 public void setSourceFile(String sourcefilename); 107 cananian 1.2 }