public class ObjectBuffer extends Object
Modifier and Type | Field and Description |
---|---|
int |
maxSize |
Constructor and Description |
---|
ObjectBuffer()
Create an ObjectBuffer with no maximum size.
|
ObjectBuffer(int maxSize)
Create an ObjectBuffer with a maximum size.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
This closes the buffer so no more data can be put in it - however
data can still be taken out of it.
|
protected void |
closed()
This is called when the buffer is closed.
|
Object |
get(TimeOut howLong)
Get an Object from the buffer.
|
Object |
get(TimeOut howLong,
boolean closeIfFailed)
Get an Object from the buffer.
|
boolean |
isClosed()
Returns if the buffer is closed so no more data can be put into it.
|
boolean |
put(Object data)
Place data in the buffer but do not wait if the buffer is full.
|
boolean |
put(Object data,
TimeOut howLong)
Place data in the buffer waiting if the buffer is full.
|
public ObjectBuffer(int maxSize)
maxSize
- the maximum number of Objects the buffer can hold.public ObjectBuffer()
public boolean isClosed()
public void close()
protected void closed()
public Object get(TimeOut howLong) throws InterruptedException
howLong
- the length of time to wait for the next object.InterruptedException
- if the Thread was interrupted.public Object get(TimeOut howLong, boolean closeIfFailed) throws InterruptedException
howLong
- the length of time to wait for the next object.closeIfFailed
- set this true if you want to close the buffer
if data does not arrive in time or if ther Thread is interrupted.InterruptedException
- if the Thread was interrupted.public boolean put(Object data, TimeOut howLong) throws InterruptedException
data
- the data to put in the buffer.howLong
- how long to wait.InterruptedException
public boolean put(Object data)
data
- the data to put in the buffer.