|
JAPI 0.9.0 Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.japi.io.Nibbles
public final class Nibbles
A class to get nibbles from byte sequences. This class works in sequentially numbered big endian (network byte) order, which means that the first nibble (0-nibble) is the high nibble of the first byte (high byte high nibble). You may also call this "high nibble first". The long value 0x0123456789ABCDEFl reflects the nibble indices in longs. Other datatypes work similarly: The int value 0x01234567 reflects the nibble indices in ints.
Binary nibbles are returned as ints because the general contract of I/O-methods as in packagejava.io
is to expect and return single
bytes being stored in ints and it saves neither space nor performance to return bytes instead of ints.
When needing chars, you should invoke those methods returning chars directly (single method invocation) instead of first getting the nibble and then
converting it to a char (two method invocations) because inlining compilers will give you a better performance then.
Everything in this class is final for performance reasons: Final methods can be sort of inlined by some compilers.
Method Summary | |
---|---|
static int |
getNibble(byte[] data,
int index)
Get a nibble from a byte array. |
static int |
getNibble(byte data,
int index)
Get a nibble from a byte value. |
static int |
getNibble(char data,
int index)
Get a nibble from a char value. |
static int |
getNibble(double data,
int index)
Get a nibble from a double value (raw format). |
static int |
getNibble(float data,
int index)
Get a nibble from a float value (raw format). |
static int |
getNibble(int data,
int index)
Get a nibble from an int value. |
static int |
getNibble(long data,
int index)
Get a nibble from a long value. |
static int |
getNibble(short data,
int index)
Get a nibble from a short value. |
static char |
getNibbleLC(byte[] data,
int index)
Get a lowercase character reflecting a nibble from a byte array. |
static char |
getNibbleLC(byte data,
int index)
Get a lowercase character reflecting a nibble from a byte. |
static char |
getNibbleLC(char data,
int index)
Get a lowercase character reflecting a nibble from a char. |
static char |
getNibbleLC(double data,
int index)
Get a lowercase character reflecting a nibble from a double. |
static char |
getNibbleLC(float data,
int index)
Get a lowercase character reflecting a nibble from a float. |
static char |
getNibbleLC(int nibble)
Get a lowercase character for a nibble. |
static char |
getNibbleLC(int data,
int index)
Get a lowercase character reflecting a nibble from a int. |
static char |
getNibbleLC(long data,
int index)
Get a lowercase character reflecting a nibble from a long. |
static char |
getNibbleLC(short data,
int index)
Get a lowercase character reflecting a nibble from a short. |
static byte[] |
getNibbles(byte[] data)
Get all nibbles from a byte array. |
static byte[] |
getNibbles(byte[] data,
int startIndex,
int length)
Get some nibbles from a byte array. |
static char |
getNibbleUC(byte[] data,
int index)
Get an uppercase character reflecting a nibble from a byte array. |
static char |
getNibbleUC(byte data,
int index)
Get an uppercase character reflecting a nibble from a byte. |
static char |
getNibbleUC(char data,
int index)
Get an uppercase character reflecting a nibble from a char. |
static char |
getNibbleUC(double data,
int index)
Get an uppercase character reflecting a nibble from a double. |
static char |
getNibbleUC(float data,
int index)
Get an uppercase character reflecting a nibble from a float. |
static char |
getNibbleUC(int nibble)
Get a uppercase character for a nibble. |
static char |
getNibbleUC(int data,
int index)
Get an uppercase character reflecting a nibble from a int. |
static char |
getNibbleUC(long data,
int index)
Get an uppercase character reflecting a nibble from a long. |
static char |
getNibbleUC(short data,
int index)
Get an uppercase character reflecting a nibble from a short. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int getNibble(byte[] data, int index)
data
- byte array to get nibble fromindex
- nibble number
public static byte[] getNibbles(byte[] data)
data
- byte array to get nibbles from
public static byte[] getNibbles(byte[] data, int startIndex, int length)
data
- byte array to get nibbles fromstartIndex
- first nibble index to get nibble forlength
- number of nibbles to get
public static int getNibble(byte data, int index)
data
- byte value to get nibble fromindex
- nibble number
public static int getNibble(short data, int index)
data
- short value to get nibble fromindex
- nibble number
public static int getNibble(int data, int index)
data
- int value to get nibble fromindex
- nibble number
public static int getNibble(long data, int index)
data
- int value to get nibble fromindex
- nibble number
public static int getNibble(char data, int index)
data
- char value to get nibble fromindex
- nibble nubmer
public static int getNibble(float data, int index)
Float.floatToIntBits(float)
.
data
- float value to get nibble fromindex
- nibble nubmer
public static int getNibble(double data, int index)
Double.doubleToLongBits(double)
.
data
- double value to get nibble fromindex
- nibble nubmer
public static char getNibbleLC(int nibble)
nibble
- nibble to get character for
IllegalArgumentException
- if data
isn't a single nibblepublic static char getNibbleUC(int nibble)
nibble
- nibble to get character for
IllegalArgumentException
- if data
isn't a single nibblepublic static char getNibbleLC(byte[] data, int index)
data
- byte array to get nibble fromindex
- nibble number
public static char getNibbleUC(byte[] data, int index)
data
- byte array to get nibble fromindex
- nibble number
public static char getNibbleLC(byte data, int index)
data
- byte to get nibble fromindex
- nibble number
public static char getNibbleUC(byte data, int index)
data
- byte to get nibble fromindex
- nibble number
public static char getNibbleLC(short data, int index)
data
- short to get nibble fromindex
- nibble number
public static char getNibbleUC(short data, int index)
data
- short to get nibble fromindex
- nibble number
public static char getNibbleLC(int data, int index)
data
- int to get nibble fromindex
- nibble number
public static char getNibbleUC(int data, int index)
data
- int to get nibble fromindex
- nibble number
public static char getNibbleLC(long data, int index)
data
- long to get nibble fromindex
- nibble number
public static char getNibbleUC(long data, int index)
data
- long to get nibble fromindex
- nibble number
public static char getNibbleLC(char data, int index)
data
- char to get nibble fromindex
- nibble number
public static char getNibbleUC(char data, int index)
data
- char to get nibble fromindex
- nibble number
public static char getNibbleLC(float data, int index)
data
- float to get nibble fromindex
- nibble number
public static char getNibbleUC(float data, int index)
data
- float to get nibble fromindex
- nibble number
public static char getNibbleLC(double data, int index)
data
- double to get nibble fromindex
- nibble number
public static char getNibbleUC(double data, int index)
data
- double to get nibble fromindex
- nibble number
|
JAPI Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |