1 34 35 package org.logicalcobwebs.asm; 36 37 40 41 public class Attribute { 42 43 46 47 public String type; 48 49 54 55 public byte[] b; 56 57 60 61 public int off; 62 63 66 67 public int len; 68 69 72 73 public Attribute next; 74 75 83 84 public Attribute ( 85 final String type, 86 final byte[] b, 87 final int off, 88 final int len) 89 { 90 this.type = type; 91 this.b = b; 92 this.off = off; 93 this.len = len; 94 } 95 96 101 102 public Attribute (final String type) { 103 this(type, null, 0, 0); 104 } 105 106 111 112 final int getCount () { 113 int count = 0; 114 Attribute attr = this; 115 while (attr != null) { 116 count += 1; 117 attr = attr.next; 118 } 119 return count; 120 } 121 122 131 132 final int getSize (final ClassWriter cw) { 133 int size = 0; 134 Attribute attr = this; 135 while (attr != null) { 136 cw.newUTF8(attr.type); 137 size += cw.writeAttribute(attr).length + 6; 138 attr = attr.next; 139 } 140 return size; 141 } 142 143 151 152 final void put (final ClassWriter cw, final ByteVector out) { 153 Attribute attr = this; 154 while (attr != null) { 155 byte[] b = cw.writeAttribute(attr); 156 out.put2(cw.newUTF8(attr.type)).put4(b.length); 157 out.putByteArray(b, 0, b.length); 158 attr = attr.next; 159 } 160 } 161 } 162 | Popular Tags |