/* * Created on Dec 4, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.apache.bcel.classfile; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.apache.bcel.Constants; /** * @author yann * */ public final class EscapeAttribute extends Attribute { static final long serialVersionUID = 0; private short[] offsets; public EscapeAttribute(int name_index, int length, short[] offsets, ConstantPool cp) { super(Constants.ATTR_ESCAPE_MAP,name_index,length,cp); this.offsets = offsets; } public EscapeAttribute(int name_index, int length, DataInputStream str, ConstantPool cp) throws IOException { this(name_index, length, (short [])null, cp); int nb = length / 2; if(nb > 0) { offsets = new short[nb]; for(int i = 0; i < nb; i++) { offsets[i] = str.readShort(); } } } public void accept(Visitor v) { v.visitEscapeMap(this); } public Attribute copy(ConstantPool cp) { EscapeAttribute copy = (EscapeAttribute)clone(); System.arraycopy(offsets,0,copy.offsets,0,offsets.length); return copy; } public final void dump(DataOutputStream file) throws IOException { super.dump(file); for(int i = 0; i < offsets.length; i++) { file.writeShort(offsets[i]); } } public short[] getOffsets() { return offsets; } public final String toString() { StringBuffer buf = new StringBuffer("EscapeMap("); for(int i=0; i < offsets.length; i++) { buf.append(offsets[i]); if(i < offsets.length - 1) buf.append(", "); } buf.append(')'); return buf.toString(); } }