planetj.common
Class CMUtility

java.lang.Object
  |
  +--planetj.common.BusinessObject
        |
        +--planetj.common.CMUtility
All Implemented Interfaces:
Invokeable, Serializable

public class CMUtility
extends BusinessObject

This type was created in VisualAge.

See Also:
Serialized Form

Field Summary
static Class[] EMPTY_CLASS_ARRAY
           
static Object[] EMPTY_OBJECT_ARRAY
           
 
Constructor Summary
CMUtility()
           
 
Method Summary
static Vector arrayToVector(Object[] array)
          Insert the method's description here.
static String backslashApostrophes(String s)
          Inserts a backslash before any apostrophes in the String
static int copy(File source, File destination)
          Copies a file or directory.
static int copy(String source, String destination)
          Copies a file or directory.
static boolean deleteFile(File pFile)
          Removes the specified file or directory, and all subdirectories
static boolean deleteFile(String pFilePath)
          Removes the specified file or directory, and all subdirectories
static long endSystemTimer()
          endSystemTimer method records the currentTimeMillis and computes the time elapsed since the call to startSystemTimer().
static boolean equals(Object o1, Object o2)
          Tests two Objects for equality
static boolean equalsIgnoreCase(String s1, String s2)
          Tests two Strings for equality, ignoring case
static BigDecimal getBigDecimal(int i)
          Gets an BigDecimal object for the specified int, possibly from a cache
static BigInteger getBigInteger(int i)
          Gets an BigInteger object for the specified int, possibly from a cache
static int getDifferenceInDays(Date from, Date to)
          Get the number of days between the two given dates (regardless of hours).
static Method getGetterMethod(Class c, MethodProperties mp)
          Gets the Method from the Class with the name specified in the MethodProperties object along with a String[] parameter containing all the Strings[] in the method properties object.
static int getHashCode(Object o)
          Gets an object's hashcode
static Integer getInteger(int i)
          Gets an Integer object for the specified int, possibly from a cache
static int getNumberOfDigits(int number)
          Get the number of digits for the given int.
static double getPercentage(Number val1, Number val2)
          Gets the percentage difference between the two numbers.
static Method getSetterMethod(Class c, MethodProperties mp)
          Gets the Method from the Class with the name specified in the MethodProperties object along with a String[] parameter containing all the Strings[] in the method properties object.
static String getString(int i)
          Gets a String representation for the given int, possibly from a cache.
static double getVariancePercentage(Number val1, Number val2)
          Gets the percentage difference between the two numbers.
static Object invokeMethod(Class targetObjectClass, String methodName, Class[] parameterTypes, Object[] params)
          Invokes the specified method via reflection.
static Object invokeMethod(Class targetObjectClass, String methodName, Object[] params)
          Invokes the specified method via reflection.
static Object invokeMethod(Object targetObject, Class targetObjectClass, String methodName, Class[] parameterTypes, Object[] parameters)
          Invokes the specified method via reflection.
static Object invokeMethod(Object targetObject, Class targetObjectClass, String methodName, Object[] params)
          Invokes the specified method via reflection.
static String ipAddressToString(byte[] ipAddress)
          Converts an IP address into a String
static boolean isBeginsWith(String mainString, String startingString)
          Tests if the first String begins with the second one
static boolean isRunningInDevelopment()
          Deprecated. - Replaced by CMUtility.isRunningInVA()
static boolean isRunningInTomcat()
          Test if this java program is running in Visual Age
static boolean isRunningInVA()
          Test if this java program is running in Visual Age
static boolean isRunningInWAS()
          If we are running in WAS or not
static boolean isRunningInWASExpress()
          If we are running in WAS Express or not
static boolean isRunningInWindows()
          Test if this java program is running on a Windows system
static boolean isRunningInWSSDExpress()
          If we are running in Studio Site Developer or not
static boolean isStringContainNumeric(String value)
          Returns true if the any char in the String is numeric
static boolean isStringNumeric(String value)
          Test if the given String contains all digits/numbers.
static StringBuffer mergeStrings(StringBuffer pBuffer, String pString)
          This will merge pString into pBuffer
