java.nio.Buffer#limit ( )源码实例Demo

下面列出了java.nio.Buffer#limit ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jmonkeyengine   文件: LwjglGLExt.java
private static void checkLimit(Buffer buffer) {
    if (buffer == null) {
        return;
    }
    if (buffer.limit() == 0) {
        throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error");
    }
    if (buffer.remaining() == 0) {
        throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error");
    }
}
 
源代码2 项目: jmonkeyengine   文件: IosGL.java
private static void checkLimit(Buffer buffer) {
    if (buffer == null) {
        return;
    }
    if (buffer.limit() == 0) {
        throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error");
    }
    if (buffer.remaining() == 0) {
        throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error");
    }
}
 
源代码3 项目: jmonkeyengine   文件: LwjglGLFboGL3.java
private static void checkLimit(Buffer buffer) {
    if (buffer == null) {
        return;
    }
    if (buffer.limit() == 0) {
        throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error");
    }
    if (buffer.remaining() == 0) {
        throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error");
    }
}
 
源代码4 项目: TencentKona-8   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码5 项目: java-technology-stack   文件: DefaultDataBuffer.java
@Override
public ByteBuffer asByteBuffer(int index, int length) {
	checkIndex(index, length);

	ByteBuffer duplicate = this.byteBuffer.duplicate();
	// Explicit access via Buffer base type for compatibility
	// with covariant return type on JDK 9's ByteBuffer...
	Buffer buffer = duplicate;
	buffer.position(index);
	buffer.limit(index + length);
	return duplicate.slice();
}
 
源代码6 项目: apm-agent-java   文件: BufferedFile.java
/**
 * Sets the position of the file without reading new data.
 *
 * @param pos the new position
 */
public void position(long pos) {
    Buffer buffer = this.buffer;
    long positionDelta = pos - position();
    long newBufferPos = buffer.position() + positionDelta;
    if (0 <= newBufferPos && newBufferPos <= buffer.limit()) {
        buffer.position((int) newBufferPos);
    } else {
        // makes sure that the next ensureRemaining will load from file
        buffer.position(0);
        buffer.limit(0);
        offset = pos;
    }
}
 
源代码7 项目: apm-agent-java   文件: SamplingProfiler.java
private void readActivationEventsToBuffer(FileChannel activationEventsFileChannel, long eof, ByteBuffer byteBuffer) throws IOException {
    Buffer buf = byteBuffer;
    buf.clear();
    long remaining = eof - activationEventsFileChannel.position();
    activationEventsFileChannel.read(byteBuffer);
    buf.flip();
    if (remaining < buf.capacity()) {
        buf.limit((int) remaining);
    }
}
 
源代码8 项目: apm-agent-java   文件: SamplingProfiler.java
long startProcessingActivationEventsFile() throws IOException {
    Buffer activationEventsBuffer = this.activationEventsBuffer;
    if (activationEventsFileChannel.position() > 0) {
        flushActivationEvents();
        activationEventsBuffer.limit(0);
    } else {
        activationEventsBuffer.flip();
    }
    long eof = activationEventsFileChannel.position();
    activationEventsFileChannel.position(0);
    return eof;
}
 
源代码9 项目: openjdk-jdk8u   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码11 项目: jmonkeyengine   文件: AndroidGL.java
private static void checkLimit(Buffer buffer) {
    if (buffer == null) {
        return;
    }
    if (buffer.limit() == 0) {
        throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error");
    }
    if (buffer.remaining() == 0) {
        throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error");
    }
}
 
源代码12 项目: SnowGraph   文件: MboxIterator.java
/**
 * Utility method to log important details about buffers.
 */
public static String bufferDetailsToString(final Buffer buffer) {
    return "Buffer details: " + "\ncapacity:\t" + buffer.capacity() +
            "\nlimit:\t" + buffer.limit() +
            "\nremaining:\t" + buffer.remaining() +
            "\nposition:\t" + buffer.position() +
            "\nbuffer:\t" + buffer.isReadOnly() +
            "\nclass:\t" + buffer.getClass();
}
 
源代码13 项目: jmonkeyengine   文件: GLTracer.java
private void printBuffer(Buffer buffer) {
    StringBuilder sb = new StringBuilder();
    sb.append(ANSI_MAGENTA);
    if (buffer instanceof ByteBuffer) {
        sb.append("byte");
    } else if (buffer instanceof ShortBuffer) {
        sb.append("short");
    } else if (buffer instanceof CharBuffer) { 
        sb.append("char");
    } else if (buffer instanceof FloatBuffer) {
        sb.append("float");
    } else if (buffer instanceof IntBuffer) {
        sb.append("int");
    } else if (buffer instanceof LongBuffer) {
        sb.append("long");
    } else if (buffer instanceof DoubleBuffer) {
        sb.append("double");
    } else {
        throw new UnsupportedOperationException();
    }
    sb.append(ANSI_RESET);
    sb.append("[");
    
    if (buffer.position() == 0
            && buffer.limit() == buffer.capacity()) {
        // Common case. Just print buffer size.
        sb.append(buffer.capacity());
    } else {
        sb.append("pos=").append(buffer.position());
        sb.append(" lim=").append(buffer.limit());
        sb.append(" cap=").append(buffer.capacity());
    }
    
    sb.append("]");
    print(sb.toString());
}
 
源代码14 项目: Tomcat8-Source-Read   文件: OutputBuffer.java
private boolean isFull(Buffer buffer) {
    return buffer.limit() == buffer.capacity();
}
 
源代码15 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }
 
源代码16 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }
 
源代码17 项目: sis   文件: ByteWriter.java
/**
 * Prepares the given source and target buffers to a new transfer.
 */
private static void reset(final Buffer source, final Buffer target) {
    target.clear();
    source.limit(Math.min(source.capacity(), source.position() + target.capacity()));
}
 
源代码18 项目: FastBootWeixin   文件: ReaderInputStream.java
/**
 * Returns the number of elements between the limit and capacity.
 */
private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
}
 
源代码19 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }
 
源代码20 项目: jmonkeyengine   文件: IosGL.java
private static int getLimitCount(Buffer buffer, int elementSize) {
    checkLimit(buffer);
    return buffer.limit() / elementSize;
}