You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CtMember.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later.
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. */
  15. package javassist;
  16. /**
  17. * An instance of <code>CtMember</code> represents a field, a constructor,
  18. * or a method.
  19. */
  20. public abstract class CtMember {
  21. protected CtClass declaringClass;
  22. protected CtMember(CtClass clazz) { declaringClass = clazz; }
  23. /**
  24. * Returns the class that declares this member.
  25. */
  26. public CtClass getDeclaringClass() { return declaringClass; }
  27. /**
  28. * Obtains the modifiers of the member.
  29. *
  30. * @return modifiers encoded with
  31. * <code>javassist.Modifier</code>.
  32. * @see Modifier
  33. */
  34. public abstract int getModifiers();
  35. /**
  36. * Sets the encoded modifiers of the member.
  37. *
  38. * @see Modifier
  39. */
  40. public abstract void setModifiers(int mod);
  41. /**
  42. * Obtains the name of the member.
  43. */
  44. public abstract String getName();
  45. /**
  46. * Obtains an attribute with the given name.
  47. * If that attribute is not found in the class file, this
  48. * method returns null.
  49. *
  50. * @param name attribute name
  51. */
  52. public abstract byte[] getAttribute(String name);
  53. /**
  54. * Adds an attribute. The attribute is saved in the class file.
  55. *
  56. * @param name attribute name
  57. * @param data attribute value
  58. */
  59. public abstract void setAttribute(String name, byte[] data);
  60. }