static int moveElementDownOne(List l, int index)
          Takes a ltor and the index and moves the element up one position
static int moveElementUpOne(List l, int index)
          Takes a ltor and the index and moves the element up one position
static MethodProperties parseMethod(String method)
          Takes the given String representing a Method, parses it into its method name and parameters, and then stores them in a MethodProperties object which can later be used to retrieve the different parts.
static void runClientSideApplication(String path)
          executes the given path and file EXAMPLE Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe c:\\jmagic\\cave.htm");
static void startSystemTimer()
          startSystemTime method records the currentTimeMillis of the system to be used for later calculation.
static String stripOffAllNonNumericCharacters(String alphaChars)
          stripOffAllNonNumericCharacters() will return a string of all intergers and strip off all values that are non-numeric
static int sum(int[] numbers)
          Sums up an array of integers
static List toList(Enumeration e)
          Adds all elements in the Enumeration to a new List
static List toList(Iterator i)
          Adds all elements in the Iterator to a new List
static List toUpperCase(List l)
          Uppercases a List of String objects.
static List trim(List pStrings)
          Trims a List of Strings
static String trim(String inpString)
          trim String object and ensure nulls are not returned
static List trimNulls(List pList)
          Removes all null references from the end of the List
static String trimTo(String string, int x)
          trim String object to x characters in length and ensure nulls are not returned
static String trimTrailing(String pString)
          Returns a String with all trailing white spaces removed.
static boolean validateAS400Name(String name)
          Test the name String for AS400 naming compliance
 
Methods inherited from class planetj.common.BusinessObject
generateException, generateException, generateException, generateException, generateException, getTranslation, invoke, toBoolean, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CLASS_ARRAY

public static final Class[] EMPTY_CLASS_ARRAY

EMPTY_OBJECT_ARRAY

public static final Object[] EMPTY_OBJECT_ARRAY
Constructor Detail

CMUtility

public CMUtility()
Method Detail

arrayToVector

public static Vector arrayToVector(Object[] array)
Insert the method's description here. Creation date: (9/24/00 3:07:12 PM)

Parameters:
array - java.lang.Object[]
Returns:
java.util.Vector

backslashApostrophes

public static final String backslashApostrophes(String s)
Inserts a backslash before any apostrophes in the String


copy

public static int copy(File source,
                       File destination)
                throws IOException
Copies a file or directory. Existing files are overwritten without warning.

