tools
Class UniversalTool

java.lang.Object
  extended by tools.UniversalTool

public class UniversalTool
extends java.lang.Object

Class for various purposes

Author:
Leo Bosnjak

Constructor Summary
UniversalTool()
           
 
Method Summary
static boolean compareIntArrs(int[] intArr1, int[] intArr2)
          Compares two int[].
static java.lang.String getCurrentTimeString()
          Returns the current date and time as string.
static java.lang.String getExceptionString(java.lang.Exception e)
          Formats the given exception and returns its string representation.
static java.lang.String getExceptionString(java.lang.Exception e, boolean getStackTrace)
          Formats the given exception and returns its string representation.
static boolean loadObjectsFromFile(java.lang.String filePath, java.util.Vector<java.lang.Object> objectsToLoad)
          Load the given objects from an existing file previously saved using the saveObjectsToFile method.
static boolean saveObjectsToFile(java.lang.String filePath, java.util.Vector<java.lang.Object> objectsToSave)
          Save objects into file for later use.
static boolean writeRandomFile(java.lang.String filePath, int size)
          Writes a random int sequence of the required size to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniversalTool

public UniversalTool()
Method Detail

getCurrentTimeString

public static java.lang.String getCurrentTimeString()
Returns the current date and time as string.

Returns:
the current time as a String

getExceptionString

public static java.lang.String getExceptionString(java.lang.Exception e)
Formats the given exception and returns its string representation.

Parameters:
e -
Returns:
the String representation of the Exception

getExceptionString

public static java.lang.String getExceptionString(java.lang.Exception e,
                                                  boolean getStackTrace)
Formats the given exception and returns its string representation.

Parameters:
e -
getStackTrace -
Returns:
the String representation of the Exception

compareIntArrs

public static boolean compareIntArrs(int[] intArr1,
                                     int[] intArr2)
Compares two int[].

Parameters:
intArr1 -
intArr2 -
Returns:
true if they are equal

writeRandomFile

public static boolean writeRandomFile(java.lang.String filePath,
                                      int size)
Writes a random int sequence of the required size to the file.

Parameters:
filePath -
size -
Returns:
true if successful

saveObjectsToFile

public static boolean saveObjectsToFile(java.lang.String filePath,
                                        java.util.Vector<java.lang.Object> objectsToSave)
                                 throws java.lang.Exception
Save objects into file for later use. Note that the objects have to be Java Beans!!

Parameters:
filePath - - full path of the file to which the objects are saved
objectsToSave - - a Vector containing the objects to save
Returns:
true if successful
Throws:
java.lang.Exception

loadObjectsFromFile

public static boolean loadObjectsFromFile(java.lang.String filePath,
                                          java.util.Vector<java.lang.Object> objectsToLoad)
Load the given objects from an existing file previously saved using the saveObjectsToFile method.

Parameters:
filePath - - the path to the file to load the objects from
objectsToLoad - - the Vector must be initialized with the correct dimensions and the correct type of the objects in the file.
Returns:
true if successful