tokyocabinet
Class Util

java.lang.Object
  extended by tokyocabinet.Util

public class Util
extends java.lang.Object

Set of utility methods.


Method Summary
static int atoi(java.lang.String str)
          Convert a string to integer.
static long atol(java.lang.String str)
          Convert a string to integer.
static int chdir(java.lang.String path)
          Change current working directory using the native function `chdir' defined in POSIX.
static java.lang.Object deserialize(byte[] serial)
          Redintegrate a serialized object.
static java.lang.String getcwd()
          Get current working directory using the native function `getcwd' defined in POSIX.
static java.lang.String getenv(java.lang.String name)
          Get an environment variable using the native function `getenv' defined in POSIX and ANSI C.
static int getpid()
          Get process identification using the native function `getpid' defined in POSIX.
static java.lang.String itoa(long num, int cols, char padding)
          Convert a integer to string.
static byte[] packdouble(double num)
          Serialize a real number.
static byte[] packint(int num)
          Serialize an integer.
static int putenv(java.lang.String name, java.lang.String value)
          Set an environment variable using the native function `putenv' defined in POSIX and ANSI C.
static byte[] serialize(java.lang.Object obj)
          Serialize an object.
static int system(java.lang.String cmd)
          Execute a shell command using the native function `system' defined in POSIX and ANSI C.
static double time()
          Get the current time.
static double unpackdouble(byte[] serial)
          Redintegrate a serialized real number.
static int unpackint(byte[] serial)
          Redintegrate a serialized integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

atoi

public static int atoi(java.lang.String str)
Convert a string to integer.

Parameters:
str - a decimal string.
Returns:
the result integer.

atol

public static long atol(java.lang.String str)
Convert a string to integer.

Parameters:
str - a decimal string.
Returns:
the result integer.

chdir

public static int chdir(java.lang.String path)
Change current working directory using the native function `chdir' defined in POSIX.

Parameters:
path - the path of a directory.
Returns:
0 on success, or -1 on failure.

deserialize

public static java.lang.Object deserialize(byte[] serial)
Redintegrate a serialized object.

Parameters:
serial - a byte array of the serialized object.
Returns:
the original object or null if an error occurs.

getcwd

public static java.lang.String getcwd()
Get current working directory using the native function `getcwd' defined in POSIX.

Returns:
the path of the current working directory or null on failure.

getenv

public static java.lang.String getenv(java.lang.String name)
Get an environment variable using the native function `getenv' defined in POSIX and ANSI C.

Parameters:
name - the name of an environment variable.
Returns:
the value of the variable, or null if it does not exist.

getpid

public static int getpid()
Get process identification using the native function `getpid' defined in POSIX.

Returns:
the process ID of the current process.

itoa

public static java.lang.String itoa(long num,
                                    int cols,
                                    char padding)
Convert a integer to string.

Parameters:
num - a number.
cols - the number of columns. The result string may be longer than it.
padding - a padding character to fulfil columns with.

packdouble

public static byte[] packdouble(double num)
Serialize a real number.

Parameters:
num - a real number.
Returns:
a byte array of the serialized real number.

packint

public static byte[] packint(int num)
Serialize an integer.

Parameters:
num - an integer.
Returns:
a byte array of the serialized integer.

putenv

public static int putenv(java.lang.String name,
                         java.lang.String value)
Set an environment variable using the native function `putenv' defined in POSIX and ANSI C.

Parameters:
name - the name of an environment variable.
value - value of an environment variable.
Returns:
0 on success, or -1 on failure.

serialize

public static byte[] serialize(java.lang.Object obj)
Serialize an object.

Parameters:
obj - a serializable object.
Returns:
a byte array of the serialized object or null if an error occurs.

system

public static int system(java.lang.String cmd)
Execute a shell command using the native function `system' defined in POSIX and ANSI C.

Parameters:
cmd - a command line.
Returns:
the return value of the function. It depends on the native system.

time

public static double time()
Get the current time.

Returns:
the current time of seconds from the epoch.

unpackdouble

public static double unpackdouble(byte[] serial)
Redintegrate a serialized real number.

Parameters:
serial - a byte array of the serialized real number.
Returns:
the original real number.

unpackint

public static int unpackint(byte[] serial)
Redintegrate a serialized integer.

Parameters:
serial - a byte array of the serialized integer.
Returns:
the original integer.