1 17 package org.apache.bcel.classfile; 18 19 import java.io.DataInputStream ; 20 import java.io.DataOutputStream ; 21 import java.io.IOException ; 22 import org.apache.bcel.Constants; 23 24 33 public final class Deprecated extends Attribute { 34 35 private byte[] bytes; 36 37 38 42 public Deprecated(Deprecated c) { 43 this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); 44 } 45 46 47 53 public Deprecated(int name_index, int length, byte[] bytes, ConstantPool constant_pool) { 54 super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool); 55 this.bytes = bytes; 56 } 57 58 59 67 Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool) 68 throws IOException { 69 this(name_index, length, (byte[]) null, constant_pool); 70 if (length > 0) { 71 bytes = new byte[length]; 72 file.readFully(bytes); 73 System.err.println("Deprecated attribute with length > 0"); 74 } 75 } 76 77 78 85 public void accept( Visitor v ) { 86 v.visitDeprecated(this); 87 } 88 89 90 96 public final void dump( DataOutputStream file ) throws IOException { 97 super.dump(file); 98 if (length > 0) { 99 file.write(bytes, 0, length); 100 } 101 } 102 103 104 107 public final byte[] getBytes() { 108 return bytes; 109 } 110 111 112 115 public final void setBytes( byte[] bytes ) { 116 this.bytes = bytes; 117 } 118 119 120 123 public final String toString() { 124 return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED]; 125 } 126 127 128 131 public Attribute copy( ConstantPool _constant_pool ) { 132 Deprecated c = (Deprecated ) clone(); 133 if (bytes != null) { 134 c.bytes = new byte[bytes.length]; 135 System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); 136 } 137 c.constant_pool = _constant_pool; 138 return c; 139 } 140 } 141 | Popular Tags |