本文整理了Java中java.nio.Buffer.remaining()
方法的一些代码示例,展示了Buffer.remaining()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.remaining()
方法的具体详情如下:
包路径:java.nio.Buffer
类名称:Buffer
方法名:remaining
[英]Returns the number of remaining elements in this buffer, that is limit - position.
[中]返回此缓冲区中剩余的元素数,即limit-position。
代码示例来源:origin: stackoverflow.com
ByteBuffer bb =..
byte[] b = new byte[bb.remaining()]
bb.get(b);
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* Returns true if the end of the compressed
* data output stream has been reached.
*
* @return <code>true</code> if the end of the compressed
* data output stream has been reached.
*/
@Override
public boolean finished() {
// Check if all uncompressed data has been consumed
return (finish && finished && compressedDirectBuf.remaining() == 0);
}
代码示例来源:origin: robovm/robovm
void checkStartEndRemaining(int start, int end) {
if (end < start || start < 0 || end > remaining()) {
throw new IndexOutOfBoundsException("start=" + start + ", end=" + end +
", remaining()=" + remaining());
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
synchronized void setInputFromSavedData() {
int len = Math.min(userBufLen, uncompressedDirectBuf.remaining());
((ByteBuffer)uncompressedDirectBuf).put(userBuf, userBufOff, len);
userBufLen -= len;
userBufOff += len;
uncompressedDirectBufLen = uncompressedDirectBuf.position();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* @return
* @see Buffer#remaining()
*/
public int remaining() {
return getBuffer().remaining();
}
代码示例来源:origin: robovm/robovm
int checkGetBounds(int bytesPerElement, int length, int offset, int count) {
int byteCount = bytesPerElement * count;
if ((offset | count) < 0 || offset > length || length - offset < count) {
throw new IndexOutOfBoundsException("offset=" + offset +
", count=" + count + ", length=" + length);
}
if (byteCount > remaining()) {
throw new BufferUnderflowException();
}
return byteCount;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
protected static void checkLimit(final 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");
}
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
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");
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
Buffer pixels) {
if (pixels.limit() > 1) {
HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
ArrayBufferView buffer;
if (pixels instanceof FloatBuffer) {
buffer = webGLArray;
} else {
int remainingBytes = pixels.remaining() * 4;
int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;
buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);
}
gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buffer);
} else {
Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer) pixels).get(0));
gl.texSubImage2D(target, level, xoffset, yoffset, format, type, pixmap.getCanvasElement());
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
Buffer pixels) {
if (pixels.limit() > 1) {
HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
ArrayBufferView buffer;
if (pixels instanceof FloatBuffer) {
buffer = webGLArray;
} else {
int remainingBytes = pixels.remaining() * 4;
int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;
buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);
}
gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buffer);
} else {
Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer) pixels).get(0));
gl.texSubImage2D(target, level, xoffset, yoffset, format, type, pixmap.getCanvasElement());
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
Buffer pixels) {
if (pixels == null) {
gl.texImage2D(target, level, internalformat, width, height, border, format, type, null);
} else {
if (pixels.limit() > 1) {
HasArrayBufferView arrayHolder = (HasArrayBufferView)pixels;
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
ArrayBufferView buffer;
if (pixels instanceof FloatBuffer) {
buffer = webGLArray;
} else {
int remainingBytes = pixels.remaining() * 4;
int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;
buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);
}
gl.texImage2D(target, level, internalformat, width, height, border, format, type, buffer);
} else {
Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer)pixels).get(0));
// Prefer to use the HTMLImageElement when possible, since reading from the CanvasElement can be lossy.
if (pixmap.canUseImageElement()) {
gl.texImage2D(target, level, internalformat, format, type, pixmap.getImageElement());
}
else {
gl.texImage2D(target, level, internalformat, format, type, pixmap.getCanvasElement());
}
}
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
Buffer pixels) {
if (pixels == null) {
gl.texImage2D(target, level, internalformat, width, height, border, format, type, null);
} else {
if (pixels.limit() > 1) {
HasArrayBufferView arrayHolder = (HasArrayBufferView)pixels;
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
ArrayBufferView buffer;
if (pixels instanceof FloatBuffer) {
buffer = webGLArray;
} else {
int remainingBytes = pixels.remaining() * 4;
int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;
buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);
}
gl.texImage2D(target, level, internalformat, width, height, border, format, type, buffer);
} else {
Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer)pixels).get(0));
// Prefer to use the HTMLImageElement when possible, since reading from the CanvasElement can be lossy.
if (pixmap.canUseImageElement()) {
gl.texImage2D(target, level, internalformat, format, type, pixmap.getImageElement());
}
else {
gl.texImage2D(target, level, internalformat, format, type, pixmap.getCanvasElement());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!