本文整理匯總了Java中java.nio.Buffer類的典型用法代碼示例。如果您正苦於以下問題:Java Buffer類的具體用法?Java Buffer怎麽用?Java Buffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Buffer類屬於java.nio包,在下文中一共展示了Buffer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGet_io
import java.nio.Buffer; //導入依賴的package包/類
public void testGet_io() throws IOException {
assertEquals(-1, ArbitraryInstances.get(InputStream.class).read());
assertEquals(-1, ArbitraryInstances.get(ByteArrayInputStream.class).read());
assertEquals(-1, ArbitraryInstances.get(Readable.class).read(CharBuffer.allocate(1)));
assertEquals(-1, ArbitraryInstances.get(Reader.class).read());
assertEquals(-1, ArbitraryInstances.get(StringReader.class).read());
assertEquals(0, ArbitraryInstances.get(Buffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(CharBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(ByteBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(ShortBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(IntBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(LongBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(FloatBuffer.class).capacity());
assertEquals(0, ArbitraryInstances.get(DoubleBuffer.class).capacity());
ArbitraryInstances.get(PrintStream.class).println("test");
ArbitraryInstances.get(PrintWriter.class).println("test");
assertNotNull(ArbitraryInstances.get(File.class));
assertFreshInstanceReturned(
ByteArrayOutputStream.class, OutputStream.class,
Writer.class, StringWriter.class,
PrintStream.class, PrintWriter.class);
assertEquals(ByteSource.empty(), ArbitraryInstances.get(ByteSource.class));
assertEquals(CharSource.empty(), ArbitraryInstances.get(CharSource.class));
assertNotNull(ArbitraryInstances.get(ByteSink.class));
assertNotNull(ArbitraryInstances.get(CharSink.class));
}
示例2: GetDirectBufferCapacity
import java.nio.Buffer; //導入依賴的package包/類
@VM_ENTRY_POINT
private static long GetDirectBufferCapacity(Pointer env, JniHandle buffer) {
// Source: JniFunctionsSource.java:1766
Pointer anchor = prologue(env);
if (logger.enabled()) {
logger.log(LogOperations.GetDirectBufferCapacity.ordinal(), UPCALL_ENTRY, anchor, env, buffer);
}
try {
Object buf = buffer.unhand();
if (DirectByteBuffer.isInstance(buf)) {
return ((Buffer) buf).capacity();
}
return -1;
} catch (Throwable t) {
VmThread.fromJniEnv(env).setJniException(t);
return JNI_ERR;
} finally {
epilogue(anchor);
if (logger.enabled()) {
logger.log(LogOperations.GetDirectBufferCapacity.ordinal(), UPCALL_EXIT);
}
}
}
示例3: loadTexture
import java.nio.Buffer; //導入依賴的package包/類
public static int loadTexture(Buffer paramBuffer, int paramInt1, int paramInt2, int paramInt3)
{
int[] arrayOfInt = new int[1];
if (paramInt3 == -1)
{
GLES20.glGenTextures(1, arrayOfInt, 0);
GLES20.glBindTexture(3553, arrayOfInt[0]);
GLES20.glTexParameterf(3553, 10240, 9729.0F);
GLES20.glTexParameterf(3553, 10241, 9729.0F);
GLES20.glTexParameterf(3553, 10242, 33071.0F);
GLES20.glTexParameterf(3553, 10243, 33071.0F);
GLES20.glTexImage2D(3553, 0, 6408, paramInt1, paramInt2, 0, 6408, 5121, paramBuffer);
}
else
{
GLES20.glBindTexture(3553, paramInt3);
GLES20.glTexSubImage2D(3553, 0, 0, 0, paramInt1, paramInt2, 6408, 5121, paramBuffer);
arrayOfInt[0] = paramInt3;
}
return arrayOfInt[0];
}
示例4: loadTexture
import java.nio.Buffer; //導入依賴的package包/類
public static int loadTexture(final Buffer data, final int width,final int height, final int usedTexId) {
if(data == null)
return NO_TEXTURE;
int textures[] = new int[1];
if (usedTexId == NO_TEXTURE) {
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height,
0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, width,
height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
textures[0] = usedTexId;
}
return textures[0];
}
示例5: glTextureImage3DEXT_trace
import java.nio.Buffer; //導入依賴的package包/類
private static void glTextureImage3DEXT_trace(int texture, int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, Buffer pixels,
MethodCall mc) {
mc.param(texture);
mc.paramEnum(GLmetadata.TextureTarget().get(target));
mc.param(level);
if (internalformat >= 1 && internalformat <= 4)
mc.param(internalformat);
else
mc.paramEnum(GLmetadata.InternalFormat().get(internalformat));
mc.param(width);
mc.param(height);
mc.param(depth);
mc.param(border);
mc.paramEnum(GLmetadata.PixelFormat().get(format));
mc.paramEnum(GLmetadata.PixelType().get(type));
mc.param(pixels);
}
示例6: isDirect
import java.nio.Buffer; //導入依賴的package包/類
private static boolean isDirect(Buffer buf) {
if (buf instanceof FloatBuffer) {
return ((FloatBuffer) buf).isDirect();
}
if (buf instanceof IntBuffer) {
return ((IntBuffer) buf).isDirect();
}
if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).isDirect();
}
if (buf instanceof ByteBuffer) {
return ((ByteBuffer) buf).isDirect();
}
if (buf instanceof DoubleBuffer) {
return ((DoubleBuffer) buf).isDirect();
}
if (buf instanceof LongBuffer) {
return ((LongBuffer) buf).isDirect();
}
throw new UnsupportedOperationException(" BufferAux.isDirect was called on " + buf.getClass().getName());
}
示例7: loadTexture
import java.nio.Buffer; //導入依賴的package包/類
public static int loadTexture(final Buffer data, final int width,final int height, final int usedTexId,final int type) {
if(data == null)
return NO_TEXTURE;
int textures[] = new int[1];
if (usedTexId == NO_TEXTURE) {
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height,
0, GLES20.GL_RGBA, type, data);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, width,
height, GLES20.GL_RGBA, type, data);
textures[0] = usedTexId;
}
return textures[0];
}
示例8: clone
import java.nio.Buffer; //導入依賴的package包/類
/**
* Creates a clone of the given buffer. The clone's capacity is
* equal to the given buffer's limit.
*
* @param buf The buffer to clone
* @return The cloned buffer
*/
public static Buffer clone(Buffer buf) {
if (buf instanceof FloatBuffer) {
return clone((FloatBuffer) buf);
} else if (buf instanceof ShortBuffer) {
return clone((ShortBuffer) buf);
} else if (buf instanceof ByteBuffer) {
return clone((ByteBuffer) buf);
} else if (buf instanceof IntBuffer) {
return clone((IntBuffer) buf);
} else if (buf instanceof DoubleBuffer) {
return clone((DoubleBuffer) buf);
} else {
throw new UnsupportedOperationException();
}
}
示例9: withResult
import java.nio.Buffer; //導入依賴的package包/類
private static final CoderResult withResult(CoderResult cr,
Buffer src, int sp,
Buffer dst, int dp)
{
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
return cr;
}
示例10: inflateDirect
import java.nio.Buffer; //導入依賴的package包/類
int inflateDirect(ByteBuffer src, ByteBuffer dst) throws IOException {
assert (this instanceof ZlibDirectDecompressor);
ByteBuffer presliced = dst;
if (dst.position() > 0) {
presliced = dst;
dst = dst.slice();
}
Buffer originalCompressed = compressedDirectBuf;
Buffer originalUncompressed = uncompressedDirectBuf;
int originalBufferSize = directBufferSize;
compressedDirectBuf = src;
compressedDirectBufOff = src.position();
compressedDirectBufLen = src.remaining();
uncompressedDirectBuf = dst;
directBufferSize = dst.remaining();
int n = 0;
try {
n = inflateBytesDirect();
presliced.position(presliced.position() + n);
if (compressedDirectBufLen > 0) {
src.position(compressedDirectBufOff);
} else {
src.position(src.limit());
}
} finally {
compressedDirectBuf = originalCompressed;
uncompressedDirectBuf = originalUncompressed;
compressedDirectBufOff = 0;
compressedDirectBufLen = 0;
directBufferSize = originalBufferSize;
}
return n;
}
示例11: getFacesIndices
import java.nio.Buffer; //導入依賴的package包/類
public Buffer getFacesIndices()
{
if(mDirty)
{
mFacesIndices = BufferUtility.getIntBuffer(getInternalFacesIndices());
mDirty = false;
}
return mFacesIndices;
}
示例12: findBufferAddress
import java.nio.Buffer; //導入依賴的package包/類
private static long findBufferAddress() {
try {
return UNSAFE.objectFieldOffset(getDeclaredField(Buffer.class, "address"));
} catch (Exception e) {
throw new UnsupportedOperationException("Could not detect ByteBuffer.address offset", e);
}
}
示例13: testFreshInstance
import java.nio.Buffer; //導入依賴的package包/類
@AndroidIncompatible // problem with equality of Type objects?
public void testFreshInstance() {
assertFreshInstances(
String.class, CharSequence.class,
Appendable.class, StringBuffer.class, StringBuilder.class,
Pattern.class, MatchResult.class,
Number.class, int.class, Integer.class,
long.class, Long.class,
short.class, Short.class,
byte.class, Byte.class,
boolean.class, Boolean.class,
char.class, Character.class,
int[].class, Object[].class,
UnsignedInteger.class, UnsignedLong.class,
BigInteger.class, BigDecimal.class,
Throwable.class, Error.class, Exception.class, RuntimeException.class,
Charset.class, Locale.class, Currency.class,
List.class, Map.Entry.class,
Object.class,
Equivalence.class, Predicate.class, Function.class,
Comparable.class, Comparator.class, Ordering.class,
Class.class, Type.class, TypeToken.class,
TimeUnit.class, Ticker.class,
Joiner.class, Splitter.class, CharMatcher.class,
InputStream.class, ByteArrayInputStream.class,
Reader.class, Readable.class, StringReader.class,
OutputStream.class, ByteArrayOutputStream.class,
Writer.class, StringWriter.class, File.class,
Buffer.class, ByteBuffer.class, CharBuffer.class,
ShortBuffer.class, IntBuffer.class, LongBuffer.class,
FloatBuffer.class, DoubleBuffer.class,
String[].class, Object[].class, int[].class);
}
示例14: toString
import java.nio.Buffer; //導入依賴的package包/類
static String toString(Buffer b) {
return (b.getClass().getName()
+ "[pos=" + b.position()
+ " lim=" + b.limit()
+ " cap=" + b.capacity()
+ "]");
}
示例15: getVerticesPoints
import java.nio.Buffer; //導入依賴的package包/類
public Buffer getVerticesPoints()
{
if(mDirty)
{
mPositions = BufferUtility.getFloatBuffer(getInternalVerticesPoints());
}
return mPositions;
}