// Path: src/main/java/com/wizzardo/epoll/readable/ReadableData.java
// public abstract class ReadableData implements Closeable {
// 
//     public ByteBufferWrapper getByteBuffer(ByteBufferProvider bufferProvider) {
//         return bufferProvider.getBuffer();
//     }
// 
//     public void close() throws IOException {
//     }
// 
//     public abstract int read(ByteBuffer byteBuffer);
// 
//     public int read(ByteBufferWrapper wrapper) {
//         return read(wrapper.buffer());
//     }
// 
//     public abstract void unread(int i);
// 
//     public abstract boolean isComplete();
// 
//     public abstract long complete();
// 
//     public abstract long length();
// 
//     public abstract long remains();
// 
//     public boolean hasOwnBuffer() {
//         return false;
//     }
// 
//     public void onComplete() {
//     }
// }


import com.wizzardo.epoll.readable.ReadableData;
import java.nio.ByteBuffer;
package com.wizzardo.epoll;



/**
 * @author: wizzardo
 * Date: 3/15/14
 */
public class ByteBufferWrapper {

    private final ByteBuffer buffer;
    private int offset = 0;

    public final long address;

    public ByteBufferWrapper(ByteBuffer buffer) {
        if (!buffer.isDirect())
            throw new IllegalArgumentException("byte buffer must be direct");

        this.buffer = buffer;
        address = EpollCore.address(buffer);
    }

// Path: src/main/java/com/wizzardo/epoll/readable/ReadableData.java
// public abstract class ReadableData implements Closeable {
// 
//     public ByteBufferWrapper getByteBuffer(ByteBufferProvider bufferProvider) {
//         return bufferProvider.getBuffer();
//     }
// 
//     public void close() throws IOException {
//     }
// 
//     public abstract int read(ByteBuffer byteBuffer);
// 
//     public int read(ByteBufferWrapper wrapper) {
//         return read(wrapper.buffer());
//     }
// 
//     public abstract void unread(int i);
// 
//     public abstract boolean isComplete();
// 
//     public abstract long complete();
// 
//     public abstract long length();
// 
//     public abstract long remains();
// 
//     public boolean hasOwnBuffer() {
//         return false;
//     }
// 
//     public void onComplete() {
//     }
// }


// Path: src/main/java/com/wizzardo/epoll/ByteBufferWrapper.java
import com.wizzardo.epoll.readable.ReadableData;
import java.nio.ByteBuffer;

package com.wizzardo.epoll;



/**
 * @author: wizzardo
 * Date: 3/15/14
 */
public class ByteBufferWrapper {

    private final ByteBuffer buffer;
    private int offset = 0;

    public final long address;

    public ByteBufferWrapper(ByteBuffer buffer) {
        if (!buffer.isDirect())
            throw new IllegalArgumentException("byte buffer must be direct");

        this.buffer = buffer;
        address = EpollCore.address(buffer);
    }

    public ByteBufferWrapper(ReadableData data) {