qdbm
Class Util

java.lang.Object
  extended by qdbm.Util

public class Util
extends java.lang.Object

Class of utility methods. This class depends on the native library `jqdbm'.


Method Summary
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 long deserializeLong(byte[] serial)
          Redintegrate a serialized long integer.
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 numstr(int num, int cols, char padding)
          Get a formatted decimal string made from a number.
static byte[] readFile(java.lang.String path)
          Read whole data of a file.
static byte[] serialize(java.lang.Object obj)
          Serialize an object.
static byte[] serializeLong(long num)
          Serialize a long integer.
static int system(java.lang.String cmd)
          Execute a shell command using the native function `system' defined in POSIX and ANSI C.
static boolean writeFile(java.lang.String path, byte[] data)
          Write whole data to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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:
an original object or null if an error occurs.

deserializeLong

public static long deserializeLong(byte[] serial)
                            throws java.lang.IllegalArgumentException
Redintegrate a serialized long integer.

Parameters:
serial - a byte array of a serialized long integer.
Returns:
the long value.
Throws:
java.lang.IllegalArgumentException - thrown if the size of the array is invalid.

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.

numstr

public static java.lang.String numstr(int num,
                                      int cols,
                                      char padding)
Get a formatted decimal string made from a number.

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.

readFile

public static byte[] readFile(java.lang.String path)
Read whole data of a file.

Parameters:
path - the path of a file.
Returns:
while data of a file on success, or null 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.

serializeLong

public static byte[] serializeLong(long num)
Serialize a long integer.

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

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.

writeFile

public static boolean writeFile(java.lang.String path,
                                byte[] data)
Write whole data to a file.

Parameters:
path - the path of a file.
data - data to write.
Returns:
true if success, false on failure.