Parameters:
source - The file or directory to copy. If this is a directory, then the directory itself (and not just the directory's contents) will be copied
destination - The directory to copy to. This directory must exist already.
Returns:
The total number of files (not including directories) that were copied
IOException

copy

public static int copy(String source,
                       String destination)
                throws IOException
Copies a file or directory. Existing files are overwritten without warning.

Parameters:
source - The file or directory to copy
destination - The directory to copy to. This directory must exist already.
Returns:
The total number of files (not including directories) that were copied
IOException

deleteFile

public static boolean deleteFile(File pFile)
Removes the specified file or directory, and all subdirectories

Parameters:
pFile - The file or directory that you wish to delete

deleteFile

public static boolean deleteFile(String pFilePath)
Removes the specified file or directory, and all subdirectories

Parameters:
pFilePath - The Absolute Path to a file or directory that you wish to delete

endSystemTimer

public static final long endSystemTimer()
endSystemTimer method records the currentTimeMillis and computes the time elapsed since the call to startSystemTimer(). A return value of -1 is given if no time has elapsed or no call to startSystemTimer has been made.

Returns:
long
See Also:
startSystemTimer

equals

public static final boolean equals(Object o1,
                                   Object o2)
Tests two Objects for equality


equalsIgnoreCase

public static final boolean equalsIgnoreCase(String s1,
                                             String s2)
Tests two Strings for equality, ignoring case


getBigDecimal

public static final BigDecimal getBigDecimal(int i)
Gets an BigDecimal object for the specified int, possibly from a cache


getDifferenceInDays

public static final int getDifferenceInDays(Date from,
                                            Date to)
Get the number of days between the two given dates (regardless of hours). If the from date is greater than the to date, a negative number will be returned.


getBigInteger

public static final BigInteger getBigInteger(int i)
Gets an BigInteger object for the specified int, possibly from a cache


getGetterMethod

public static Method getGetterMethod(Class c,
                                     MethodProperties mp)
                              throws NoSuchMethodException
Gets the Method from the Class with the name specified in the MethodProperties object along with a String[] parameter containing all the Strings[] in the method properties object.

Note: this method is only used for retrieving methods with a String[] paramter.

Parameters:
c - Class
mp - MethodProperties
Returns:
Method
NoSuchMethodException

getHashCode

public static final int getHashCode(Object o)
Gets an object's hashcode


getInteger

public static final Integer getInteger(int i)
Gets an Integer object for the specified int, possibly from a cache


getNumberOfDigits

public static int getNumberOfDigits(int number)
Get the number of digits for the given int.


getPercentage

public static double getPercentage(Number val1,
                                   Number val2)
Gets the percentage difference between the two numbers. For example... getPercentage(1, 2) = .5


getSetterMethod

public static Method getSetterMethod(Class c,
                                     MethodProperties mp)
                              throws NoSuchMethodException
Gets the Method from the Class with the name specified in the MethodProperties object along with a String[] parameter containing all the Strings[] in the method properties object.

Note: this method is only used for retrieving methods with a String[] paramter.

Parameters:
c - Class
mp - MethodProperties
Returns:
Method
NoSuchMethodException

getString

public static final String getString(int i)
Gets a String representation for the given int, possibly from a cache.


getVariancePercentage

public static double getVariancePercentage(Number val1,
                                           Number val2)
Gets the percentage difference between the two numbers. Checks to see how much different the first value is from the second. e.g. val1 = 50 and val2 = 10, then the percentage returned is 500.


invokeMethod

public static final Object invokeMethod(Class targetObjectClass,
                                        String methodName,
                                        Class[] parameterTypes,
                                        Object[] params)
                                 throws Exception
Invokes the specified method via reflection. You must provide the fully qualified class name, as well as the parameters for the method. This method assumes that the method you are trying to invoke is a static method. Creation date: (1/27/2003 10:42:56 AM)

Parameters:
targetObjectClass - java.lang.Class
methodName - java.lang.String
parameterTypes - java.Class[]
params - java.util.Object[]
Returns:
java.lang.Object
Exception

invokeMethod

public static final Object invokeMethod(Class targetObjectClass,
                                        String methodName,
                                        Object[] params)
                                 throws Exception
Invokes the specified method via reflection. You must provide the fully qualified class name, as well as the parameters for the method. This method assumes that the method you are trying to invoke is a static method. Creation date: (1/27/2003 10:42:56 AM)

Parameters:
targetObjectClass - java.lang.Class
methodName - java.lang.String
params - java.util.Object[]
Returns:
java.lang.Object
Exception

invokeMethod

public static final Object invokeMethod(Object targetObject,
                                        Class targetObjectClass,
                                        String methodName,
                                        Class[] parameterTypes,
                                        Object[] parameters)
                                 throws Exception
Invokes the specified method via reflection. You must provide the fully qualified class name, as well as the parameters for the method. Creation date: (1/27/2003 10:42:56 AM)

Parameters:
targetObject - java.lang.Object The object the underlying method is invoked from. If the underlying method is static, then pass null
targetObjectClass - java.lang.String
methodName - java.lang.String
parameterTypes - java.lang.Class[]
Returns:
java.lang.Object
Exception

invokeMethod

public static final Object invokeMethod(Object targetObject,
                                        Class targetObjectClass,
                                        String methodName,
                                        Object[] params)
                                 throws Exception
Invokes the specified method via reflection. Does not require the Class array argument, so they class types for the arguments will be assumed to be the same as the arguments Creation date: (1/27/2003 10:42:56 AM)

Parameters:
targetObject - java.lang.Object
targetObjectClass - java.lang.Class
methodName - java.lang.String
params - java.util.Object[]
Returns:
java.lang.Object
Exception

ipAddressToString

public static final String ipAddressToString(byte[] ipAddress)
Converts an IP address into a String


isBeginsWith

public static final boolean isBeginsWith(String mainString,
                                         String startingString)
Tests if the first String begins with the second one


isRunningInDevelopment

public static final boolean isRunningInDevelopment()
Deprecated. - Replaced by CMUtility.isRunningInVA()

Test if this java program is running in the developement environment


isRunningInTomcat

public static final boolean isRunningInTomcat()
Test if this java program is running in Visual Age


isRunningInVA

public static final boolean isRunningInVA()
Test if this java program is running in Visual Age


isRunningInWAS

public static final boolean isRunningInWAS()
If we are running in WAS or not


isRunningInWASExpress

public static final boolean isRunningInWASExpress()
If we are running in WAS Express or not


isRunningInWindows

public static final boolean isRunningInWindows()
Test if this java program is running on a Windows system


isRunningInWSSDExpress

public static final boolean isRunningInWSSDExpress()
If we are running in Studio Site Developer or not


isStringContainNumeric

public static boolean isStringContainNumeric(String value)
Returns true if the any char in the String is numeric

Returns:
boolean

isStringNumeric

public static boolean isStringNumeric(String value)
Test if the given String contains all digits/numbers.

Returns:
true if the given string is all digits/numbers.

mergeStrings

public static final StringBuffer mergeStrings(StringBuffer pBuffer,
                                              String pString)
This will merge pString into pBuffer

Example: pBuffer.toString() = I the in hat pString = love cat the . Return value of pBuffer = I love the cat in the hat.

The text in the StringBuffer pBuffer will never be overriden by pString unless the value for that char is a blank ' '. Example: pBuffer.toString() = I love the in hat pString = hate cat the . Return value of pBuffer = I love the cat in the hat.

Creation date: (7/30/2002 3:08:17 PM)


moveElementDownOne

public static final int moveElementDownOne(List l,
                                           int index)
Takes a ltor and the index and moves the element up one position


moveElementUpOne

public static final int moveElementUpOne(List l,
                                         int index)
Takes a ltor and the index and moves the element up one position


parseMethod

public static MethodProperties parseMethod(String method)
Takes the given String representing a Method, parses it into its method name and parameters, and then stores them in a MethodProperties object which can later be used to retrieve the different parts.

Parameters:
method - String
Returns:
MethodProperties
See Also:
MethodProperties

runClientSideApplication

public static void runClientSideApplication(String path)
                                     throws Exception
executes the given path and file EXAMPLE Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe c:\\jmagic\\cave.htm");

Exception

startSystemTimer

public static final void startSystemTimer()
startSystemTime method records the currentTimeMillis of the system to be used for later calculation.


stripOffAllNonNumericCharacters

public static final String stripOffAllNonNumericCharacters(String alphaChars)
stripOffAllNonNumericCharacters() will return a string of all intergers and strip off all values that are non-numeric


sum

public static final int sum(int[] numbers)
Sums up an array of integers


toList

public static List toList(Enumeration e)
Adds all elements in the Enumeration to a new List


toList

public static List toList(Iterator i)
Adds all elements in the Iterator to a new List


toUpperCase

public static List toUpperCase(List l)
Uppercases a List of String objects. All the objects in the List must be Strings; they will be replaced with uppercase String objects. The same List is returned.


trim

public static final List trim(List pStrings)
Trims a List of Strings


trim

public static final String trim(String inpString)
trim String object and ensure nulls are not returned


trimNulls

public static final List trimNulls(List pList)
Removes all null references from the end of the List


trimTo

public static final String trimTo(String string,
                                  int x)
trim String object to x characters in length and ensure nulls are not returned


trimTrailing

public static final String trimTrailing(String pString)
Returns a String with all trailing white spaces removed. Example if a String "Tyler is cool. " comes in at pString, the string "Tyler is cool." will be returned. The 3 spaces at the end will be removed. Unlike String.trim() no leading spaces will be trimmed off. Example if a String " Tyler's a hunk." comes in at pString The exact string " Tyler's a hunk." will be returned. Creation date: (4/17/2002 1:27:08 PM)


validateAS400Name

public static final boolean validateAS400Name(String name)
Test the name String for AS400 naming compliance

Returns:
a boolean that indicates if naming conventions are followed correctly.