Skip to content

Commit

Permalink
修改pom
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfei0201 committed Mar 31, 2015
1 parent 976fb0f commit 2d19ea5
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
* @author <a href="mailto:[email protected]">kimi</a>
Expand All @@ -41,7 +40,7 @@ public ByteBufferBackedChannelBuffer(ByteBuffer buffer) {
writerIndex(capacity);
}

private ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer) {
public ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer) {
this.buffer = buffer.buffer;
capacity = buffer.capacity;
setIndex(buffer.readerIndex(), buffer.writerIndex());
Expand All @@ -55,12 +54,12 @@ public ChannelBufferFactory factory() {
}
}

@Override

public int capacity() {
return capacity;
}

@Override

public ChannelBuffer copy(int index, int length) {
ByteBuffer src;
try {
Expand All @@ -77,12 +76,12 @@ public ChannelBuffer copy(int index, int length) {
return new ByteBufferBackedChannelBuffer(dst);
}

@Override

public byte getByte(int index) {
return buffer.get(index);
}

@Override

public void getBytes(int index, byte[] dst, int dstIndex, int length) {
ByteBuffer data = buffer.duplicate();
try {
Expand All @@ -93,7 +92,7 @@ public void getBytes(int index, byte[] dst, int dstIndex, int length) {
data.get(dst, dstIndex, length);
}

@Override

public void getBytes(int index, ByteBuffer dst) {
ByteBuffer data = buffer.duplicate();
int bytesToCopy = Math.min(capacity() - index, dst.remaining());
Expand All @@ -105,7 +104,7 @@ public void getBytes(int index, ByteBuffer dst) {
dst.put(data);
}

@Override

public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
if (dst instanceof ByteBufferBackedChannelBuffer) {
ByteBufferBackedChannelBuffer bbdst = (ByteBufferBackedChannelBuffer) dst;
Expand All @@ -120,7 +119,7 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
}
}

@Override

public void getBytes(int index, OutputStream out, int length) throws IOException {
if (length == 0) {
return;
Expand All @@ -138,31 +137,31 @@ public void getBytes(int index, OutputStream out, int length) throws IOException
}
}

@Override

public boolean isDirect() {
return buffer.isDirect();
}

@Override

public void setByte(int index, int value) {
buffer.put(index, (byte) value);
}

@Override

public void setBytes(int index, byte[] src, int srcIndex, int length) {
ByteBuffer data = buffer.duplicate();
data.limit(index + length).position(index);
data.put(src, srcIndex, length);
}

@Override

public void setBytes(int index, ByteBuffer src) {
ByteBuffer data = buffer.duplicate();
data.limit(index + src.remaining()).position(index);
data.put(src);
}

@Override

public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
if (src instanceof ByteBufferBackedChannelBuffer) {
ByteBufferBackedChannelBuffer bbsrc = (ByteBufferBackedChannelBuffer) src;
Expand All @@ -177,7 +176,7 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
}
}

@Override

public ByteBuffer toByteBuffer(int index, int length) {
if (index == 0 && length == capacity()) {
return buffer.duplicate();
Expand All @@ -187,7 +186,7 @@ public ByteBuffer toByteBuffer(int index, int length) {
}
}

@Override

public int setBytes(int index, InputStream in, int length) throws IOException {
int readBytes = 0;

Expand Down Expand Up @@ -227,17 +226,17 @@ public int setBytes(int index, InputStream in, int length) throws IOException {
return readBytes;
}

@Override

public byte[] array() {
return buffer.array();
}

@Override

public boolean hasArray() {
return buffer.hasArray();
}

@Override

public int arrayOffset() {
return buffer.arrayOffset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
* @author <a href="mailto:[email protected]">kimi</a>
Expand Down Expand Up @@ -68,80 +67,80 @@ public void ensureWritableBytes(int minWritableBytes) {
buffer = newBuffer;
}

@Override

public int capacity() {
return buffer.capacity();
}

@Override

public ChannelBuffer copy(int index, int length) {
DynamicChannelBuffer copiedBuffer = new DynamicChannelBuffer(Math.max(length, 64), factory());
copiedBuffer.buffer = buffer.copy(index, length);
copiedBuffer.setIndex(0, length);
return copiedBuffer;
}

@Override

public ChannelBufferFactory factory() {
return factory;
}

@Override

public byte getByte(int index) {
return buffer.getByte(index);
}

@Override

public void getBytes(int index, byte[] dst, int dstIndex, int length) {
buffer.getBytes(index, dst, dstIndex, length);
}

@Override

public void getBytes(int index, ByteBuffer dst) {
buffer.getBytes(index, dst);
}

@Override

public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
buffer.getBytes(index, dst, dstIndex, length);
}

@Override

public void getBytes(int index, OutputStream dst, int length) throws IOException {
buffer.getBytes(index, dst, length);
}

@Override

public boolean isDirect() {
return buffer.isDirect();
}

@Override

public void setByte(int index, int value) {
buffer.setByte(index, value);
}

@Override

public void setBytes(int index, byte[] src, int srcIndex, int length) {
buffer.setBytes(index, src, srcIndex, length);
}

@Override

public void setBytes(int index, ByteBuffer src) {
buffer.setBytes(index, src);
}

@Override

public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
buffer.setBytes(index, src, srcIndex, length);
}

@Override

public int setBytes(int index, InputStream src, int length) throws IOException {
return buffer.setBytes(index, src, length);
}

@Override

public ByteBuffer toByteBuffer(int index, int length) {
return buffer.toByteBuffer(index, length);
}
Expand Down Expand Up @@ -176,17 +175,17 @@ public int writeBytes(InputStream in, int length) throws IOException {
return super.writeBytes(in, length);
}

@Override

public byte[] array() {
return buffer.array();
}

@Override

public boolean hasArray() {
return buffer.hasArray();
}

@Override

public int arrayOffset() {
return buffer.arrayOffset();
}
Expand Down
Loading

0 comments on commit 2d19ea5

Please sign in to comment.