package com.de22.javabytecode.attribute; import com.de22.javabytecode.*; /** * Copyright Wynne Crisman 1999,2006

*/ public class Unidentified extends CodeAttribute { private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private String attributeName = null; /** The unidentified data. This may never be null. */ private byte[] data = EMPTY_BYTE_ARRAY; /** * Unidentified constructor. * @param type The class this constant is a member of. * @param attributeName The name of the unidentified attribute (normally the name would select a different class). */ public Unidentified(Type type, String attributeName) { super(type); this.attributeName = attributeName; }//Unidentified()// /** * Gets the name of the unidentified attribute. * @return The attribute's name which identifies what the attribute data means. */ public String getAttributeName() { return attributeName; }//getAttributeName()// /** * Gets the attribute's default name as it is stored in the class bytes. * @return The default name identifying the attribute's type. */ public String getDefaultName() { return attributeName; }//getDefaultName()// /** * Gets the size in number of bytes of the component and all subcomponents. * @return The number of bytes required to represent the component and all subcomponents. */ public int getSize() { return data.length; }//getSize()// /** * Reads this object from the given stream. * @param in The input stream to read this object from. */ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException { int length = -1; int readCount = 0; super.readExternal(in); length = in.readInt(); //Read the size of the attribute.// data = new byte[length]; //Create the data array.// //Read the data.// while(readCount != data.length) { readCount += in.read(data, readCount, data.length - readCount); }//while// }//readExternal()// /** * @see Component.toString(StringBuffer, int) */ public void toString(StringBuffer buffer, int tabCount) { appendTabs(buffer, tabCount); buffer.append("Unidentified CodeAttribute (name="); buffer.append(attributeName); buffer.append(" Size="); buffer.append(data.length); buffer.append(')'); appendEndOfLine(buffer); }//toString()// /** * Writes this object to the given stream. * @param out The output stream to write this object to. */ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException { super.writeExternal(out); out.write(data); }//writeExternal()// }//Unidentified//