All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.miv.mbox.net.PositionableByteArrayInputStream Maven / Gradle / Ivy

Go to download

The message box acts as a buffer for incoming messages. Its major property is to be usable from any thread. This allows any external source to post any message at any time without having to wonder about synchronisation.

The newest version!
package org.miv.mbox.net;

import java.io.*;

/**
 * Descendant of ByteArrayInputStream that allows to change the offset and
 * length.
 *
 * The standard ByteArrayInputStream can only wrap a fixed part of its
 * underlying byte array (this byte array being managed by another source). As
 * the ByteArrayInputStream is used as source for other streams, it is not
 * possible to create a new ByteArrayInputStream if the part of the underlying
 * byte array used to read changes. Therefore this class allows to change the
 * offset and length of the part to use. Furthermore, it also allows to change
 * the underlying byte array.
 *
 * @author Antoine Dutot
 * @since 20041103
 */
public class PositionableByteArrayInputStream
	extends ByteArrayInputStream
{
    public PositionableByteArrayInputStream( byte buf[] )
	{
		super( buf );
    }

    public PositionableByteArrayInputStream( byte buf[], int offset, int length )
	{
		super( buf, offset, length );
    }

// Access

	public int getPos()
	{
		return pos;
	}

// Commands

	public void setPos( int pos, int count )
	{
		this.pos = pos;
		this.count = count;
	}

	public void changeBuffer( byte[] buf )
	{
		this.buf = buf;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy