|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jouvieje.fmodex.utils.BufferUtils
Utility routines for dealing with direct buffers.
ABOUT THIS CLASS
This class is based on BufferUtils
of JOGL
from the package net.java.games.jogl.util
I've added in it few others routines.
Here is the copyright related to this file :
Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility. Sun gratefully acknowledges that this software was originally authored and developed by Kenneth Bradley Russell and Christopher John Kline.
Field Summary |
Fields inherited from interface org.jouvieje.fmodex.utils.SizeOfPrimitive |
SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT |
Constructor Summary | |
BufferUtils()
|
Method Summary | |
static Pointer |
asPointer(java.nio.Buffer buffer)
Create a view of the Buffer object as a Pointer object. |
static java.nio.ByteBuffer |
copyByteBuffer(java.nio.ByteBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.DoubleBuffer |
copyDoubleBuffer(java.nio.DoubleBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.FloatBuffer |
copyFloatBuffer(java.nio.FloatBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.IntBuffer |
copyIntBuffer(java.nio.IntBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.LongBuffer |
copyLongBuffer(java.nio.LongBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.ShortBuffer |
copyShortBuffer(java.nio.ShortBuffer src)
Make a copy of an existing buffer (src) to a new buffer (dest) |
static java.nio.ByteBuffer |
fromString(java.lang.String s)
Create a ByteBuffer containing a null terminated string (UTF-8). |
static java.nio.ByteBuffer |
fromStringUTF16(java.lang.String s)
Create a ByteBuffer containing a null terminated string (UTF-16LE). |
static int |
getCapacityInBytes(java.nio.Buffer buffer)
|
static int |
getPositionInBytes(java.nio.Buffer buffer)
|
static java.nio.ByteBuffer |
newByteBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.CharBuffer |
newCharBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.DoubleBuffer |
newDoubleBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.FloatBuffer |
newFloatBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.IntBuffer |
newIntBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.LongBuffer |
newLongBuffer(int nbElements)
Allocate a new direct buffer |
static java.nio.ShortBuffer |
newShortBuffer(int nbElements)
Allocate a new direct buffer |
static void |
putNullTerminal(java.nio.ByteBuffer buffer)
Relative put operation. |
static void |
putString(java.nio.ByteBuffer buffer,
java.lang.String s)
Relative put operation. |
static void |
putString(java.nio.ByteBuffer buffer,
java.lang.String s,
java.lang.String charset)
|
static java.lang.String |
toString(java.nio.ByteBuffer buffer)
Retrieve the String stored in the Buffer (Null terminated String). |
static java.lang.String |
toString(java.nio.ByteBuffer buffer,
int offset,
int length)
Retrieve the String stored in the Buffer . |
static java.lang.String |
toString(java.nio.CharBuffer charBuffer)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BufferUtils()
Method Detail |
public static java.nio.ByteBuffer newByteBuffer(int nbElements)
nbElements
- size of the ByteBuffer in bytes.
public static java.nio.CharBuffer newCharBuffer(int nbElements)
nbElements
- size of the ByteBuffer in chars.
public static java.nio.ShortBuffer newShortBuffer(int nbElements)
nbElements
- size of the ByteBuffer in shorts.
public static java.nio.IntBuffer newIntBuffer(int nbElements)
nbElements
- size of the ByteBuffer in ints.
public static java.nio.LongBuffer newLongBuffer(int nbElements)
nbElements
- size of the ByteBuffer in longs.
public static java.nio.FloatBuffer newFloatBuffer(int nbElements)
nbElements
- size of the ByteBuffer in floats.
public static java.nio.DoubleBuffer newDoubleBuffer(int nbElements)
nbElements
- size of the ByteBuffer in doubles.
public static java.nio.ByteBuffer copyByteBuffer(java.nio.ByteBuffer src)
src
- existing buffer to make a copy
public static java.nio.ShortBuffer copyShortBuffer(java.nio.ShortBuffer src)
src
- existing buffer to make a copy
public static java.nio.IntBuffer copyIntBuffer(java.nio.IntBuffer src)
src
- existing buffer to make a copy
public static java.nio.LongBuffer copyLongBuffer(java.nio.LongBuffer src)
src
- existing buffer to make a copy
public static java.nio.FloatBuffer copyFloatBuffer(java.nio.FloatBuffer src)
src
- existing buffer to make a copy
public static java.nio.DoubleBuffer copyDoubleBuffer(java.nio.DoubleBuffer src)
src
- existing buffer to make a copy
public static int getCapacityInBytes(java.nio.Buffer buffer)
buffer
- a buffer
public static int getPositionInBytes(java.nio.Buffer buffer)
buffer
- a buffer
public static java.lang.String toString(java.nio.ByteBuffer buffer)
String
stored in the Buffer
(Null terminated String).
buffer
- a buffer that holds a String
.
String
holded by the Buffer
.null
if no String
stored in the Buffer
.toString(ByteBuffer, int, int)
public static java.lang.String toString(java.nio.ByteBuffer buffer, int offset, int length)
String
stored in the Buffer
.
buffer
- a buffer that holds a String.offset
- offset (in bytes) from the current position in the ByteBuffer.length
- length of the String to retrieve from the buffer.
toString(ByteBuffer)
public static java.lang.String toString(java.nio.CharBuffer charBuffer)
public static java.nio.ByteBuffer fromString(java.lang.String s)
s
- a string
fromStringUTF16(String)
public static java.nio.ByteBuffer fromStringUTF16(java.lang.String s)
s
- a string
fromString(String)
public static void putString(java.nio.ByteBuffer buffer, java.lang.String s)
String
in a ByteBuffer
object.putNullTerminalCharacter
.
buffer
- a destination buffer for the String.s
- a String to copy in the BufferputNullTerminal(ByteBuffer)
public static void putString(java.nio.ByteBuffer buffer, java.lang.String s, java.lang.String charset)
charset
- string encodingputString(ByteBuffer, String)
,
putNullTerminal(ByteBuffer)
public static void putNullTerminal(java.nio.ByteBuffer buffer)
ByteBuffer
object.
buffer
- a destination buffer for the String.public static Pointer asPointer(java.nio.Buffer buffer)
Buffer
object as a Pointer
object.
buffer
- a direct ByteBuffer
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |