From e581ea0e1f65101a7d4baf99d18fa43e1aa20b01 Mon Sep 17 00:00:00 2001
From: Michael Bien <mbien@fh-landshut.de>
Date: Wed, 9 Feb 2011 22:19:22 +0100
Subject: - 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

---
 src/java/com/jogamp/common/nio/AbstractBuffer.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

(limited to 'src/java/com/jogamp/common/nio/AbstractBuffer.java')

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()+"]";
     }
-- 
cgit v1.2.3