Example usage for io.netty.handler.stream ChunkedFile startOffset

List of usage examples for io.netty.handler.stream ChunkedFile startOffset

Introduction

In this page you can find the example usage for io.netty.handler.stream ChunkedFile startOffset.

Prototype

long startOffset

To view the source code for io.netty.handler.stream ChunkedFile startOffset.

Click Source Link

Usage

From source file:io.advantageous.conekt.http.impl.ServerConnection.java

License:Open Source License

private long getBytes(Object obj) {
    if (obj == null)
        return 0;

    if (obj instanceof Buffer) {
        return ((Buffer) obj).length();
    } else if (obj instanceof ByteBuf) {
        return ((ByteBuf) obj).readableBytes();
    } else if (obj instanceof HttpContent) {
        return ((HttpContent) obj).content().readableBytes();
    } else if (obj instanceof WebSocketFrame) {
        return ((WebSocketFrame) obj).binaryData().length();
    } else if (obj instanceof FileRegion) {
        return ((FileRegion) obj).count();
    } else if (obj instanceof ChunkedFile) {
        ChunkedFile file = (ChunkedFile) obj;
        return file.endOffset() - file.startOffset();
    } else {/*  www.  ja v a 2  s.c  o  m*/
        return -1;
    }
}

From source file:io.vertx.core.http.impl.Http1xServerConnection.java

License:Open Source License

private long getBytes(Object obj) {
    if (obj == null)
        return 0;

    if (obj instanceof Buffer) {
        return ((Buffer) obj).length();
    } else if (obj instanceof ByteBuf) {
        return ((ByteBuf) obj).readableBytes();
    } else if (obj instanceof HttpContent) {
        return ((HttpContent) obj).content().readableBytes();
    } else if (obj instanceof WebSocketFrame) {
        return ((WebSocketFrame) obj).content().readableBytes();
    } else if (obj instanceof FileRegion) {
        return ((FileRegion) obj).count();
    } else if (obj instanceof ChunkedFile) {
        ChunkedFile file = (ChunkedFile) obj;
        return file.endOffset() - file.startOffset();
    } else {//  w  ww  . jav a 2  s  . c o m
        return -1;
    }
}