Olá galera…tenho um evento desta forma :
<blockquote> public void actionPerformed(ActionEvent e) {
Decoder decoder = new Decoder();
//IoBuffer io = new
ProtocolDecoderOutput out = new ProtocolDecoderOutput() {
private final List<Object> childProducts = new ArrayList<Object>();
public void write(Object message) {
childProducts.add(message);
}
public void flush(NextFilter nextFilter, IoSession session) {
}
};</blockquote>
Aonde estou passando o IoBuffer, quero recuperar o valor do IoBuffer…tenho a seguinte classe :
public class SimpleBufferAllocator implements IoBufferAllocator {public IoBuffer allocate(int capacity, boolean direct) { return wrap(allocateNioBuffer(capacity, direct)); } public ByteBuffer allocateNioBuffer(int capacity, boolean direct) { ByteBuffer nioBuffer; if (direct) { nioBuffer = ByteBuffer.allocateDirect(capacity); } else { nioBuffer = ByteBuffer.allocate(capacity); } return nioBuffer; } public IoBuffer wrap(ByteBuffer nioBuffer) { return new SimpleBuffer(nioBuffer); } public void dispose() { // Do nothing } private class SimpleBuffer extends AbstractIoBuffer { private ByteBuffer buf; protected SimpleBuffer(ByteBuffer buf) { super(SimpleBufferAllocator.this, buf.capacity()); this.buf = buf; buf.order(ByteOrder.BIG_ENDIAN); } protected SimpleBuffer(SimpleBuffer parent, ByteBuffer buf) { super(parent); this.buf = buf; } @Override public ByteBuffer buf() { return buf; } @Override protected void buf(ByteBuffer buf) { this.buf = buf; } @Override protected IoBuffer duplicate0() { return new SimpleBuffer(this, this.buf.duplicate()); } @Override protected IoBuffer slice0() { return new SimpleBuffer(this, this.buf.slice()); } @Override protected IoBuffer asReadOnlyBuffer0() { return new SimpleBuffer(this, this.buf.asReadOnlyBuffer()); } @Override public byte[] array() { return buf.array(); } @Override public int arrayOffset() { return buf.arrayOffset(); } @Override public boolean hasArray() { return buf.hasArray(); } @Override public void free() { // Do nothing } }}
Por favor, me ajudem, estou perdido!!! :roll: :shock:
abraços!!