本文整理了Java中org.eclipse.jetty.io.Buffer
类的一些代码示例,展示了Buffer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer
类的具体详情如下:
包路径:org.eclipse.jetty.io.Buffer
类名称:Buffer
[英]Byte Buffer interface. This is a byte buffer that is designed to work like a FIFO for bytes. Puts and Gets operate on different pointers into the buffer and the valid _content of the buffer is always between the getIndex and the putIndex. This buffer interface is designed to be similar, but not dependent on the java.nio buffers, which may be used to back an implementation of this Buffer. The main difference is that NIO buffer after a put have their valid _content before the position and a flip is required to access that data. For this buffer it is always true that: markValue
[中]字节缓冲接口。这是一个字节缓冲区,其设计类似于字节的FIFO。在缓冲区中的不同指针上执行Puts和GET操作,缓冲区的有效_内容始终在getIndex和putIndex之间。该缓冲区接口的设计类似,但不依赖于java。nio缓冲区,可用于支持此缓冲区的实现。主要区别在于put之后的NIO缓冲区在位置之前有其有效的_内容,需要翻转才能访问该数据。对于该缓冲区,始终为真:markValue
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server
public static boolean isPrefix(Buffer prefix,Buffer buffer)
{
if (prefix.length()>buffer.length())
return false;
int bi=buffer.getIndex();
for (int i=prefix.getIndex(); i<prefix.putIndex();i++)
if (prefix.peek(i)!=buffer.peek(bi++))
return false;
return true;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp
public InputStream getInputStream() throws IOException
{
Buffer indirect = getIndirectBuffer();
if (indirect!=null && indirect.array()!=null)
return new ByteArrayInputStream(indirect.array(),indirect.getIndex(),indirect.length());
return _resource.getInputStream();
}
代码示例来源:origin: org.eclipse.jetty/jetty-websocket
public void fill(Buffer buffer)
{
if (buffer!=null && buffer.length()>0)
{
if (_buffer==null)
_buffer=_buffers.getBuffer();
_buffer.put(buffer);
buffer.clear();
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public boolean isBufferFull()
{
if (_buffer != null && _buffer.space()==0)
{
if (_buffer.length()==0 && !_buffer.isImmutable())
_buffer.compact();
return _buffer.space()==0;
}
return _content!=null && _content.length()>0;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public static Buffer getHeaderName(Buffer _buffer, View tok)
{
int len=((_buffer.peek()&0xFF)<<8)|(_buffer.peek(_buffer.getIndex()+1)&0xFF);
if ((0xFF00&len)==0xA000)
{
_buffer.skip(1);
return Ajp13RequestHeaders.CACHE.get(_buffer.get());
}
int start=_buffer.getIndex();
tok.update(start+2,start+len+2);
_buffer.skip(len+3);
return tok;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public View(Buffer buffer)
{
super(READWRITE,!buffer.isImmutable());
_buffer=buffer.buffer();
setPutIndex(buffer.putIndex());
setGetIndex(buffer.getIndex());
setMarkIndex(buffer.markIndex());
_access=buffer.isReadOnly()?READONLY:READWRITE;
}
代码示例来源:origin: org.eclipse.jetty.spdy/spdy-jetty-http
private DataInfo toDataInfo(Buffer buffer, boolean close)
{
if (buffer instanceof ByteArrayBuffer)
return new BytesDataInfo(buffer.array(), buffer.getIndex(), buffer.length(), close);
if (buffer instanceof NIOBuffer)
{
ByteBuffer byteBuffer = ((NIOBuffer)buffer).getByteBuffer();
byteBuffer.limit(buffer.putIndex());
byteBuffer.position(buffer.getIndex());
return new ByteBufferDataInfo(byteBuffer, close);
}
return new BytesDataInfo(buffer.asArray(), close);
}
代码示例来源:origin: org.eclipse.jetty/jetty-websocket
if (buffer.array()==null)
buffer=buffer.asMutableBuffer();
int length=0xff&buffer.get();
if (length>=0x7e)
length=0;
while(b-->0)
length=0x100*length+(0xff&buffer.get());
_inflater.setInput(buffer.array(),buffer.getIndex(),buffer.length());
ByteArrayBuffer buf = new ByteArrayBuffer(length);
try
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public Buffer lookup(Buffer buffer)
{
if (buffer instanceof CachedBuffer)
return buffer;
Buffer b= get(buffer);
if (b == null)
{
if (buffer instanceof Buffer.CaseInsensitve)
return buffer;
return new ByteArrayBuffer.CaseInsensitive(buffer.asArray(),0,buffer.length(),Buffer.IMMUTABLE);
}
return b;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
private synchronized int expelBuffer(long blockFor) throws IOException
{
if (_buffer==null)
return 0;
int result = flushBuffer();
_buffer.compact();
if (!_endp.isBlocking())
{
while (_buffer.space()==0)
{
boolean ready = _endp.blockWritable(blockFor);
if (!ready)
throw new IOException("Write timeout");
result += flushBuffer();
_buffer.compact();
}
}
return result;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
/**
* @return The {@link Buffer#capacity} of the underlying buffer.
*/
public int capacity()
{
return _buffer.capacity();
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
@Override
protected int gatheringFlush(Buffer header, ByteBuffer bbuf0, Buffer buffer, ByteBuffer bbuf1) throws IOException
{
int headerPosition = header.getIndex();
int headerLength = header.length();
int bufferPosition = buffer.getIndex();
int written = super.gatheringFlush(header, bbuf0, buffer,bbuf1);
notifyOutgoing(header, headerPosition, written > headerLength ? headerLength : written);
notifyOutgoing(buffer, bufferPosition, written > headerLength ? written - headerLength : 0);
return written;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
private ByteBuffer extractByteBuffer(Buffer buffer)
{
if (buffer.buffer() instanceof NIOBuffer)
return ((NIOBuffer)buffer.buffer()).getByteBuffer();
return ByteBuffer.wrap(buffer.array());
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public static byte getByte(Buffer _buffer)
{
return _buffer.get();
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public boolean isBufferEmpty()
{
_lock.lock();
try
{
return _buffer == null || _buffer.length() == 0;
}
finally
{
_lock.unlock();
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public void returnBuffer(Buffer buffer)
{
synchronized(this)
{
buffer.clear();
if (buffer==_header)
_headerOut=false;
if (buffer==_buffer)
_bufferOut=false;
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
/**
* @return The result of calling {@link Buffer#peek(int, int)} on the underlying buffer
*/
@Override
public Buffer peek(int index, int length)
{
return _buffer.peek(index, length);
}
代码示例来源:origin: org.eclipse.jetty/jetty-websocket
while (_buffer.length() > 0)
_buffer.compact();
return result;
代码示例来源:origin: org.eclipse.jetty/test-jetty-servlet
private String getString(Buffer buffer)
{
return getString(buffer.asArray());
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
/**
* @return The {@link Buffer#array()} from the underlying buffer.
*/
public byte[] array()
{
return _buffer.array();
}
内容来源于网络,如有侵权,请联系作者删除!