/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
public long read(BytePtr buffer, long len) { return read(buffer.getHandle(), len); } public long read(ByteBuffer bytes) {
public long write(BytePtr buffer, long len) { return write(buffer.getHandle(), len); } public long write(ByteBuffer bytes) {
public long write(BytePtr buffer, long len) { return write(buffer.getHandle(), len); } public long write(ByteBuffer bytes) {
public long read(BytePtr buffer, long len) { return read(buffer.getHandle(), len); }
public NSData(BytePtr bytes, int length, boolean freeWhenDone) { super((SkipInit) null); if (bytes == null) { throw new NullPointerException("bytes"); } initObject(init(bytes.getHandle(), length, freeWhenDone)); }
/** * Returns a {@link String} created from the NUL-terminated C string pointed * to by this {@link BytePtr}. Non ASCII characters will be replaced with * '?' in the result. This method is more efficient than using * {@link #toStringZ(Charset)} with ASCII as {@link Charset}. * * @return a {@link String} containing the same characters as the C string * pointed to. */ public String toStringAsciiZ() { int length = 0; int b = 0; long address = getHandle(); while ((b = VM.getByte(address++)) != 0) { length++; } StringBuilder sb = new StringBuilder(length); address = getHandle(); while ((b = VM.getByte(address++)) != 0) { if (b < 0x80) { sb.append((char) b); } else { sb.append('?'); } } return sb.toString(); }
/** * Returns a {@link String} created from the NUL-terminated C string pointed * to by this {@link BytePtr} using the specified {@link Charset}. Illegal * characters will be replaced with '?' in the result. * * @param charset the {@link Charset} to use. Must be an 8-bit or variable * length character encoding with 8-bits as smallest value and that * can be NUL-terminated (e.g. UTF-8). * @return a {@link String} converted from the C string bytes. */ public String toStringZ(Charset charset) { int length = 0; long address = getHandle(); while (VM.getByte(address++) != 0) { length++; } return charset.decode(asByteBuffer(length)).toString(); }
/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
/** * Returns a {@link ByteBuffer} which reads and writes to the same memory * location pointed to by this {@link BytePtr}. * * @param n the maximum number of bytes the {@link ByteBuffer} can * read/write. This will be the {@link ByteBuffer}'s * <code>capacity</code>. * @return the {@link ByteBuffer}. */ public ByteBuffer asByteBuffer(int n) { return VM.newDirectByteBuffer(getHandle(), n); }
public long write(BytePtr buffer, long len) { return write(buffer.getHandle(), len); } public long write(ByteBuffer bytes) {
public long write(BytePtr buffer, long len) { return write(buffer.getHandle(), len); } public long write(ByteBuffer bytes) {
public long read(BytePtr buffer, long len) { return read(buffer.getHandle(), len); } public long read(ByteBuffer bytes) {
public long read(BytePtr buffer, long len) { return read(buffer.getHandle(), len); } public long read(ByteBuffer bytes) {
public long write(BytePtr buffer, long len) { return write(buffer.getHandle(), len); } public long write(ByteBuffer bytes) {
public NSData(BytePtr bytes, int length, boolean freeWhenDone) { super((SkipInit) null); if (bytes == null) { throw new NullPointerException("bytes"); } initObject(init(bytes.getHandle(), length, freeWhenDone)); }
public NSData(BytePtr bytes, int length, boolean freeWhenDone) { super((SkipInit) null); if (bytes == null) { throw new NullPointerException("bytes"); } initObject(init(bytes.getHandle(), length, freeWhenDone)); }