netcom.util
Class Util

java.lang.Object
  extended bynetcom.util.Util

public class Util
extends java.lang.Object

This class contains static utility methods used throughout the program


Constructor Summary
Util()
           
 
Method Summary
static int cardinality(java.util.BitSet set)
          This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for Bitset.cardinality()
static java.util.Collection combineCollections(java.util.Collection first, java.util.Collection second)
          Method to copy two synchronized collections into a unsynchronized Collection which contains pointers to all the objects in the first two collections.
static java.util.Map copyMap(java.util.Map input_map)
          Method to copy a syncrhonized Map to a thread-safe, unsyncrhonized copy ie.
static void flip(java.util.BitSet set, int i)
          This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for BitSet.flip()
static java.lang.String getBloomString(java.util.List[] name_list_pairs)
          This is a method to ensure the Name-List-Pairs are ALWAYS converted to Strings the SAME WAY (this is crucial for bloom filters)
static boolean isClosed(java.net.Socket s)
          It is very important to make sure no one is reading from the Socket s while you call isClosed.
static int nextSetBit(java.util.BitSet set, int idx)
          This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for Bitset.nextSetBit()
static void set(java.util.BitSet set, int i, boolean b)
          This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for BitSet.set()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

isClosed

public static boolean isClosed(java.net.Socket s)
It is very important to make sure no one is reading from the Socket s while you call isClosed. If another thread is reading from the socket while isClosed is called, behavior is undefined.

Parameters:
s - Socket whose connection we are testing
Returns:
whether or not the connection is closed

combineCollections

public static java.util.Collection combineCollections(java.util.Collection first,
                                                      java.util.Collection second)
Method to copy two synchronized collections into a unsynchronized Collection which contains pointers to all the objects in the first two collections. ie. a snapshot of the synchronized collections Either parameter can be null so this could really just make a 'copy' of a syncrhonized to another unsyncrhonized Collection which can be manipulated

Parameters:
first - the first synchronized collection to be copied
second - the second synchronized collection to be copied
Returns:
a NEW Collection with references to all the elements of the input collections however is not 'synchronized'

copyMap

public static java.util.Map copyMap(java.util.Map input_map)
Method to copy a syncrhonized Map to a thread-safe, unsyncrhonized copy ie. this takes a 'snapshort of a synchronized map

Parameters:
input_map - the synchronized map to copy out
Returns:
a NEW Map with all the entries the original map has but no 'synchronized'

getBloomString

public static java.lang.String getBloomString(java.util.List[] name_list_pairs)
This is a method to ensure the Name-List-Pairs are ALWAYS converted to Strings the SAME WAY (this is crucial for bloom filters)

Parameters:
name_list_pairs - the List[] with the name-list-pair information
Returns:
a String with a bloom filter representation of those name-list-pairs

set

public static void set(java.util.BitSet set,
                       int i,
                       boolean b)
This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for BitSet.set()


flip

public static void flip(java.util.BitSet set,
                        int i)
This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for BitSet.flip()


cardinality

public static int cardinality(java.util.BitSet set)
This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for Bitset.cardinality()


nextSetBit

public static int nextSetBit(java.util.BitSet set,
                             int idx)
This is a method to implement a java 1.4 method using java 1.3 calls See 1.4 docs for Bitset.nextSetBit()