diff options
author | Michael Bien <[email protected]> | 2011-02-09 22:19:22 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-02-09 22:19:22 +0100 |
commit | e581ea0e1f65101a7d4baf99d18fa43e1aa20b01 (patch) | |
tree | d41b99d3ea1dd68e7054e63778aee5208980409d /src/java/com/jogamp/common/nio/AbstractBuffer.java | |
parent | e20879b9f124ecca8bc7467013e118d1b7f5782b (diff) |
- removed CDC impl for com.jogamp.common.nio
- generified class hierarchy (casts no longer needed in client code)
- @Override where needed and other minor changes
Diffstat (limited to 'src/java/com/jogamp/common/nio/AbstractBuffer.java')
-rw-r--r-- | src/java/com/jogamp/common/nio/AbstractBuffer.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java index f3ad9eb..870f3c0 100644 --- a/src/java/com/jogamp/common/nio/AbstractBuffer.java +++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java @@ -34,14 +34,12 @@ package com.jogamp.common.nio; import com.jogamp.common.os.*; import java.nio.ByteBuffer; -import java.nio.Buffer; -import java.util.HashMap; /** * @author Michael Bien * @author Sven Gothel */ -public abstract class AbstractBuffer implements NativeBuffer { +public abstract class AbstractBuffer<B extends AbstractBuffer> implements NativeBuffer<B> { protected final ByteBuffer bb; protected int capacity; @@ -70,13 +68,13 @@ public abstract class AbstractBuffer implements NativeBuffer { return position; } - public final NativeBuffer position(int newPos) { + public final B position(int newPos) { if (0 > newPos || newPos >= capacity) { throw new IndexOutOfBoundsException("Sorry to interrupt, but the position "+newPos+" was out of bounds. " + "My capacity is "+capacity()+"."); } position = newPos; - return this; + return (B)this; } public final int remaining() { @@ -87,9 +85,9 @@ public abstract class AbstractBuffer implements NativeBuffer { return position < capacity; } - public final NativeBuffer rewind() { + public final B rewind() { position = 0; - return this; + return (B) this; } public boolean hasArray() { @@ -108,6 +106,7 @@ public abstract class AbstractBuffer implements NativeBuffer { return bb.isDirect(); } + @Override public String toString() { return "AbstractBuffer[capacity "+capacity+", position "+position+", elementSize "+(bb.capacity()/capacity)+", ByteBuffer.capacity "+bb.capacity()+"]"; } |