1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 38 import org.apache.log4j.*; 39 40 public class Custom_attribute extends Attribute_info { 41 private String name; 42 private byte[] info; 43 44 public Custom_attribute(Classfile classfile, Visitable owner, DataInputStream in) throws IOException { 45 this("", classfile, owner, in); 46 } 47 48 public Custom_attribute(String name, Classfile classfile, Visitable owner, DataInputStream in) throws IOException { 49 super(classfile, owner); 50 51 this.name = name; 52 53 int byteCount = in.readInt(); 54 Logger.getLogger(getClass()).debug("Attribute length: " + byteCount); 55 56 this.info = new byte[byteCount]; 57 int bytesRead = in.read(info); 58 Logger.getLogger(getClass()).debug("Bytes read: " + bytesRead); 59 } 60 61 public String getName() { 62 return name; 63 } 64 65 public byte[] getInfo() { 66 return info; 67 } 68 69 public String toString() { 70 return "Custom \"" + name + "\" " + getInfo().length + " byte(s)"; 71 } 72 73 public void accept(Visitor visitor) { 74 visitor.visitCustom_attribute(this); 75 } 76 } 77 | Popular Tags |