code: public static Pointer toBuffer(Buffer buffer)
      {
          if (buffer == null || (!buffer.isDirect() && !buffer.hasArray()))
          {
              throw new IllegalArgumentException(
                  "Buffer may not be null and must have an array or be direct");
          }
          if (buffer instanceof ByteBuffer)
          {
              return computePointer((ByteBuffer)buffer);
          }
          if (buffer instanceof ShortBuffer)
          {
              return computePointer((ShortBuffer)buffer);
          }
          if (buffer instanceof IntBuffer)
          {
              return computePointer((IntBuffer)buffer);
          }
          if (buffer instanceof LongBuffer)
          {
              return computePointer((LongBuffer)buffer);
          }
          if (buffer instanceof FloatBuffer)
          {
              return computePointer((FloatBuffer)buffer);
          }
          if (buffer instanceof DoubleBuffer)
          {
              return computePointer((DoubleBuffer)buffer);
          }
          throw new IllegalArgumentException(
              "Unknown buffer type: "+buffer);
  
      }
docs: Creates a new Pointer to the given buffer.<br />
  <br />
  Note that this method takes into account the array offset and position
  of the given buffer, in contrast to the {@link #to(Buffer)} method.
  
  @param buffer The buffer
  @return The new pointer
  @throws IllegalArgumentException If the given buffer
  is null or is neither direct nor has a backing array