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.

EnumMemberValue.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 2004 Bill Burke. 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.bytecode.annotation;
  16. import javassist.bytecode.ConstPool;
  17. import java.io.DataOutputStream;
  18. import java.io.IOException;
  19. /**
  20. * Comment
  21. *
  22. * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
  23. * @version $Revision: 1.3 $
  24. *
  25. **/
  26. public class EnumMemberValue extends MemberValue
  27. {
  28. short type_name_index;
  29. short const_name_index;
  30. public EnumMemberValue(short type, short cni, ConstPool cp)
  31. {
  32. super('e', cp);
  33. this.type_name_index = type;
  34. this.const_name_index = cni;
  35. }
  36. public String getEnumType()
  37. {
  38. return cp.getUtf8Info(type_name_index);
  39. }
  40. public String getEnumVal()
  41. {
  42. return cp.getUtf8Info(const_name_index);
  43. }
  44. public String toString()
  45. {
  46. return getEnumType() + "." + getEnumVal();
  47. }
  48. public void write(DataOutputStream dos) throws IOException
  49. {
  50. super.write(dos);
  51. dos.writeShort(type_name_index);
  52. dos.writeShort(const_name_index);
  53. }
  54. public void accept(MemberValueVisitor visitor)
  55. {
  56. visitor.visitEnumMemberValue(this);
  57. }
  58. }