📄 ctclass.java
字号:
*/ public boolean isAnnotation() { return false; } /** * Determines whether this object represents an enum. * It returns <code>true</code> if this object represents an enum. * * @since 3.2 */ public boolean isEnum() { return false; } /** * Returns the modifiers for this class, encoded in an integer. * For decoding, use <code>javassist.Modifier</code>. * * <p>If the class is a static nested class (a.k.a. static inner class), * the returned modifiers include <code>Modifier.STATIC</code>. * * @see Modifier */ public int getModifiers() { return 0; } /** * Returns the annotations associated with this class. * For example, if an annotation <code>@Author</code> is associated * with this class, the returned array contains an <code>Author</code> * object. The member values can be obtained by calling methods on * the <code>Author</code> object. * * @return an array of annotation-type objects. * @see CtMember#getAnnotations() * @since 3.1 */ public Object[] getAnnotations() throws ClassNotFoundException { return new Object[0]; } /** * Returns the annotations associated with this class. * This method is equivalent to <code>getAnnotations()</code> * except that, if any annotations are not on the classpath, * they are not included in the returned array. * * @return an array of annotation-type objects. * @see #getAnnotations() * @see CtMember#getAvailableAnnotations() * @since 3.3 */ public Object[] getAvailableAnnotations(){ return new Object[0]; } /** * Returns an array of nested classes declared in the class. * Nested classes are inner classes, anonymous classes, local classes, * and static nested classes. * * @since 3.2 */ public CtClass[] getNestedClasses() throws NotFoundException { return new CtClass[0]; } /** * Sets the modifiers. * * <p>If the class is a nested class, this method also modifies * the class declaring that nested class (i.e. the enclosing * class is modified). * * @param mod modifiers encoded by * <code>javassist.Modifier</code> * @see Modifier */ public void setModifiers(int mod) { checkModify(); } /** * Determines whether the class directly or indirectly extends * the given class. If this class extends a class A and * the class A extends a class B, then subclassof(B) returns true. * * <p>This method returns true if the given class is identical to * the class represented by this object. */ public boolean subclassOf(CtClass superclass) { return false; } /** * Obtains the class object representing the superclass of the * class. * It returns null if this object represents the * <code>java.lang.Object</code> class and thus it does not have * the super class. * * <p>If this object represents an interface, this method * always returns the <code>java.lang.Object</code> class. * To obtain the super interfaces * extended by that interface, call <code>getInterfaces()</code>. */ public CtClass getSuperclass() throws NotFoundException { return null; } /** * Changes a super class unless this object represents an interface. * The new super class must be compatible with the old one. * * <p>If this object represents an interface, this method is equivalent * to <code>addInterface()</code>; it appends <code>clazz</code> to * the list of the super interfaces extended by that interface. * Note that an interface can extend multiple super interfaces. */ public void setSuperclass(CtClass clazz) throws CannotCompileException { checkModify(); } /** * Obtains the class objects representing the interfaces implemented * by the class or, if this object represents an interface, the interfaces * extended by that interface. */ public CtClass[] getInterfaces() throws NotFoundException { return new CtClass[0]; } /** * Sets implemented interfaces. If this object represents an interface, * this method sets the interfaces extended by that interface. * * @param list a list of the <code>CtClass</code> objects * representing interfaces, or * <code>null</code> if the class implements * no interfaces. */ public void setInterfaces(CtClass[] list) { checkModify(); } /** * Adds an interface. * * @param anInterface the added interface. */ public void addInterface(CtClass anInterface) { checkModify(); } /** * If this class is a member class or interface of another class, * then the class enclosing this class is returned. * * @return null if this class is a top-level class or an anonymous class. */ public CtClass getDeclaringClass() throws NotFoundException { return null; } /** * Returns the immediately enclosing method of this class. * This method works only with JDK 1.5 or later. * * @return null if this class is not a local class or an anonymous * class. */ public CtMethod getEnclosingMethod() throws NotFoundException { return null; } /** * Makes a new public nested class. If this method is called, * the <code>CtClass</code>, which encloses the nested class, is modified * since a class file includes a list of nested classes. * * <p>The current implementation only supports a static nested class. * <code>isStatic</code> must be true. * * @param name the simple name of the nested class. * @param isStatic true if the nested class is static. */ public CtClass makeNestedClass(String name, boolean isStatic) { throw new RuntimeException(getName() + " is not a class"); } /** * Returns an array containing <code>CtField</code> objects * representing all the non-private fields of the class. * That array includes non-private fields inherited from the * superclasses. */ public CtField[] getFields() { return new CtField[0]; } /** * Returns the field with the specified name. The returned field * may be a private field declared in a super class or interface. */ public CtField getField(String name) throws NotFoundException { throw new NotFoundException(name); } /** * @return null if the specified field is not found. */ CtField getField2(String name) { return null; } /** * Gets all the fields declared in the class. The inherited fields * are not included. * * <p>Note: the result does not include inherited fields. */ public CtField[] getDeclaredFields() { return new CtField[0]; } /** * Retrieves the field with the specified name among the fields * declared in the class. * * <p>Note: this method does not search the superclasses. */ public CtField getDeclaredField(String name) throws NotFoundException { throw new NotFoundException(name); } /** * Gets all the constructors and methods declared in the class. */ public CtBehavior[] getDeclaredBehaviors() { return new CtBehavior[0]; } /** * Returns an array containing <code>CtConstructor</code> objects * representing all the non-private constructors of the class. */ public CtConstructor[] getConstructors() { return new CtConstructor[0]; } /** * Returns the constructor with the given signature, * which is represented by a character string * called method descriptor. * For details of the method descriptor, see the JVM specification * or <code>javassist.bytecode.Descriptor</code>. * * @param desc method descriptor * @see javassist.bytecode.Descriptor */ public CtConstructor getConstructor(String desc) throws NotFoundException { throw new NotFoundException("no such a constructor"); } /** * Gets all the constructors declared in the class. * * @see javassist.CtConstructor */ public CtConstructor[] getDeclaredConstructors() { return new CtConstructor[0]; } /** * Returns a constructor receiving the specified parameters. * * @param params parameter types. */ public CtConstructor getDeclaredConstructor(CtClass[] params) throws NotFoundException { String desc = Descriptor.ofConstructor(params); return getConstructor(desc); } /** * Gets the class initializer (static constructor) * declared in the class. * This method returns <code>null</code> if * no class initializer is not declared. * * @see #makeClassInitializer() * @see javassist.CtConstructor */ public CtConstructor getClassInitializer() { return null; } /** * Returns an array containing <code>CtMethod</code> objects * representing all the non-private methods of the class. * That array includes pon-private methods inherited from the * superclasses. */ public CtMethod[] getMethods() { return new CtMethod[0]; } /** * Returns the method with the given name and signature. * The returned method may be declared in a super class. * The method signature is represented by a character string * called method descriptor, * which is defined in the JVM specification. * * @param name method name * @param desc method descriptor * @see CtBehavior#getSignature() * @see javassist.bytecode.Descriptor */ public CtMethod getMethod(String name, String desc) throws NotFoundException { throw new NotFoundException(name); } /** * Gets all methods declared in the class. The inherited methods * are not included. * * @see javassist.CtMethod */ public CtMethod[] getDeclaredMethods() { return new CtMethod[0]; } /** * Retrieves the method with the specified name and parameter types * among the methods declared in the class. * * <p>Note: this method does not search the superclasses. * * @param name method name * @param params parameter types * @see javassist.CtMethod */ public CtMethod getDeclaredMethod(String name, CtClass[] params) throws NotFoundException { throw new NotFoundException(name); } /** * Retrieves the method with the specified name among the methods * declared in the class. If there are multiple methods with * the specified name, then this method returns one of them. * * <p>Note: this method does not search the superclasses. * * @see javassist.CtMethod */ public CtMethod getDeclaredMethod(String name) throws NotFoundException { throw new NotFoundException(name); } /** * Makes an empty class initializer (static constructor). * If the class already includes a class initializer, * this method returns it. * * @see #getClassInitializer() */ public CtConstructor makeClassInitializer() throws CannotCompileException { throw new CannotCompileException("not a class"); } /** * Adds a constructor. To add a class initializer (static constructor), * call <code>makeClassInitializer()</code>. * * @see #makeClassInitializer() */ public void addConstructor(CtConstructor c) throws CannotCompileException { checkModify(); } /** * Removes a constructor declared in this class. * * @param c removed constructor. * @throws NotFoundException if the constructor is not found. */ public void removeConstructor(CtConstructor c) throws NotFoundException { checkModify(); } /** * Adds a method. */ public void addMethod(CtMethod m) throws CannotCompileException { checkModify(); } /** * Removes a method declared in this class. * * @param m removed method. * @throws NotFoundException if the method is not found. */ public void removeMethod(CtMethod m) throws NotFoundException { checkModify(); } /** * Adds a field. * * <p>The <code>CtField</code> belonging to another * <code>CtClass</code> cannot be directly added to this class. * Only a field created for this class can be added. * * @see javassist.CtField#CtField(CtField,CtClass) */ public void addField(CtField f) throws CannotCompileException { addField(f, (CtField.Initializer)null); } /** * Adds a field with an initial value. * * <p>The <code>CtField</code> belonging to another * <code>CtClass</code> cannot be directly added to this class. * Only a field created for this class can be added. * * <p>The initial value is given as an expression written in Java. * Any regular Java expression can be used for specifying the initial * value. The followings are examples. * * <ul><pre> * cc.addField(f, "0") // the initial value is 0.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -