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.

ByteMemberValue.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 ByteMemberValue extends MemberValue
  27. {
  28. short const_value_index;
  29. public ByteMemberValue(short const_value_index, ConstPool cp)
  30. {
  31. super('B', cp);
  32. this.const_value_index = const_value_index;
  33. }
  34. public ByteMemberValue(ConstPool cp)
  35. {
  36. super('B', cp);
  37. setValue((byte)0);
  38. }
  39. public byte getValue()
  40. {
  41. return (byte)cp.getIntegerInfo(const_value_index);
  42. }
  43. public void setValue(byte newVal)
  44. {
  45. const_value_index = (short)cp.addIntegerInfo(newVal);
  46. }
  47. public String toString()
  48. {
  49. return "" + getValue();
  50. }
  51. public void write(DataOutputStream dos) throws IOException
  52. {
  53. super.write(dos);
  54. dos.writeShort(const_value_index);
  55. }
  56. public void accept(MemberValueVisitor visitor)
  57. {
  58. visitor.visitByteMemberValue(this);
  59. }
  60. }