summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/nio/AbstractBuffer.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-10 01:35:58 +0100
committerSven Gothel <[email protected]>2011-02-10 01:35:58 +0100
commit29eb568b642faac9475665d000a865fe684d42a4 (patch)
tree48d0fee6df82ce4f8fe35c3466cb3ed8690251dc /src/java/com/jogamp/common/nio/AbstractBuffer.java
parentcbb0bc1ef3d8c0464618c9f773cd1b4725059971 (diff)
parente581ea0e1f65101a7d4baf99d18fa43e1aa20b01 (diff)
Merge branch 'master' of github.com:mbien/gluegen
Diffstat (limited to 'src/java/com/jogamp/common/nio/AbstractBuffer.java')
-rw-r--r--src/java/com/jogamp/common/nio/AbstractBuffer.java13
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()+"]";
}