org.objectweb.easybeans.rpc.util
Class Hash

java.lang.Object
  extended by org.objectweb.easybeans.rpc.util.Hash

public final class Hash
extends java.lang.Object

Utility class providing some hashing methods on java.lang.reflect.Method or java.lang.Class.

Author:
Florent Benoit

Field Summary
private static int BYTE_MASK
          Mask for hashing algorithm.
private static int BYTES_LENGTH
          Length of hash of a method (eight byte sequence).
private static JLog logger
          Logger.
 
Constructor Summary
private Hash()
          Utility class, no public constructor.
 
Method Summary
static java.util.Map<java.lang.Long,java.lang.reflect.Method> hashClass(java.lang.Class clz)
          Gets a map between an hash and its associated method.
static long hashMethod(java.lang.reflect.Method method)
          Computes the hash for a given method.
The method hash to be used for the opnum parameter is a 64-bit (long) integer computed from the first two 32-bit values of the message digest of a particular byte stream using the National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA-1).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


BYTES_LENGTH

private static final int BYTES_LENGTH
Length of hash of a method (eight byte sequence).

See Also:
Constant Field Values

BYTE_MASK

private static final int BYTE_MASK
Mask for hashing algorithm.

See Also:
Constant Field Values
Constructor Detail

Hash

private Hash()
Utility class, no public constructor.

Method Detail

hashMethod

public static long hashMethod(java.lang.reflect.Method method)
Computes the hash for a given method.
The method hash to be used for the opnum parameter is a 64-bit (long) integer computed from the first two 32-bit values of the message digest of a particular byte stream using the National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA-1). This byte stream contains a string as if it was written using the java.io.DataOutput.writeUTF method, consisting of the remote method's name followed by its method descriptor (see section 4.3.3 of The Java Virtual Machine Specification (JVMS) for a description of method descriptors). The 64-bit hash value is the little-endian composition of an eight byte sequence where the first four bytes are the first 32-bit value of the message digest in big-endian byte order and the last four bytes are the second 32-bit value of the message digest in big-endian byte order.

Parameters:
method - the given method.
Returns:
the computed hash.
See Also:
Method hashing of RMI

hashClass

public static java.util.Map<java.lang.Long,java.lang.reflect.Method> hashClass(java.lang.Class clz)
Gets a map between an hash and its associated method.

Parameters:
clz - the class to analyze.
Returns:
a map with an hash and its associated method.