Task.Support.CoreSupport
Class Utils

java.lang.Object
  extended by Task.Support.CoreSupport.Utils

public class Utils
extends java.lang.Object

Utils is a static function library to do mundane and repetitive, yet important functions that are used everywhere in the system.

Since:
2/26/2000,3:08pm
Version:
1.0
Author:
Nazmul Idris

Method Summary
static java.lang.String arrayToString(java.lang.Object[] args)
           
static java.lang.String buildUri(java.lang.String uri, java.util.HashMap<java.lang.String,java.lang.String> map)
           
static java.lang.String concatenateFilePath(java.lang.String path1, java.lang.String path2)
           
static
<Type extends java.io.Serializable>
Type
copyObject(Type copythis)
          copies the object and returns it
static
<ClassType>
void
createInEDT(java.lang.Class<ClassType> aClass)
          given a class, it creates an instance of it in the EDT
static ByteBuffer fileToByteBuffer(java.lang.String fileName)
          this method reads a file and returns a ByteBuffer of the contents of this file.
static ByteBuffer fileToByteBuffer(java.lang.String fileName, java.util.Map<java.lang.String,ByteBuffer> fileCache)
          this method reads a file and returns it as a ByteBuffer, but it uses a Map for a fileCache
static byte[] fileToBytes(java.lang.String fileName)
          this method reads a file and returns a byte[] of the contents of this file.
static byte[] fileToBytes(java.lang.String fileName, java.util.Map<java.lang.String,ByteBuffer> fileCache)
          this method reads a file and returns it as a byte array, but it uses a Map for a fileCache
static java.lang.String getCallerClassName()
           
static java.lang.String getCallerMethodName()
           
static java.lang.String getClassNameFromStackTrace(int depth)
           
static java.lang.String getDebugHeaderString(java.lang.String msg)
           
static java.lang.Object[] getObjectRay(java.lang.Object... args)
           
static java.lang.String getString(java.util.Map m, java.lang.Object key)
          this method does away with a NullPointerException that might get thrown (incorrectly semantically speaking) when the following call is made: (String)Map.get("nonexistentkey");.
static java.lang.String getTime()
          this method returns the current time in
static java.lang.String[] getTokens(java.lang.String s, java.lang.String delim)
          this is just a convenience method to tokenize a string using the services of TheStringTokenizer class.
static boolean isDifferent(java.lang.Object lhs, java.lang.Object rhs)
          checks to see if lhs and rhs objects are the same or not
static boolean isNullOrEmpty(java.lang.String string)
           
static
<T> boolean
isObjectInArray(T item, T[] list)
           
static
<T> boolean
isObjectInList(T item, java.util.List<T> list)
           
static boolean isStringInList(java.lang.String item, java.util.List<java.lang.String> list)
           
static java.lang.String listOfLogRecordToString(java.util.List<java.util.logging.LogRecord> list)
          Turns a list of LogRecord objects into a string for debug purposes
static java.lang.String listToString(java.util.List list)
           
static java.lang.String mapToString(java.util.Map map)
           
static void printDebugHeaderToConsole(java.lang.String msg)
           
static java.util.ArrayList<java.lang.String> toArrayListFromObjectRay(java.lang.Object[] objRay)
           
static void writeToFile(byte[] msg, java.lang.String file)
           
static void writeToFile(ByteBuffer msg, java.lang.String file)
           
static void writeToFile(java.lang.String msg, java.lang.String file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

buildUri

public static final java.lang.String buildUri(java.lang.String uri,
                                              java.util.HashMap<java.lang.String,java.lang.String> map)
                                       throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

isNullOrEmpty

public static boolean isNullOrEmpty(java.lang.String string)

printDebugHeaderToConsole

public static void printDebugHeaderToConsole(java.lang.String msg)

getDebugHeaderString

public static java.lang.String getDebugHeaderString(java.lang.String msg)

getObjectRay

public static java.lang.Object[] getObjectRay(java.lang.Object... args)

listOfLogRecordToString

public static java.lang.String listOfLogRecordToString(java.util.List<java.util.logging.LogRecord> list)
Turns a list of LogRecord objects into a string for debug purposes


mapToString

public static java.lang.String mapToString(java.util.Map map)

listToString

public static java.lang.String listToString(java.util.List list)

arrayToString

public static java.lang.String arrayToString(java.lang.Object[] args)

isStringInList

public static boolean isStringInList(java.lang.String item,
                                     java.util.List<java.lang.String> list)

isObjectInList

public static <T> boolean isObjectInList(T item,
                                         java.util.List<T> list)

isObjectInArray

public static <T> boolean isObjectInArray(T item,
                                          T[] list)

getCallerMethodName

public static java.lang.String getCallerMethodName()

getCallerClassName

public static java.lang.String getCallerClassName()

getClassNameFromStackTrace

public static java.lang.String getClassNameFromStackTrace(int depth)

toArrayListFromObjectRay

public static java.util.ArrayList<java.lang.String> toArrayListFromObjectRay(java.lang.Object[] objRay)

getTime

public static java.lang.String getTime()
this method returns the current time in


fileToByteBuffer

public static ByteBuffer fileToByteBuffer(java.lang.String fileName)
this method reads a file and returns a ByteBuffer of the contents of this file.


fileToBytes

public static byte[] fileToBytes(java.lang.String fileName)
this method reads a file and returns a byte[] of the contents of this file.


fileToBytes

public static byte[] fileToBytes(java.lang.String fileName,
                                 java.util.Map<java.lang.String,ByteBuffer> fileCache)
this method reads a file and returns it as a byte array, but it uses a Map for a fileCache


fileToByteBuffer

public static ByteBuffer fileToByteBuffer(java.lang.String fileName,
                                          java.util.Map<java.lang.String,ByteBuffer> fileCache)
this method reads a file and returns it as a ByteBuffer, but it uses a Map for a fileCache


getString

public static java.lang.String getString(java.util.Map m,
                                         java.lang.Object key)
this method does away with a NullPointerException that might get thrown (incorrectly semantically speaking) when the following call is made: (String)Map.get("nonexistentkey");. The NullPointerException gets thrown because you can't typecast NULL. So the code simply checks to see if get(key) returns a null; and if it does, merely returns null; else returns the String representation of the object.s


getTokens

public static java.lang.String[] getTokens(java.lang.String s,
                                           java.lang.String delim)
this is just a convenience method to tokenize a string using the services of TheStringTokenizer class.


writeToFile

public static void writeToFile(java.lang.String msg,
                               java.lang.String file)

writeToFile

public static void writeToFile(byte[] msg,
                               java.lang.String file)

writeToFile

public static void writeToFile(ByteBuffer msg,
                               java.lang.String file)

concatenateFilePath

public static java.lang.String concatenateFilePath(java.lang.String path1,
                                                   java.lang.String path2)

isDifferent

public static boolean isDifferent(java.lang.Object lhs,
                                  java.lang.Object rhs)
checks to see if lhs and rhs objects are the same or not

Parameters:
lhs - this might be null
rhs - this might be null

copyObject

public static <Type extends java.io.Serializable> Type copyObject(Type copythis)
copies the object and returns it

Parameters:
copythis - this is the object to copy
Returns:
this is null if the object can't be copied for some reason

createInEDT

public static <ClassType> void createInEDT(java.lang.Class<ClassType> aClass)
given a class, it creates an instance of it in the EDT



Copyright © 2011. All Rights Reserved.