kyotocabinet
Class Utility

Object
  extended by Utility

public class Utility
extends Object

Utility functions.


Field Summary
static String VERSION
          The version information.
 
Method Summary
static double atof(String str)
          Convert a string to a real number.
static long atoi(String str)
          Convert a string with a metric prefix to an integer.
static long atoix(String str)
          Convert a string with a metric prefix to an integer.
static long hash_fnv(byte[] data)
          Get the hash value of a byte array by FNV hashing.
static long hash_murmur(byte[] data)
          Get the hash value of a byte array by MurMur hashing.
static boolean remove_files_recursively(String path)
          Remove a file or a directory recursively.
static double time()
          Get the current time.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
The version information.

Method Detail

atof

public static double atof(String str)
Convert a string to a real number.

Parameters:
str - specifies the string.
Returns:
the real number. If the string does not contain numeric expression, 0.0 is returned.

atoi

public static long atoi(String str)
Convert a string with a metric prefix to an integer.

Parameters:
str - the string.
Returns:
the integer. If the string does not contain numeric expression, 0 is returned.

atoix

public static long atoix(String str)
Convert a string with a metric prefix to an integer.

Parameters:
str - the string, which can be trailed by a binary metric prefix. "K", "M", "G", "T", "P", and "E" are supported. They are case-insensitive.
Returns:
the integer. If the string does not contain numeric expression, 0 is returned. If the integer overflows the domain, Long.MAX_VALUE or Long.MIN_VALUE is returned according to the sign.

hash_fnv

public static long hash_fnv(byte[] data)
Get the hash value of a byte array by FNV hashing.

Parameters:
data - the byte array.
Returns:
the hash value.

hash_murmur

public static long hash_murmur(byte[] data)
Get the hash value of a byte array by MurMur hashing.

Parameters:
data - the byte array.
Returns:
the hash value.

remove_files_recursively

public static boolean remove_files_recursively(String path)
Remove a file or a directory recursively.

Parameters:
path - the path of a file or a directory.
Returns:
true on success, or false on failure.

time

public static double time()
Get the current time.

Returns:
the current time from the epoch in seconds.