From 9667575aabfbf6fe503bc2e14e5ac7ea743949b0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 10 Oct 2012 16:52:40 +0200 Subject: Buffers.toString(): Add optional format string for single element --- src/java/com/jogamp/common/nio/Buffers.java | 47 ++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'src/java/com/jogamp/common/nio/Buffers.java') diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index e4e20ef..5b5f83b 100755 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -877,10 +877,13 @@ public class Buffers { /** * Appends Buffer details inclusive data to a StringBuilder instance. * @param sb optional pass through StringBuilder + * @param f optional format string of one element, i.e. "%10.5f" for {@link FloatBuffer}, see {@link java.util.Formatter}, + * or null for unformatted output. + * Note: Caller is responsible to match the format string w/ the data type as expected in the given buffer. * @param buffer Any valid Buffer instance * @return the modified StringBuilder containing the Buffer details */ - public static StringBuilder toString(StringBuilder sb, Buffer buffer) { + public static StringBuilder toString(StringBuilder sb, String f, Buffer buffer) { if(null == sb) { sb = new StringBuilder(); } @@ -893,43 +896,71 @@ public class Buffers { final ByteBuffer b = (ByteBuffer)buffer; for(int i=0; i