1 package com.sun.org.apache.bcel.internal.classfile; 2 3 56 57 import com.sun.org.apache.bcel.internal.Constants; 58 import java.io.*; 59 60 69 public final class Deprecated extends Attribute { 70 private byte[] bytes; 71 72 76 public Deprecated(Deprecated c) { 77 this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); 78 } 79 80 87 public Deprecated(int name_index, int length, byte[] bytes, 88 ConstantPool constant_pool) 89 { 90 super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool); 91 this.bytes = bytes; 92 } 93 94 102 Deprecated(int name_index, int length, DataInputStream file, 103 ConstantPool constant_pool) throws IOException 104 { 105 this(name_index, length, (byte [])null, constant_pool); 106 107 if(length > 0) { 108 bytes = new byte[length]; 109 file.readFully(bytes); 110 System.err.println("Deprecated attribute with length > 0"); 111 } 112 } 113 114 121 public void accept(Visitor v) { 122 v.visitDeprecated(this); 123 } 124 125 131 public final void dump(DataOutputStream file) throws IOException 132 { 133 super.dump(file); 134 135 if(length > 0) 136 file.write(bytes, 0, length); 137 } 138 139 142 public final byte[] getBytes() { return bytes; } 143 144 147 public final void setBytes(byte[] bytes) { 148 this.bytes = bytes; 149 } 150 151 154 public final String toString() { 155 return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED]; 156 } 157 158 161 public Attribute copy(ConstantPool constant_pool) { 162 Deprecated c = (Deprecated )clone(); 163 164 if(bytes != null) 165 c.bytes = (byte[])bytes.clone(); 166 167 c.constant_pool = constant_pool; 168 return c; 169 } 170 } 171 | Popular Tags |