00001 package de.fub.bytecode.classfile;
00002
00003 import de.fub.bytecode.Constants;
00004 import java.io.*;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 public final class Synthetic extends Attribute {
00016 private byte[] bytes;
00017
00018
00019
00020
00021
00022
00023
00024
00025 public Synthetic(int name_index, int length, byte[] bytes,
00026 ConstantPool constant_pool)
00027 {
00028 super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
00029 this.bytes = bytes;
00030 }
00031
00032
00033
00034
00035
00036
00037
00038
00039 Synthetic(int name_index, int length, DataInputStream file,
00040 ConstantPool constant_pool) throws IOException
00041 {
00042 this(name_index, length, (byte [])null, constant_pool);
00043
00044 if(length > 0) {
00045 bytes = new byte[length];
00046 file.readFully(bytes);
00047 System.err.println("Synthetic attribute with length > 0");
00048 }
00049 }
00050
00051
00052
00053
00054 public Synthetic(Synthetic c) {
00055 this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
00056 }
00057
00058
00059
00060
00061
00062
00063
00064 public void accept(Visitor v) {
00065 v.visitSynthetic(this);
00066 }
00067
00068
00069
00070 public Attribute copy(ConstantPool constant_pool) {
00071 Synthetic c = (Synthetic)clone();
00072
00073 if(bytes != null)
00074 c.bytes = (byte[])bytes.clone();
00075
00076 c.constant_pool = constant_pool;
00077 return c;
00078 }
00079
00080
00081
00082
00083
00084
00085 public final void dump(DataOutputStream file) throws IOException
00086 {
00087 super.dump(file);
00088 if(length > 0)
00089 file.write(bytes, 0, length);
00090 }
00091
00092
00093
00094 public final byte[] getBytes() { return bytes; }
00095
00096
00097
00098 public final void setBytes(byte[] bytes) {
00099 this.bytes = bytes;
00100 }
00101
00102
00103
00104 public final String toString() {
00105 StringBuffer buf = new StringBuffer("Synthetic");
00106
00107 if(length > 0)
00108 buf.append(" " + Utility.toHexString(bytes));
00109
00110 return buf.toString();
00111 }
00112 }