|
Rice Pastry API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectrice.p2p.util.MathUtils
This class contains a large number of static methods for performing math operations.
| Field Summary | |
static char[] |
HEX_ARRAY
The array used for conversion to hexidecimal |
| Method Summary | |
static int |
byteArrayToInt(byte[] input)
Utility method for converting a byte[] into a int |
static long |
byteArrayToLong(byte[] input)
Utility method for converting a byte[] into a long |
static byte[] |
intToByteArray(int input)
Utility method for converting a int into a byte[] |
static void |
intToByteArray(int input,
byte[] output,
int offset)
Utility method for converting a int into a byte[] |
static byte[] |
longToByteArray(long input)
Utility method for converting a long into a byte[] |
static void |
longToByteArray(long input,
byte[] output,
int offset)
Utility method for converting a long into a byte[] |
static int |
mod(int a,
int b)
Utility which does *proper* modding, where the result is guaranteed to be positive. |
static byte[] |
randomBytes(int len)
Method which returns a specified number of random bytes |
static int |
randomInt()
Method which returns a random int |
static java.lang.String |
toHex(byte[] text)
Utility method which converts a byte[] to a hexidecimal string of characters, in lower case |
static byte[] |
xor(byte[] a,
byte[] b)
Utility method which xors two given byte arrays, of equal length, and returns the results |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final char[] HEX_ARRAY
| Method Detail |
public static int mod(int a,
int b)
a - The modeeb - The value to mod by
public static byte[] xor(byte[] a,
byte[] b)
a - The first arrayb - The second array
public static byte[] randomBytes(int len)
len - The number of random bytes to generate
public static int randomInt()
public static java.lang.String toHex(byte[] text)
text - The array to convert
public static byte[] intToByteArray(int input)
input - The log to convert
public static void intToByteArray(int input,
byte[] output,
int offset)
input - The log to convertoutput - DESCRIBE THE PARAMETERoffset - DESCRIBE THE PARAMETERpublic static int byteArrayToInt(byte[] input)
input - The byte[] to convert
public static byte[] longToByteArray(long input)
input - The log to convert
public static void longToByteArray(long input,
byte[] output,
int offset)
input - The log to convertoutput - DESCRIBE THE PARAMETERoffset - DESCRIBE THE PARAMETERpublic static long byteArrayToLong(byte[] input)
input - The byte[] to convert
|
Rice Pastry API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||