net.tomp2p.utils
Class Utils
java.lang.Object
net.tomp2p.utils.Utils
public class Utils
- extends Object
Constructor Summary |
Utils()
|
Method Summary |
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 String |
debugArray(byte[] array)
|
static String |
debugArray(byte[] array,
int offset,
int length)
|
static Object |
decodeJavaObject(byte[] me,
int offset,
int length)
|
static
|
difference(Collection<K> collection1,
Collection<K> result,
Collection<K>... collections2)
Stores the differences of multiple collections in a result collection. |
static
|
difference(Collection<K> collection1,
Collection<K> result,
Collection<K> collection2)
Stores the differences of two collections in a result collection. |
static DigestInfo |
digest(Digest storage,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys)
|
static
|
disjunction(Map<K,V> a,
Collection<K> b)
|
static byte[] |
encodeJavaObject(Object attachement)
|
static
|
getLast(List<K> list)
|
static byte[] |
intToByteArray(int value)
|
static
|
limit(Collection<K> a,
int size)
|
static
|
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 PeerAddress |
pollFirst(SortedSet<PeerAddress> queue)
|
static
|
pollRandom(SortedSet<K> queueToAsk,
Random rnd)
|
static
|
pollRandomKey(Map<K,V> queueToAsk,
Random rnd)
|
static
|
subtract(Collection<K> a,
Collection<K> b)
|
static
|
subtract(Map<K,V> a,
Collection<K> b)
|
static byte[] |
uncompress(byte[] compressedData)
|
static byte[] |
uncompress(byte[] compressedData,
int offset,
int length)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utils
public Utils()
loadFile
public static ByteBuffer loadFile(File file)
throws IOException
- Throws:
IOException
makeSHAHash
public static Number160 makeSHAHash(File file)
makeSHAHash
public static Number160 makeSHAHash(String strInput)
makeSHAHash
public static Number160 makeSHAHash(ByteBuffer buffer)
makeSHAHash
public static Number160 makeSHAHash(byte[] buffer)
makeSHAHash
public static Number160 makeSHAHash(byte[] buffer,
int offset,
int length)
createRandomNodeID
public static Number160 createRandomNodeID()
compress
public static byte[] compress(byte[] input)
uncompress
public static byte[] uncompress(byte[] compressedData,
int offset,
int length)
uncompress
public static byte[] uncompress(byte[] compressedData)
encodeJavaObject
public static byte[] encodeJavaObject(Object attachement)
throws IOException
- Throws:
IOException
decodeJavaObject
public static Object decodeJavaObject(byte[] me,
int offset,
int length)
throws ClassNotFoundException,
IOException
- Throws:
ClassNotFoundException
IOException
difference
public static <K> Collection<K> difference(Collection<K> collection1,
Collection<K> result,
Collection<K> collection2)
- Stores the differences of two collections in a result collection.
The result will contain items from collection1 without those items that
are in collection2.
- Parameters:
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
duplicates
- Returns:
- Returns the collection the user specified as the resulting
collection
difference
public static <K> Collection<K> difference(Collection<K> collection1,
Collection<K> result,
Collection<K>... collections2)
- Stores the differences of multiple collections in a result collection.
The result will contain items from collection1 without those items that
are in collections2. The calling method might need to provide a
- Parameters:
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
duplicates
- Returns:
- Returns the collection the user specified as the resulting
collection
bestEffortclose
public static void bestEffortclose(Closeable... closables)
pollFirst
public static PeerAddress pollFirst(SortedSet<PeerAddress> queue)
intToByteArray
public static final byte[] intToByteArray(int value)
byteArrayToInt
public static final int byteArrayToInt(byte[] b)
digest
public static DigestInfo digest(Digest storage,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys)
pollRandom
public static <K> K pollRandom(SortedSet<K> queueToAsk,
Random rnd)
pollRandomKey
public static <K,V> Map.Entry<K,V> pollRandomKey(Map<K,V> queueToAsk,
Random rnd)
subtract
public static <K> Collection<K> subtract(Collection<K> a,
Collection<K> b)
subtract
public static <K,V> Map<K,V> subtract(Map<K,V> a,
Collection<K> b)
disjunction
public static <K,V> Map<K,V> disjunction(Map<K,V> a,
Collection<K> b)
limit
public static <K> Collection<K> limit(Collection<K> a,
int size)
limit
public static <K,V> Map<K,V> limit(Map<K,V> a,
int i)
convert
public static Collection<Number160> convert(Collection<TrackerData> a)
debugArray
public static String debugArray(byte[] array,
int offset,
int length)
debugArray
public static String debugArray(byte[] array)
checkEntryProtection
public static boolean checkEntryProtection(Map<Number160,Data> dataMap)
addReleaseListener
public static void addReleaseListener(BaseFuture baseFuture,
ConnectionReservation connectionReservation,
ChannelCreator cc,
int nr)
addReleaseListenerAll
public static void addReleaseListenerAll(BaseFuture baseFuture,
ConnectionReservation connectionReservation,
ChannelCreator channelCreator)
limitRandom
public static Map<Number160,TrackerData> limitRandom(Map<Number160,TrackerData> activePeers,
int trackerSize)
getLast
public static <K> K getLast(List<K> list)
Copyright © 2012. All Rights Reserved.