com.extrememessaging.ResponseMaster
Class CHelper

java.lang.Object
  extended bycom.extrememessaging.ResponseMaster.CHelper

public class CHelper
extends java.lang.Object

Some helper functions that are useful in many places in ResponseMaster and may be useful to others working on response handling


Constructor Summary
CHelper()
           
 
Method Summary
static char decodeEscapedSequenceForHTML(java.lang.String sEscapeSequence)
          Decode an HTML escaped sequence to a character.
static java.lang.String DecodeMimeText(java.lang.String input)
          Decodes mime text, eg =?utf-8?B?5a+m6Zqb44SJ6KiI55WrLnppcA==?=
static java.lang.String decryptPassword(java.lang.String sInput)
          Decrypts the string if it is encrypted, otherwise, just gives it back
static java.lang.String getAddress(javax.mail.Address address)
          Gets the address (not the display name) from an Address object
static java.lang.String getAddressWithName(javax.mail.Address address)
          Gets the display name and address from an Address object
static int getEOLIndex(java.lang.String sInput, int nIndex)
          Used to find the index of the end of the line containing an index.
static byte[] getFromHex(java.lang.String input)
           
static java.lang.String getHex(byte[] ba)
           
static java.lang.String GetPlainMimeType(java.lang.String input)
          Turns something like application/pdf; name="fax-072508-1249.pdf" into application/pdf
static java.lang.String getStackDump(java.lang.Throwable input)
          Gets a string containing the stack dump from an exception or error
static java.lang.String getTokenAtPosition(java.lang.String sInput, int nIndex)
          Gets the word at a location, treating < and > and " and : as whitespace
static java.lang.String HandleRelativeConfigFileName(java.lang.String sContainingFileName, java.lang.String sChildFileName)
          Returns a filename suitable for use by the operating system given the filename that refers to the file, and the file that is referred to.
static java.lang.String NullToEmptyString(java.lang.String input)
           
static byte[] ReadToEnd(java.io.InputStream is)
           
static java.lang.String replaceString(java.lang.String sInput, java.lang.String sSearchFor, java.lang.String sNewString, boolean bIgnoreCase)
          Replaces all instances of sSearchFor in sInput with sNewString
static void Sleep(int milliseconds)
          Sleeps the specified number of milliseconds without throwing an exception
static java.lang.String StripCharacters(java.lang.String sInput, char[] charactersToStrip)
          Strips the whitespace from a string
static java.lang.String StripWhitespace(java.lang.String sInput)
          Strips the whitespace from a string
static java.lang.String StripWhitespaceForRules(java.lang.String sInput)
          Strips the whitespace from a string and some other special characters (eg underscores)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CHelper

public CHelper()
Method Detail

Sleep

public static void Sleep(int milliseconds)
Sleeps the specified number of milliseconds without throwing an exception


replaceString

public static java.lang.String replaceString(java.lang.String sInput,
                                             java.lang.String sSearchFor,
                                             java.lang.String sNewString,
                                             boolean bIgnoreCase)
Replaces all instances of sSearchFor in sInput with sNewString

Parameters:
sInput - The original string
sSearchFor - The string to search for
sNewString - The string to replace it with
bIgnoreCase - True if you want to ignore case when searching for sSearchFor
Returns:
The new string

decodeEscapedSequenceForHTML

public static char decodeEscapedSequenceForHTML(java.lang.String sEscapeSequence)
                                         throws ResponseMasterDecodingException
Decode an HTML escaped sequence to a character.

Parameters:
sEscapeSequence - The string to decode (e.g. 'lt'). It does not include the & or the semicolon.
Returns:
The decoded character. '?' if it could not be decoded.
Throws:
Throws - a ResponseMasterDecodingException if there is a probelm
ResponseMasterDecodingException

decryptPassword

public static java.lang.String decryptPassword(java.lang.String sInput)
Decrypts the string if it is encrypted, otherwise, just gives it back


getTokenAtPosition

public static java.lang.String getTokenAtPosition(java.lang.String sInput,
                                                  int nIndex)
Gets the word at a location, treating < and > and " and : as whitespace

Parameters:
sInput - The string to get the token from
nIndex - A position that is in the token or in whitespace before the token
Returns:
The token found at that position

getEOLIndex

public static int getEOLIndex(java.lang.String sInput,
                              int nIndex)
Used to find the index of the end of the line containing an index. Both \n and \r\n are considered to be the end of the line.

Parameters:
sInput - The big string
nIndex - The index of a character in the line that you want the end of
Returns:
The last non-CRLF character in the line. If it is the last line, the function returns the index of the last character in the file.

getStackDump

public static java.lang.String getStackDump(java.lang.Throwable input)
Gets a string containing the stack dump from an exception or error


getAddress

public static java.lang.String getAddress(javax.mail.Address address)
Gets the address (not the display name) from an Address object


getAddressWithName

public static java.lang.String getAddressWithName(javax.mail.Address address)
Gets the display name and address from an Address object


NullToEmptyString

public static java.lang.String NullToEmptyString(java.lang.String input)

StripWhitespace

public static java.lang.String StripWhitespace(java.lang.String sInput)
Strips the whitespace from a string


StripWhitespaceForRules

public static java.lang.String StripWhitespaceForRules(java.lang.String sInput)
Strips the whitespace from a string and some other special characters (eg underscores)


StripCharacters

public static java.lang.String StripCharacters(java.lang.String sInput,
                                               char[] charactersToStrip)
Strips the whitespace from a string


DecodeMimeText

public static java.lang.String DecodeMimeText(java.lang.String input)
Decodes mime text, eg =?utf-8?B?5a+m6Zqb44SJ6KiI55WrLnppcA==?=


HandleRelativeConfigFileName

public static java.lang.String HandleRelativeConfigFileName(java.lang.String sContainingFileName,
                                                            java.lang.String sChildFileName)
Returns a filename suitable for use by the operating system given the filename that refers to the file, and the file that is referred to. We suppport paths like "+/catRules/ExchangeBadRecipient.xml" to mean starting from the folder that contains the referring file, the file called "ExchangeBadRecipient.xml" in the catRules subdirectory. In short, "+" is like ".", except "+" means relative from the referring file, and "." means relative to the working directory.


getHex

public static java.lang.String getHex(byte[] ba)

getFromHex

public static byte[] getFromHex(java.lang.String input)
                         throws ResponseMasterException
Throws:
ResponseMasterException

ReadToEnd

public static byte[] ReadToEnd(java.io.InputStream is)
                        throws java.io.IOException
Throws:
java.io.IOException

GetPlainMimeType

public static java.lang.String GetPlainMimeType(java.lang.String input)
Turns something like application/pdf; name="fax-072508-1249.pdf" into application/pdf