MemberInfo.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**********************************************************************/
  2. /* Member Info class for j2cps */
  3. /* */
  4. /* (c) copyright QUT, John Gough 2000-2012, John Gough, 2012-2017 */
  5. /**********************************************************************/
  6. package j2cps;
  7. import java.io.DataInputStream;
  8. import java.io.IOException;
  9. public class MemberInfo {
  10. public ClassDesc owner;
  11. public int accessFlags;
  12. public String name;
  13. public String signature;
  14. public MemberInfo(ConstantPool cp,DataInputStream stream,ClassDesc own)
  15. throws IOException {
  16. owner = own;
  17. accessFlags = stream.readUnsignedShort();
  18. name = (String) cp.Get(stream.readUnsignedShort());
  19. signature = (String) cp.Get(stream.readUnsignedShort());
  20. /* skip the attributes */
  21. int attrCount = stream.readUnsignedShort();
  22. for (int i = 0; i < attrCount; i++) {
  23. int attNameIx = stream.readUnsignedShort();
  24. if ("ConstantValue".equals((String)cp.Get(attNameIx)) &&
  25. (this instanceof FieldInfo)) {
  26. ((FieldInfo)this).GetConstValueAttribute(cp,stream);
  27. } else {
  28. if ("Deprecated".equals((String)cp.Get(attNameIx)) &&
  29. (this instanceof MethodInfo)) { ((MethodInfo)this).deprecated = true; }
  30. int attrLength = stream.readInt();
  31. for (int j = 0; j < attrLength; j++) {
  32. int tmp = stream.readByte();
  33. }
  34. }
  35. }
  36. }
  37. public MemberInfo(ClassDesc own,int acc,String nam) {
  38. owner = own;
  39. accessFlags = acc;
  40. name = nam;
  41. }
  42. public boolean isPublicStatic() {
  43. return ConstantPool.isStatic(accessFlags) &&
  44. ConstantPool.isPublic(accessFlags);
  45. }
  46. public final boolean isExported() {
  47. return (ConstantPool.isPublic(accessFlags) ||
  48. ConstantPool.isProtected(accessFlags));
  49. }
  50. public boolean isPublic() {
  51. return ConstantPool.isPublic(accessFlags);
  52. }
  53. public boolean isStatic() {
  54. return ConstantPool.isStatic(accessFlags);
  55. }
  56. public boolean isPrivate() {
  57. return ConstantPool.isPrivate(accessFlags);
  58. }
  59. public boolean isProtected() {
  60. return ConstantPool.isProtected(accessFlags);
  61. }
  62. public boolean isAbstract() {
  63. return ConstantPool.isAbstract(accessFlags);
  64. }
  65. public boolean isFinal() {
  66. return ConstantPool.isFinal(accessFlags);
  67. }
  68. @Override
  69. public String toString() { return ""; };
  70. }