/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.CausedIOException
 *  javax.jms.BytesMessage
 *  javax.jms.JMSException
 */
package com.l7tech.server.transport.jms;

import com.l7tech.util.CausedIOException;
import java.io.IOException;
import java.io.InputStream;
import javax.jms.BytesMessage;
import javax.jms.JMSException;

public class BytesMessageInputStream
extends InputStream {
    private final BytesMessage a;

    public BytesMessageInputStream(BytesMessage bytesMessage) {
        this.a = bytesMessage;
    }

    @Override
    public int read() throws IOException {
        try {
            return this.a.readByte();
        }
        catch (JMSException jMSException) {
            throw new CausedIOException((Throwable)jMSException);
        }
    }

    @Override
    public synchronized int read(byte[] byArray, int n2, int n3) throws IOException {
        try {
            if (n2 == 0) {
                return this.a.readBytes(byArray, n3);
            }
        }
        catch (IOException iOException) {
            throw BytesMessageInputStream.a(iOException);
        }
        try {
            byte[] byArray2 = new byte[n3];
            int n4 = this.a.readBytes(byArray2, n3);
            if (n4 < 0) {
                return n4;
            }
            System.arraycopy(byArray2, 0, byArray, n2, n3);
            return n4;
        }
        catch (JMSException jMSException) {
            throw new CausedIOException((Throwable)jMSException);
        }
    }

    private static IOException a(IOException iOException) {
        return iOException;
    }
}

