package org.fidonet.mina.io;

import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
import org.fidonet.mina.codec.DataInfo;
import org.fidonet.mina.codec.DataReader;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * Author: Vladimir Kravets
 * E-Mail: vova.kravets@gmail.com
 * Date: 9/19/12
 * Time: 1:22 PM
 */
public class BinkFrame {

    private static final short MAX_DATA_SIZE = 32767;

    private short dataInfo;
    private byte[] data;

    public BinkFrame(short dataInfo, byte[] data) {
        this.dataInfo = dataInfo;
        this.data = data;
    }

    public short getDataInfo() {
        return dataInfo;
    }

    public byte[] getData() {
        return data;
    }

    public static BinkData toBinkData(BinkFrame frame) {
        DataInfo info = DataReader.parseDataInfo(frame.getDataInfo());
        byte cmd = -1;
        byte[] dataBuf = null;
        if (info.isCommand()) {
            DataInputStream dataStream = new DataInputStream(new ByteInputStream(frame.getData(), frame.getData().length));
            try {
                cmd = dataStream.readByte();
                dataBuf = new byte[info.getSize()-1];
                dataStream.read(dataBuf);
            } catch (IOException e) {
                // todo logger
            }
        } else {
            dataBuf = frame.getData();
        }
        return new BinkData(info.isCommand(), cmd, dataBuf);

    }

}

@@ -27,73 +27,8 @@
 o;%0A%0A
-import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;%0A
 impo
@@ -106,16 +106,53 @@
 eader;%0A%0A
+import java.io.ByteArrayInputStream;%0A
 import j
@@ -997,16 +997,21 @@
 new Byte
+Array
 InputStr
@@ -1033,32 +1033,8 @@
 ta()
-, frame.getData().length
 ));%0A

Fix compilation error.