|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mymed.utils.MConverter
public final class MConverter
Convenience class to convert to and from ByteBuffer
for the most used
data types.
Method Summary | |
---|---|
static java.nio.ByteBuffer |
booleanToByteBuffer(boolean value)
Convert a boolean value into a fictitious ByteBuffer |
static boolean |
byteBufferToBoolean(java.nio.ByteBuffer buffer)
Convert a boolean value contained in a ByteBuffer into a boolean |
static byte |
byteBufferToByte(java.nio.ByteBuffer buffer)
Convert a ByteBuffer into a byte
No assumptions are made on the value stored in the ByteBuffer, it has to
be a byte |
static double |
byteBufferToDouble(java.nio.ByteBuffer buffer)
Convert a ByteBuffer into an double
No assumptions are made on the value stored in the ByteBuffer, it has to
be a double |
static int |
byteBufferToInteger(java.nio.ByteBuffer buffer)
Convert a ByteBuffer into an integer
No assumptions are made on the value stored in the ByteBuffer, it has to
be an integer |
static long |
byteBufferToLong(java.nio.ByteBuffer buffer)
Convert a ByteBuffer into an long
No assumptions are made on the value stored in the ByteBuffer, it has to
be a long |
static java.lang.String |
byteBufferToString(java.nio.ByteBuffer buffer)
Convert a ByteBuffer back into a string |
static java.nio.ByteBuffer |
byteToByteBuffer(byte value)
Convert a byte value into a ByteBuffer |
static java.nio.ByteBuffer |
byteToByteBuffer(java.lang.Byte value)
Convert a byte value into a ByteBuffer |
static java.lang.String |
convertStreamToString(java.io.InputStream is,
int length)
Given an InputStream reads the bytes as UTF8 chars and return a String. |
static java.nio.ByteBuffer |
doubleToByteBuffer(double value)
Convert a double value into a ByteBuffer |
static java.nio.ByteBuffer |
doubleToByteBuffer(java.lang.Double value)
Convert a double value into a ByteBuffer |
static java.nio.ByteBuffer |
intToByteBuffer(int value)
Convert an integer value into a ByteBuffer |
static java.nio.ByteBuffer |
intToByteBuffer(java.lang.Integer value)
Convert an integer value into a ByteBuffer |
static java.nio.ByteBuffer |
longToByteBuffer(long value)
Convert a long value into a ByteBuffer |
static java.nio.ByteBuffer |
longToByteBuffer(java.lang.Long value)
Convert a long value into a ByteBuffer |
static java.util.List<java.nio.ByteBuffer> |
stringToByteBuffer(java.util.List<java.lang.String> list)
Convert a list of strings in a list with the strings converted into ByteBuffer |
static java.nio.ByteBuffer |
stringToByteBuffer(java.lang.String string)
Convert a string into a ByteBuffer . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.nio.ByteBuffer stringToByteBuffer(java.lang.String string) throws InternalBackEndException
ByteBuffer
. If the String
object
passed is null, it is treated as an empty string
string
- the string to convert
ByteBuffer
InternalBackEndException
- when a wrong encoding is usedpublic static java.util.List<java.nio.ByteBuffer> stringToByteBuffer(java.util.List<java.lang.String> list) throws InternalBackEndException
ByteBuffer
list
- the list with the strings to convert
InternalBackEndException
- if one of the strings is null, or when a wrong encoding is
usedpublic static java.lang.String byteBufferToString(java.nio.ByteBuffer buffer) throws InternalBackEndException
ByteBuffer
back into a string
buffer
- the ByteBuffer
to convert
InternalBackEndException
- if the buffer is null, or when a wrong encoding is usedpublic static java.nio.ByteBuffer intToByteBuffer(int value)
ByteBuffer
value
- the integer to convert
public static java.nio.ByteBuffer intToByteBuffer(java.lang.Integer value)
ByteBuffer
value
- the integer to convert
public static int byteBufferToInteger(java.nio.ByteBuffer buffer)
ByteBuffer
into an integer
No assumptions are made on the value stored in the ByteBuffer, it has to be an integer
buffer
- the ByteBuffer that holds the integer value
public static java.nio.ByteBuffer longToByteBuffer(long value)
ByteBuffer
value
- the long to convert
public static java.nio.ByteBuffer longToByteBuffer(java.lang.Long value)
ByteBuffer
value
- the long to convert
public static long byteBufferToLong(java.nio.ByteBuffer buffer)
ByteBuffer
into an long
No assumptions are made on the value stored in the ByteBuffer, it has to be a long
buffer
- the ByteBuffer that holds the long value
public static java.nio.ByteBuffer byteToByteBuffer(byte value)
ByteBuffer
value
- the byte value to convert
public static java.nio.ByteBuffer byteToByteBuffer(java.lang.Byte value)
ByteBuffer
value
- the byte value to convert
public static byte byteBufferToByte(java.nio.ByteBuffer buffer)
ByteBuffer
into a byte
No assumptions are made on the value stored in the ByteBuffer, it has to be a byte
buffer
- the ByteBuffer that holds the byte value
public static java.nio.ByteBuffer doubleToByteBuffer(double value)
ByteBuffer
value
- the double to convert
public static java.nio.ByteBuffer doubleToByteBuffer(java.lang.Double value)
ByteBuffer
value
- the double to convert
public static double byteBufferToDouble(java.nio.ByteBuffer buffer)
ByteBuffer
into an double
No assumptions are made on the value stored in the ByteBuffer, it has to be a double
buffer
- the ByteBuffer that holds the double value
public static java.nio.ByteBuffer booleanToByteBuffer(boolean value)
ByteBuffer
value
- the boolean to convert
ByteBuffer
representation of the boolean valuepublic static boolean byteBufferToBoolean(java.nio.ByteBuffer buffer)
buffer
- the buffer with the boolean value
public static java.lang.String convertStreamToString(java.io.InputStream is, int length) throws InternalBackEndException
is
- Input stream.length
- Length of the stream in bytes.
InternalBackEndException
- Format is not correct or the length less then the real wrong.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |