当前位置: 首页>>代码示例>>Java>>正文


Java Buffer类代码示例

本文整理汇总了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));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:27,代码来源:ArbitraryInstancesTest.java

示例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);
        }

    }
}
 
开发者ID:beehive-lab,项目名称:Maxine-VM,代码行数:26,代码来源:JniFunctions.java

示例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];
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:27,代码来源:OpenGlUtils.java

示例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];
  }
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:26,代码来源:OpenGLUtils.java

示例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);
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:18,代码来源:EXTDirectStateAccess.java

示例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());
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:22,代码来源:BufferUtils.java

示例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];
}
 
开发者ID:TobiasLee,项目名称:FilterPlayer,代码行数:26,代码来源:OpenGlUtils.java

示例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();
    }
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:23,代码来源:BufferUtils.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SingleByte.java

示例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;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:36,代码来源:ZlibDecompressor.java

示例11: getFacesIndices

import java.nio.Buffer; //导入依赖的package包/类
public Buffer getFacesIndices()
  {
if(mDirty)
{
	mFacesIndices = BufferUtility.getIntBuffer(getInternalFacesIndices());
	mDirty = false;
}
return mFacesIndices;
  }
 
开发者ID:WissamElkadi,项目名称:TriMeshKit,代码行数:10,代码来源:TriMesh.java

示例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);
	}
}
 
开发者ID:httpdigest,项目名称:ftljson,代码行数:8,代码来源:Unsafe.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:34,代码来源:FreshValueGeneratorTest.java

示例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()
            + "]");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:Basic.java

示例15: getVerticesPoints

import java.nio.Buffer; //导入依赖的package包/类
public Buffer getVerticesPoints()
  {
if(mDirty)
{
	mPositions = BufferUtility.getFloatBuffer(getInternalVerticesPoints());
}

return mPositions;
  }
 
开发者ID:WissamElkadi,项目名称:TriMeshKit,代码行数:10,代码来源:TriMesh.java


注:本文中的java.nio.Buffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。