Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/IndirectNIOBuffer.java @ 1010:2712133d5bce
simplify Buffer code
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Oct 2016 22:23:50 -0600 |
parents | 3428c60d7cfc |
children | 80cad9086593 |
comparison
equal
deleted
inserted
replaced
1009:c3a04bded909 | 1010:2712133d5bce |
---|---|
20 | 20 |
21 import java.nio.ByteBuffer; | 21 import java.nio.ByteBuffer; |
22 | 22 |
23 import org.eclipse.jetty.io.ByteArrayBuffer; | 23 import org.eclipse.jetty.io.ByteArrayBuffer; |
24 | 24 |
25 public class IndirectNIOBuffer extends ByteArrayBuffer implements NIOBuffer | 25 |
26 public final class IndirectNIOBuffer extends ByteArrayBuffer implements NIOBuffer | |
26 { | 27 { |
27 protected final ByteBuffer _buf; | 28 private final ByteBuffer _buf; |
28 | 29 |
29 /* ------------------------------------------------------------ */ | 30 public IndirectNIOBuffer(int size) |
30 public IndirectNIOBuffer(int size) | 31 { |
31 { | 32 super(size,READWRITE,NON_VOLATILE); |
32 super(size,READWRITE,NON_VOLATILE); | 33 _buf = ByteBuffer.wrap(_bytes); |
33 _buf = ByteBuffer.wrap(_bytes); | 34 _buf.position(0); |
34 _buf.position(0); | 35 _buf.limit(_buf.capacity()); |
35 _buf.limit(_buf.capacity()); | 36 } |
36 } | |
37 | 37 |
38 /* ------------------------------------------------------------ */ | 38 @Override |
39 public IndirectNIOBuffer(ByteBuffer buffer,boolean immutable) | 39 public ByteBuffer getByteBuffer() |
40 { | 40 { |
41 super(buffer.array(),0,0, immutable?IMMUTABLE:READWRITE,NON_VOLATILE); | 41 return _buf; |
42 if (buffer.isDirect()) | 42 } |
43 throw new IllegalArgumentException(); | |
44 _buf = buffer; | |
45 _get=buffer.position(); | |
46 _put=buffer.limit(); | |
47 buffer.position(0); | |
48 buffer.limit(buffer.capacity()); | |
49 } | |
50 | |
51 /* ------------------------------------------------------------ */ | |
52 public ByteBuffer getByteBuffer() | |
53 { | |
54 return _buf; | |
55 } | |
56 | 43 |
57 /* ------------------------------------------------------------ */ | 44 @Override |
58 public boolean isDirect() | 45 public boolean isDirect() |
59 { | 46 { |
60 return false; | 47 return false; |
61 } | 48 } |
62 } | 49 } |