public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
addReleaseListener(BaseFuture baseFuture,
ConnectionReservation connectionReservation,
ChannelCreator cc,
int nr) |
static void |
addReleaseListenerAll(BaseFuture baseFuture,
ConnectionReservation connectionReservation,
ChannelCreator channelCreator) |
static void |
bestEffortclose(Closeable... closables) |
static int |
byteArrayToInt(byte[] b) |
static boolean |
checkEntryProtection(Map<Number160,Data> dataMap) |
static byte[] |
compress(byte[] input) |
static Collection<Number160> |
convert(Collection<TrackerData> a) |
static Number160 |
createRandomNodeID() |
static File |
createTempDir() |
static String |
debugArray(byte[] array) |
static String |
debugArray(byte[] array,
int offset,
int length) |
static Object |
decodeJavaObject(byte[] me,
int offset,
int length) |
static Object |
decodeJavaObject(org.jboss.netty.buffer.ChannelBuffer channelBuffer) |
static <K> Collection<K> |
difference(Collection<K> collection1,
Collection<K> result,
Collection<K>... collections2)
Stores the differences of multiple collections in a result collection.
|
static <K> Collection<K> |
difference(Collection<K> collection1,
Collection<K> result,
Collection<K> collection2)
Stores the differences of two collections in a result collection.
|
static <K,V> Map<K,V> |
disjunction(Map<K,V> a,
Collection<K> b) |
static byte[] |
encodeJavaObject(Object attachement) |
static Collection<Number160> |
extractContentKeys(Collection<Number480> collection) |
static Inet4Address |
fromInteger(int address)
Returns an Inet4Address having the integer value specified by the
argument.
|
static <K> K |
getLast(List<K> list) |
static byte[] |
intToByteArray(int value) |
static <K> Collection<K> |
limit(Collection<K> a,
int size) |
static <K,V> Map<K,V> |
limit(Map<K,V> a,
int i) |
static Map<Number160,TrackerData> |
limitRandom(Map<Number160,TrackerData> activePeers,
int trackerSize) |
static ByteBuffer |
loadFile(File file) |
static Number160 |
makeSHAHash(byte[] buffer) |
static Number160 |
makeSHAHash(byte[] buffer,
int offset,
int length) |
static Number160 |
makeSHAHash(ByteBuffer buffer) |
static Number160 |
makeSHAHash(File file) |
static Number160 |
makeSHAHash(String strInput) |
static void |
nullCheck(Object... objects) |
static boolean |
nullCheckRetVal(Object... objects) |
static <K> K |
pollRandom(Collection<K> collection,
Random rnd)
Returns a random element from a collection.
|
static <K,V> Map.Entry<K,V> |
pollRandomKey(Map<K,V> queueToAsk,
Random rnd) |
static <K> Collection<K> |
subtract(Collection<K> a,
Collection<K> b) |
static <K,V> Map<K,V> |
subtract(Map<K,V> a,
Collection<K> b) |
static byte[] |
uncompress(byte[] compressedData) |
static byte[] |
uncompress(byte[] compressedData,
int offset,
int length) |
public static ByteBuffer loadFile(File file) throws IOException
IOException
public static Number160 makeSHAHash(ByteBuffer buffer)
public static Number160 makeSHAHash(byte[] buffer)
public static Number160 makeSHAHash(byte[] buffer, int offset, int length)
public static Number160 createRandomNodeID()
public static byte[] compress(byte[] input)
public static byte[] uncompress(byte[] compressedData, int offset, int length)
public static byte[] uncompress(byte[] compressedData)
public static byte[] encodeJavaObject(Object attachement) throws IOException
IOException
public static Object decodeJavaObject(org.jboss.netty.buffer.ChannelBuffer channelBuffer) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static Object decodeJavaObject(byte[] me, int offset, int length) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static <K> Collection<K> difference(Collection<K> collection1, Collection<K> result, Collection<K> collection2)
collection1
- The first collection (master collection) that will be iterated
and checked against duplicates in collection2.result
- The collection to store the resultcollection2
- The second collection that will be searched for duplicatespublic static <K> Collection<K> difference(Collection<K> collection1, Collection<K> result, Collection<K>... collections2)
collection1
- The first collection (master collection) that will be iterated
and checked against duplicates in collection2.result
- The collection to store the resultcollection2
- The second collections that will be searched for duplicatespublic static void bestEffortclose(Closeable... closables)
public static final byte[] intToByteArray(int value)
public static final int byteArrayToInt(byte[] b)
public static <K> K pollRandom(Collection<K> collection, Random rnd)
List
and fetches a random
element using List.get(int)
.collection
- The collection from which we want to pick a random elementrnd
- The random objectpublic static <K> Collection<K> subtract(Collection<K> a, Collection<K> b)
public static <K,V> Map<K,V> subtract(Map<K,V> a, Collection<K> b)
public static <K,V> Map<K,V> disjunction(Map<K,V> a, Collection<K> b)
public static <K> Collection<K> limit(Collection<K> a, int size)
public static Collection<Number160> convert(Collection<TrackerData> a)
public static String debugArray(byte[] array, int offset, int length)
public static String debugArray(byte[] array)
public static void addReleaseListener(BaseFuture baseFuture, ConnectionReservation connectionReservation, ChannelCreator cc, int nr)
public static void addReleaseListenerAll(BaseFuture baseFuture, ConnectionReservation connectionReservation, ChannelCreator channelCreator)
public static Map<Number160,TrackerData> limitRandom(Map<Number160,TrackerData> activePeers, int trackerSize)
public static <K> K getLast(List<K> list)
public static Inet4Address fromInteger(int address)
address
- int
, the 32bit integer address to be convertedInet4Address
equivalent of the argumentpublic static File createTempDir() throws IOException
IOException
public static void nullCheck(Object... objects)
public static boolean nullCheckRetVal(Object... objects)
public static Collection<Number160> extractContentKeys(Collection<Number480> collection)
Copyright © 2013. All Rights Reserved.