本文整理汇总了Java中org.mortbay.io.Buffer类的典型用法代码示例。如果您正苦于以下问题:Java Buffer类的具体用法?Java Buffer怎么用?Java Buffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Buffer类属于org.mortbay.io包,在下文中一共展示了Buffer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.mortbay.io.Buffer; //导入依赖的package包/类
public void test() throws Exception
{
StreamingMarketQuote quote = new StreamingMarketQuote();
ContentExchange ex = new ContentExchange(true)
{
// tell me what kind of response code we got
protected void onResponseComplete() throws IOException
{
int status = getResponseStatus();
if (status == 200)
System.out.println("Successfully connected");
else
System.out.println("Error Code Received: " + status);
}
// print out any response data we get along the stream
protected void onResponseContent(Buffer data)
{
System.out.println(data);
}
};
ContentExchange request = quote.stream(ex, new Symbol("IBM"));
request.waitForDone();
}
示例2: inferMimeType
import org.mortbay.io.Buffer; //导入依赖的package包/类
/**
* Infer the mime type for the response based on the extension of the request
* URI. Returns null if unknown.
*/
private String inferMimeType(ServletRequest request) {
String path = ((HttpServletRequest)request).getRequestURI();
ContextHandler.SContext sContext = (ContextHandler.SContext)config.getServletContext();
MimeTypes mimes = sContext.getContextHandler().getMimeTypes();
Buffer mimeBuffer = mimes.getMimeByExtension(path);
return (mimeBuffer == null) ? null : mimeBuffer.toString();
}
示例3: fill
import org.mortbay.io.Buffer; //导入依赖的package包/类
public int fill(Buffer buffer) throws IOException
{
Buffer buf = buffer.buffer();
int len=0;
NIOBuffer nbuf = (NIOBuffer)buf;
ByteBuffer bbuf=nbuf.getByteBuffer();
synchronized(nbuf)
{
try
{
if (bbuf.position() == 0)
{
bbuf.position(buffer.putIndex());
len=_channel.read(bbuf);
}
}
finally
{
buffer.setPutIndex(bbuf.position());
bbuf.position(0);
}
}
return len;
}
示例4: inferMimeType
import org.mortbay.io.Buffer; //导入依赖的package包/类
/**
* Infer the mime type for the response based on the extension of the
* request URI. Returns null if unknown.
*/
private String inferMimeType(ServletRequest request) {
String path = ((HttpServletRequest)request).getRequestURI();
ContextHandler.SContext sContext =
(ContextHandler.SContext)config.getServletContext();
MimeTypes mimes = sContext.getContextHandler().getMimeTypes();
Buffer mimeBuffer = mimes.getMimeByExtension(path);
return (mimeBuffer == null) ? null : mimeBuffer.toString();
}
示例5: fill
import org.mortbay.io.Buffer; //导入依赖的package包/类
@Override
public int fill(Buffer buffer) throws IOException {
int len = super.fill(buffer);
if (len < 0)
getChannel().close();
return len;
}
示例6: onResponseStatus
import org.mortbay.io.Buffer; //导入依赖的package包/类
protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
{
super.onResponseStatus(version,status,reason);
}
示例7: onResponseHeader
import org.mortbay.io.Buffer; //导入依赖的package包/类
protected void onResponseHeader(Buffer name, Buffer value) throws IOException
{
super.onResponseHeader(name,value);
if (HttpHeaders.CACHE.getOrdinal(name)==HttpHeaders.SET_COOKIE_ORDINAL)
{
String cname=null;
String cvalue=null;
QuotedStringTokenizer tok=new QuotedStringTokenizer(value.toString(),"=;",false,false);
tok.setSingle(false);
if (tok.hasMoreElements())
cname=tok.nextToken();
if (tok.hasMoreElements())
cvalue=tok.nextToken();
Cookie cookie=new Cookie(cname,cvalue);
while (tok.hasMoreTokens())
{
String token=tok.nextToken();
if ("Version".equalsIgnoreCase(token))
cookie.setVersion(Integer.parseInt(tok.nextToken()));
else if ("Comment".equalsIgnoreCase(token))
cookie.setComment(tok.nextToken());
else if ("Path".equalsIgnoreCase(token))
cookie.setPath(tok.nextToken());
else if ("Domain".equalsIgnoreCase(token))
cookie.setDomain(tok.nextToken());
else if ("Expires".equalsIgnoreCase(token))
{
tok.nextToken();
// TODO
}
else if ("Max-Age".equalsIgnoreCase(token))
{
tok.nextToken();
// TODO
}
else if ("Secure".equalsIgnoreCase(token))
cookie.setSecure(true);
}
BayeuxClient.this.setCookie(cookie);
}
}
示例8: newBuffer
import org.mortbay.io.Buffer; //导入依赖的package包/类
protected Buffer newBuffer(int size)
{
return new ByteArrayBuffer(size);
}