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 Synthetic extends Attribute { 70 private byte[] bytes; 71 72 76 public Synthetic(Synthetic c) { 77 this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); 78 } 79 80 87 public Synthetic(int name_index, int length, byte[] bytes, 88 ConstantPool constant_pool) 89 { 90 super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool); 91 this.bytes = bytes; 92 } 93 94 102 Synthetic(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("Synthetic attribute with length > 0"); 111 } 112 } 113 120 public void accept(Visitor v) { 121 v.visitSynthetic(this); 122 } 123 129 public final void dump(DataOutputStream file) throws IOException 130 { 131 super.dump(file); 132 if(length > 0) 133 file.write(bytes, 0, length); 134 } 135 138 public final byte[] getBytes() { return bytes; } 139 140 143 public final void setBytes(byte[] bytes) { 144 this.bytes = bytes; 145 } 146 147 150 public final String toString() { 151 StringBuffer buf = new StringBuffer ("Synthetic"); 152 153 if(length > 0) 154 buf.append(" " + Utility.toHexString(bytes)); 155 156 return buf.toString(); 157 } 158 159 162 public Attribute copy(ConstantPool constant_pool) { 163 Synthetic c = (Synthetic)clone(); 164 165 if(bytes != null) 166 c.bytes = (byte[])bytes.clone(); 167 168 c.constant_pool = constant_pool; 169 return c; 170 } 171 } 172 | Popular Tags |