com.ibm.dse.tools.workbench.base
Class WorkbenchUtilities

java.lang.Object
  |
  +--com.ibm.dse.tools.workbench.base.WorkbenchUtilities

public class WorkbenchUtilities
extends java.lang.Object

This class provides some utilities to the Workbench


Field Summary
protected static long counter
          Counter for the current VM
static int counterDigits
          Number of digits for the counter
protected static java.lang.String encryptionAlgorithm
          Default encryption algorithm
static boolean includeIP
          Should include the IP computer address
static boolean includeTime
          Should include the time
protected static java.security.MessageDigest messageDigest
          Message Digest to make the code secure
static int randomDigits
          Number of digits for the random number
protected static java.lang.String UNKNOW_IP
          Default IP computer address, if can't get one
 
Constructor Summary
WorkbenchUtilities()
          Constructs a WorkbenchUtility Object
 
Method Summary
static java.lang.String getHexLocalHost()
          This method returns the local host IP address in hexadecimal and without separators.
static java.lang.String getHexRandom(int digits)
          This method returns a random number of digits length.
static java.lang.String getSecureUniqueCode()
          This method returns an unique code.
static java.lang.String getSecureUniqueCode(java.lang.String userString)
          This method returns an unique code.
static java.sql.Timestamp getTimestamp()
          This method returns the current timestamp
static java.lang.String getUniqueCode()
          This method returns an unique code.
static java.lang.String getUniqueCode(java.lang.String userString)
          This method returns an unique code and appends it a String provided by the user
static java.lang.String lpad(java.lang.String text, int columns, char ch)
          This method aligns a string to the left with columns size and ch chars.
static java.lang.String replace(java.lang.String text, java.lang.String key, java.lang.String value)
          This method replace all the occurrences of the key by the specified value
static java.lang.String rpad(java.lang.String text, int columns, char ch)
          This method aligns a string to the right with columns size and ch chars.
protected static void setCounterDigits(int counterDig)
          Sets the number of digits for the counter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

includeIP

public static boolean includeIP
Should include the IP computer address

includeTime

public static boolean includeTime
Should include the time

counterDigits

public static int counterDigits
Number of digits for the counter

randomDigits

public static int randomDigits
Number of digits for the random number

counter

protected static long counter
Counter for the current VM

UNKNOW_IP

protected static java.lang.String UNKNOW_IP
Default IP computer address, if can't get one

messageDigest

protected static java.security.MessageDigest messageDigest
Message Digest to make the code secure

encryptionAlgorithm

protected static java.lang.String encryptionAlgorithm
Default encryption algorithm
Constructor Detail

WorkbenchUtilities

public WorkbenchUtilities()
Constructs a WorkbenchUtility Object
Method Detail

getHexLocalHost

public static java.lang.String getHexLocalHost()
This method returns the local host IP address in hexadecimal and without separators.
Returns:
java.lang.String the IP address in hexadecimal

getHexRandom

public static java.lang.String getHexRandom(int digits)
This method returns a random number of digits length.
Parameters:
digits - int the number of digits
Returns:
java.lang.String

getSecureUniqueCode

public static java.lang.String getSecureUniqueCode()
This method returns an unique code.
Returns:
java.lang.String The secure unique code

getSecureUniqueCode

public static java.lang.String getSecureUniqueCode(java.lang.String userString)
This method returns an unique code.
Parameters:
userString - java.lang.String
Returns:
java.lang.String the secure unique code

getTimestamp

public static java.sql.Timestamp getTimestamp()
This method returns the current timestamp
Returns:
java.sql.Timestamp the timestamp

getUniqueCode

public static java.lang.String getUniqueCode()
This method returns an unique code.
Returns:
java.lang.String The unique code

getUniqueCode

public static java.lang.String getUniqueCode(java.lang.String userString)
This method returns an unique code and appends it a String provided by the user
Parameters:
userString - java.lang.String The String provided by the user to be added to the generated code
Returns:
java.lang.String The unique code

lpad

public static java.lang.String lpad(java.lang.String text,
                                    int columns,
                                    char ch)
This method aligns a string to the left with columns size and ch chars.
Parameters:
text - java.lang.String the String to be aligned
columns - int the number of columns
ch - char the char used to align
Returns:
java.lang.String the aligned String

replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String key,
                                       java.lang.String value)
This method replace all the occurrences of the key by the specified value
Parameters:
text - java.lang.String The String to be processed
key - java.lang.String The key to be replaced
value - java.lang.String The value to replace the key
Returns:
java.lang.String The processed String

rpad

public static java.lang.String rpad(java.lang.String text,
                                    int columns,
                                    char ch)
This method aligns a string to the right with columns size and ch chars.
Parameters:
text - java.lang.String The String to be aligned
columns - int The number of columns
ch - char The char user to align
Returns:
java.lang.String The aligned String

setCounterDigits

protected static void setCounterDigits(int counterDig)
Sets the number of digits for the counter.
Parameters:
counterDig - int The number of digits used by the counter