com.pega.pegarules.pub.util
Class StringUtils

java.lang.Object
  extended by com.pega.pegarules.pub.util.StringUtils

public class StringUtils
extends java.lang.Object

Static methods for manipulating Strings.

Version:
$Revision: 28650 $ $Date: 2012-06-02 22:20:55 -0400 (Sat, 02 Jun 2012) $
Author:
David Burns

Field Summary
static int ASIS
          Constant for "concat" methods, leave string in original case
static java.lang.String COPYRIGHT
           
static int LOWERCASE
          Constant for "concat" methods, convert string to lower case
static int UPPERCASE
          Constant for "concat" methods, convert string to upper case
static java.lang.String VERSION
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
static java.lang.String center(java.lang.String in, int length)
          center a string in a given length
static boolean compareStringsHandleNulls(java.lang.String lhs, java.lang.String rhs)
           
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5, java.lang.Object arg6)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5, java.lang.Object arg6, java.lang.Object arg7)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5, java.lang.Object arg6, java.lang.Object arg7, java.lang.Object arg8)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5, java.lang.Object arg6, java.lang.Object arg7, java.lang.Object arg8, java.lang.Object arg9)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String concat(int aCase, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5, java.lang.Object arg6, java.lang.Object arg7, java.lang.Object arg8, java.lang.Object arg9, java.lang.Object arg10)
          Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.
static java.lang.String crossScriptingFilter(java.lang.String aBuf)
          Converts the special characters into html entities for the given string
static java.lang.String decodeURL(java.lang.String s)
          Decodes a application/x-www-form-urlencoded string using the UTF-8 encoding scheme.
static java.lang.String encodeURL(java.lang.String strParameterValue)
          Translates a string into application/x-www-form-urlencoded format using the UTF-8 encoding scheme.
static java.lang.String escapeCrossScriptingFilter(java.lang.String aBuf)
          Converts the special characters into html entities also appends escape character for single quote and double quote for the given string
static java.lang.String escapeForExpression(java.lang.String value)
           
static java.lang.String escapeIntoJavaString(java.lang.String aInput)
          Given an input string, convert it into something we could embed in Java source.
static java.lang.String escapeIntoJSONString(java.lang.String aInput)
          Given an input string, convert it into a valid JSON string.
static java.lang.String filterRichText(java.lang.String html)
           
static java.lang.String fitRight(java.lang.String in, int length)
          Fit a string to specified length padding the right or truncating as necessary.
static java.lang.String fitRight(java.lang.String in, int length, char padChar)
          Fit a string to specified length padding the right or truncating as necessary.
static byte[] fromHexString(java.lang.String in)
          Convert string of hex to a byte array
static java.lang.String fromPackedDecimal(byte[] packedDecimal)
          Convert a byte array encoded as packed decimal data(COMP-3) to the string equivalent.
static java.lang.String fromPackedDecimal(byte[] packedDecimal, int decimals)
          Convert a byte array encoded as packed decimal data(COMP-3) to the string equivalent.
static java.lang.String fromZonedDecimal(byte[] zonedDecimal, int decimals)
          Convert a byte array encoded as zoned decimal data(DISPLAY) to the string equivalent.
static java.lang.String getPackageQualifier(ClassDefinition aClass)
           
static int indexOf(char[] aSource, int aSourceStart, int aSourceLength, java.lang.String aToBeFound)
          Locate a substring within a character array
static int indexOf(java.lang.StringBuffer s, char c, int p)
          String.indexOf - like function that works with StringBuffers and works in jdk 1.3.x
static int indexOfEsc(java.lang.StringBuffer s, char c, int p)
          String.indexOf - like function that respects back-slash escaping of the searched-for character and works in jdk 1.3.x with StringBuffers
static int indexOfEsc(java.lang.String s, char c, int p)
          String.indexOf - like function that respects back-slash escaping of the searched-for character
static void insertInteger(java.lang.StringBuffer aTarget, int aAtPosition, int aIntValue)
           
static boolean interpretBoolean(java.lang.String aOpt)
          Interprets a String value as a boolean, satisfying javascript and generic conventions.
static boolean isBlank(java.lang.String aString)
          Returns true iff the string is non-null and has size greated than zero.
static java.lang.String packString(java.lang.String input)
          Convert escape sequences to individual characters.
static java.lang.String padLeft(java.lang.String in, int length)
          Pad a string on the left with spaces until it has length specified.
static java.lang.String padLeft(java.lang.String in, int length, char padChar)
          Pad a string on left with specified pad character so it has specified length.
static java.lang.String padRight(java.lang.String in, int length)
          Pad a string on the right with spaces until it has length specified.
static java.lang.String padRight(java.lang.String in, int length, char padChar)
          Pad a string on right with specified pad character so it has specified length.
static char[] pageNameClean(char[] in)
          Changes invalid pageName characters to the under-bar char.
static char[] pageNameClean(java.lang.String in)
           
static int parseInt(int radix, java.lang.String s, int start, int end)
          Similar to String.parseInt(String s, int radix) but allows specification of the segment of the string that should be parsed.
static java.util.Map parseQueryString(java.lang.String aQS)
          Parse a query string, creating a map of name=value pairs
26-Nov-02 olsok -- substituting algorithm from Tomcat 4.0.4 to more correctly deal with %hh escapes and character set encodings.
static void parseURLParameters(java.util.Map map, byte[] data, int useLen, java.lang.String encoding)
          26-Nov-02 OLSOK -- adapted parseParameters from Tomcat 4.0.4 and merged with PegaRULES heuristics (dealing with '&' entities in query strings) in order to get internationalization logic correct and plausible...
static void parseURLParameters(java.util.Map map, byte[] data, java.lang.String encoding)
          parse the full byte array as a URL-encoded string
static void parseURLParameters(java.util.Map map, java.lang.String data, java.lang.String encoding)
          Append request parameters from the specified String to the specified Map.
static java.lang.String quote(java.lang.String inputStr)
           
static java.lang.String quoteAndEscape(java.lang.String aOriginalString)
          This method will completely quote a string, converting existing double quotes to single quotes if necessary.
static java.lang.StringBuffer replace(java.lang.StringBuffer buf, char oldChar, char newChar)
          Similar to String.replace(oldChar, newChar) but operates on StringBuffer
static java.lang.String replaceAll(java.lang.String aBaseString, java.lang.String aOriginalChars, java.lang.String aNewChars)
          Method replaceAll replaces the specified string..
static java.lang.String replaceAll(java.lang.String aBaseString, java.lang.String aOriginalChars, java.lang.String aNewChars, boolean aReplaceAssign)
          Method replaceAll replaces the specified string..
static java.lang.String restoreFilteredString(java.lang.String aBuf)
          restore a cross site scripting filtered string to its original form
static java.lang.String reversibleCrossScriptingFilter(java.lang.String aBuf)
          filter a string for cross site scripting characters and add a prefix to allow for filtering to be reversed
static boolean startsWith(java.lang.CharSequence aSequenceToCheck, java.lang.String aLookingFor)
           
static java.lang.String stripQuotes(java.lang.String aString)
          Strip quotes from the specified string.
static java.lang.String toHexString(byte[] in)
          Convert byte array to a string of hex.
static java.lang.String toLowerCase(java.util.Locale aLocale, java.lang.String aBuf)
          Lowercase the specified String.
static java.lang.String toLowerCase(java.util.Locale aLocale, java.lang.StringBuffer aBuf, int start, int limit)
          Lowercase the specified segment of the StringBuffer
static java.lang.String toLowerCase(java.util.Locale aLocale, java.lang.String aBuf, int start, int limit)
          Lowercase the specified segment of the StringBuffer
static byte[] toPackedDecimal(java.lang.String aPackedString, boolean isSigned, int digits, int decimals)
          Convert a string to byte array encoded as packed decimal data(COMP-3).
static java.lang.String toProperCase(java.lang.String aString)
          Convert the input text to proper case.
static java.lang.String toUpperCase(java.util.Locale aLocale, java.lang.String aBuf)
          Uppercase the specified String.
static java.lang.String toUpperCase(java.util.Locale aLocale, java.lang.StringBuffer aBuf, int start, int limit)
          Uppercase the specified segment of the StringBuffer
static java.lang.String toUpperCase(java.util.Locale aLocale, java.lang.String aBuf, int start, int limit)
          Uppercase the specified segment of the String.
static byte[] toZonedDecimal(java.lang.String aZonedString, boolean isSigned, int digits, int decimals)
          Convert a string to byte array encoded as zoned decimal data(DISPLAY).
static java.lang.String unquote(java.lang.String input)
           
static char[] urlClean(char[] in)
          Changes invalid URL characters to the under-bar char.
static char[] urlClean(java.lang.String in)
           
static char[] urlClean(java.lang.StringBuffer in)
           
static java.lang.String urlCrossScriptingFilter(java.lang.String aBuf)
          Converts the special characters into url encoded values for the given string
static void writeEscapedCSVEntry(java.lang.String aString, java.io.PrintWriter aWriter)
          Writes a single field of information about a class to a comma-separated-value (CSV) file, escaping characters as necessary.
static java.lang.String xlateBytesToString(byte[] aData, int useLen, java.lang.String encoding)
          Translate byte array using the specified character encoding
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION

ASIS

public static final int ASIS
Constant for "concat" methods, leave string in original case

See Also:
Constant Field Values

UPPERCASE

public static final int UPPERCASE
Constant for "concat" methods, convert string to upper case

See Also:
Constant Field Values

LOWERCASE

public static final int LOWERCASE
Constant for "concat" methods, convert string to lower case

See Also:
Constant Field Values
Constructor Detail

StringUtils

public StringUtils()
Method Detail

reversibleCrossScriptingFilter

public static java.lang.String reversibleCrossScriptingFilter(java.lang.String aBuf)
filter a string for cross site scripting characters and add a prefix to allow for filtering to be reversed

Parameters:
aBuf - the source string
Returns:
string

urlCrossScriptingFilter

public static final java.lang.String urlCrossScriptingFilter(java.lang.String aBuf)
Converts the special characters into url encoded values for the given string

Parameters:
aBuf - the source string
Returns:
string

restoreFilteredString

public static java.lang.String restoreFilteredString(java.lang.String aBuf)
restore a cross site scripting filtered string to its original form

Parameters:
aBuf - the source string
Returns:
string

packString

public static java.lang.String packString(java.lang.String input)
                                   throws PRException
Convert escape sequences to individual characters.

This is useful for accepting user input of the form "\r\n" and you want to turn it into the character equivalent.

Parameters:
input - string
Returns:
converted string.
Throws:
PRException

toPackedDecimal

public static byte[] toPackedDecimal(java.lang.String aPackedString,
                                     boolean isSigned,
                                     int digits,
                                     int decimals)
Convert a string to byte array encoded as packed decimal data(COMP-3).

Parameters:
aPackedString - string containing decimal value.
isSigned - whether produce signed value or not
digits - number of digits in the whole part of the number
decimals - the number of implied decimal places.
Returns:
result

fromZonedDecimal

public static java.lang.String fromZonedDecimal(byte[] zonedDecimal,
                                                int decimals)
Convert a byte array encoded as zoned decimal data(DISPLAY) to the string equivalent. This method will add the implied decimal to output string.

Parameters:
zonedDecimal - byte array containing packed decimal value.
decimals - the number of implied decimal places.
Returns:
result

toZonedDecimal

public static byte[] toZonedDecimal(java.lang.String aZonedString,
                                    boolean isSigned,
                                    int digits,
                                    int decimals)
Convert a string to byte array encoded as zoned decimal data(DISPLAY).

Parameters:
aZonedString - string containing decimal value.
isSigned - whether produce signed value or not
digits - number of digits in the whole part of the number
decimals - the number of implied decimal places.
Returns:
result

fromPackedDecimal

public static java.lang.String fromPackedDecimal(byte[] packedDecimal)
Convert a byte array encoded as packed decimal data(COMP-3) to the string equivalent. This method leaves the implied decimals implied in the output string.

Parameters:
packedDecimal - byte array containing packed decimal value.
Returns:
result

fromPackedDecimal

public static java.lang.String fromPackedDecimal(byte[] packedDecimal,
                                                 int decimals)
Convert a byte array encoded as packed decimal data(COMP-3) to the string equivalent. This method will add the implied decimal to output string.

Parameters:
packedDecimal - byte array containing packed decimal value.
decimals - the number of implied decimal places.
Returns:
result

padLeft

public static java.lang.String padLeft(java.lang.String in,
                                       int length)
Pad a string on the left with spaces until it has length specified.

Parameters:
in - the string to pad
length - length to pad to
Returns:
padded string

padLeft

public static java.lang.String padLeft(java.lang.String in,
                                       int length,
                                       char padChar)
Pad a string on left with specified pad character so it has specified length.

String will not be truncated if it is longer than specified length. null string will cause a new string to be allocated and padded to the specified length.

Parameters:
in - string to pad
length - desired length of string
padChar - character to fill length
Returns:
the padded string

padRight

public static java.lang.String padRight(java.lang.String in,
                                        int length)
Pad a string on the right with spaces until it has length specified.

Parameters:
in - the string to pad
length - length to pad to
Returns:
padded string

padRight

public static java.lang.String padRight(java.lang.String in,
                                        int length,
                                        char padChar)
Pad a string on right with specified pad character so it has specified length.

String will not be truncated if it is longer than specified length. null string will cause a new string to be allocated and padded to the specified length.

Parameters:
in - string to pad
length - desired length of string
padChar - character to fill length
Returns:
the padded string

center

public static java.lang.String center(java.lang.String in,
                                      int length)
center a string in a given length

Parameters:
in -
length -
Returns:
string centered in length

fitRight

public static java.lang.String fitRight(java.lang.String in,
                                        int length)
Fit a string to specified length padding the right or truncating as necessary.

String will be truncated or padded as needed.

Parameters:
in - string to fit
length - desired length of string
Returns:
string fit to length

fitRight

public static java.lang.String fitRight(java.lang.String in,
                                        int length,
                                        char padChar)
Fit a string to specified length padding the right or truncating as necessary.

String will be truncated or padded as needed.

Parameters:
in - string to fit
length - desired length of string
padChar - character used to pad
Returns:
string fit to length

urlClean

public static char[] urlClean(java.lang.String in)
Parameters:
in - StringBuffer to clean
Returns:
cleaned character array
See Also:
urlClean(char[])

urlClean

public static char[] urlClean(java.lang.StringBuffer in)
Parameters:
in - StringBuffer to clean
Returns:
cleaned character array
See Also:
urlClean(char[])

urlClean

public static char[] urlClean(char[] in)
Changes invalid URL characters to the under-bar char.

Parameters:
in - char array to change
Returns:
undated array

pageNameClean

public static char[] pageNameClean(java.lang.String in)
Parameters:
in - String to clean
Returns:
cleaned character array
See Also:
pageNameClean(char[])

pageNameClean

public static char[] pageNameClean(char[] in)
Changes invalid pageName characters to the under-bar char.

Parameters:
in - char array to change
Returns:
undated array

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg2 Objects whose string values should be concatenated
arg2 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg3 Objects whose string values should be concatenated
arg2 -
arg3 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg4 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg5 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5,
                                      java.lang.Object arg6)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg6 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
arg6 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5,
                                      java.lang.Object arg6,
                                      java.lang.Object arg7)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg7 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
arg6 -
arg7 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5,
                                      java.lang.Object arg6,
                                      java.lang.Object arg7,
                                      java.lang.Object arg8)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg8 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
arg6 -
arg7 -
arg8 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5,
                                      java.lang.Object arg6,
                                      java.lang.Object arg7,
                                      java.lang.Object arg8,
                                      java.lang.Object arg9)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg9 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
arg6 -
arg7 -
arg8 -
arg9 -
Returns:
String concatenation of objects

concat

public static java.lang.String concat(int aCase,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4,
                                      java.lang.Object arg5,
                                      java.lang.Object arg6,
                                      java.lang.Object arg7,
                                      java.lang.Object arg8,
                                      java.lang.Object arg9,
                                      java.lang.Object arg10)
Concatenates strings (or Object.toString() equivalents) using StringBufferFactory for intermediate storage.

Parameters:
aCase - - ASIS, UPPERCASE, LOWERCASE
arg1 - .. arg10 Objects whose string values should be concatenated
arg2 -
arg3 -
arg4 -
arg5 -
arg6 -
arg7 -
arg8 -
arg9 -
arg10 -
Returns:
String concatenation of objects

toLowerCase

public static java.lang.String toLowerCase(java.util.Locale aLocale,
                                           java.lang.String aBuf)
Lowercase the specified String.

Parameters:
aLocale - locale to use or null for default locale
aBuf - String to lowecase
Returns:
lowercased String

toLowerCase

public static java.lang.String toLowerCase(java.util.Locale aLocale,
                                           java.lang.String aBuf,
                                           int start,
                                           int limit)
Lowercase the specified segment of the StringBuffer

Parameters:
aLocale - locale to use or null for default locale
aBuf - String to lowercase
start -
limit -
Returns:
lowercased String

toLowerCase

public static java.lang.String toLowerCase(java.util.Locale aLocale,
                                           java.lang.StringBuffer aBuf,
                                           int start,
                                           int limit)
Lowercase the specified segment of the StringBuffer

Parameters:
aLocale - locale to use or null for default locale
aBuf - String Buffer to lowercase
start -
limit -
Returns:
lowercased String

toUpperCase

public static java.lang.String toUpperCase(java.util.Locale aLocale,
                                           java.lang.String aBuf)
Uppercase the specified String.

Parameters:
aLocale - locale to use or null for default locale
aBuf -
Returns:
uppercased String

toUpperCase

public static java.lang.String toUpperCase(java.util.Locale aLocale,
                                           java.lang.String aBuf,
                                           int start,
                                           int limit)
Uppercase the specified segment of the String.

Parameters:
aLocale - locale to use or null for default locale
aBuf -
start -
limit -
Returns:
uppercased String

toUpperCase

public static java.lang.String toUpperCase(java.util.Locale aLocale,
                                           java.lang.StringBuffer aBuf,
                                           int start,
                                           int limit)
Uppercase the specified segment of the StringBuffer

Parameters:
aLocale - locale to use or null for default locale
aBuf -
start -
limit -
Returns:
uppercased String

toProperCase

public static java.lang.String toProperCase(java.lang.String aString)
Convert the input text to proper case. Proper case means that the first character of each word is in uppercase, and the rest of the word is in lowercase.

Parameters:
aString - input text
Returns:
the converted text

interpretBoolean

public static final boolean interpretBoolean(java.lang.String aOpt)
Interprets a String value as a boolean, satisfying javascript and generic conventions. A hybrid of the former ResourceManager.interpretBoolean and PRStringFormat.pegaToBoolean for public use. Identical to FUAUtil.parseBoolean().

Parameters:
aOpt - String to be evaluated
Returns:
true or false

unquote

public static final java.lang.String unquote(java.lang.String input)

replaceAll

public static final java.lang.String replaceAll(java.lang.String aBaseString,
                                                java.lang.String aOriginalChars,
                                                java.lang.String aNewChars,
                                                boolean aReplaceAssign)
Method replaceAll replaces the specified string..

Parameters:
aBaseString - - the base String
aOriginalChars - - the original characters
aNewChars - = new characters
aReplaceAssign - -
Returns:
String

replaceAll

public static final java.lang.String replaceAll(java.lang.String aBaseString,
                                                java.lang.String aOriginalChars,
                                                java.lang.String aNewChars)
Method replaceAll replaces the specified string..

Parameters:
aBaseString - - the base String
aOriginalChars - - the original characters
aNewChars - = new characters
Returns:
String

quoteAndEscape

public static final java.lang.String quoteAndEscape(java.lang.String aOriginalString)
This method will completely quote a string, converting existing double quotes to single quotes if necessary.

Parameters:
aOriginalString - The original string
Returns:
String The quoted string

quote

public static final java.lang.String quote(java.lang.String inputStr)

parseInt

public static int parseInt(int radix,
                           java.lang.String s,
                           int start,
                           int end)
                    throws java.lang.NumberFormatException
Similar to String.parseInt(String s, int radix) but allows specification of the segment of the string that should be parsed. Parameters rearranged to reduce confusion. Offset and length follow String.substring() conventions.

Parameters:
radix -
s -
start - starting offset (e.g. 0)
end - offset (e.g. s.length())
Returns:
converted number
Throws:
java.lang.NumberFormatException

replace

public static java.lang.StringBuffer replace(java.lang.StringBuffer buf,
                                             char oldChar,
                                             char newChar)
Similar to String.replace(oldChar, newChar) but operates on StringBuffer

Parameters:
buf -
oldChar -
newChar -
Returns:
buf with appropriate changes

escapeIntoJavaString

public static java.lang.String escapeIntoJavaString(java.lang.String aInput)
Given an input string, convert it into something we could embed in Java source. For example "hello world" (quotes included) would be returned as \"hello world\".

Parameters:
aInput - the source string to convert
Returns:
the escaped string.

escapeIntoJSONString

public static java.lang.String escapeIntoJSONString(java.lang.String aInput)
Given an input string, convert it into a valid JSON string. Differs from escapeIntoJavaString() because JSON does not support the \' escape sequence. Also adjusted for handling the issue noted in http://timelessrepo.com/json-isnt-a-javascript-subset

Parameters:
aInput - the source string to convert
Returns:
the escaped string.

writeEscapedCSVEntry

public static void writeEscapedCSVEntry(java.lang.String aString,
                                        java.io.PrintWriter aWriter)
Writes a single field of information about a class to a comma-separated-value (CSV) file, escaping characters as necessary. The comma after the entry is not written.

Parameters:
aString - the string to write
aWriter - the writer for the CSV file

parseQueryString

public static java.util.Map parseQueryString(java.lang.String aQS)
Parse a query string, creating a map of name=value pairs
26-Nov-02 olsok -- substituting algorithm from Tomcat 4.0.4 to more correctly deal with %hh escapes and character set encodings. This MAY cause problems for query/post data forwarded via the service interfaces that contains characters previously decoded and resulting in a string that contains something other than 8-bit characters. If this problem arises, olsok thinks the best solution would be to clone the parseURLParameter routine and let it parse characters instead of bytes -- but the issue of whether or not to treat %hh streams is problematic due to possible multiple interpretation.

Parameters:
aQS - The query string to parse, assumed to consist of 8-bit characters in UTF-8 encoding.
Returns:
Map A HashMap of name=value pairs.

parseURLParameters

public static void parseURLParameters(java.util.Map map,
                                      java.lang.String data,
                                      java.lang.String encoding)
Append request parameters from the specified String to the specified Map. It is presumed that the specified Map is not accessed from any other thread, so no synchronization is performed.

IMPLEMENTATION NOTE: URL decoding is performed individually on the parsed name and value elements, rather than on the entire query string ahead of time, to properly deal with the case where the name or value includes an encoded "=" or "&" character that would otherwise be interpreted as a delimiter. NOTE: The input String is assumed to contain 8-bit data only (such as might be retrieved from a servlet query parameter that was encoded in UTF-8 by the browser and handled as ISO-8859-1 by the servlet -- that is, what one typically sees in Tomcat on W2K).

Parameters:
map - Map that accumulates the resulting parameters
data - Input String containing request parameters
encoding - Encoding to use for converting bytes to String

parseURLParameters

public static void parseURLParameters(java.util.Map map,
                                      byte[] data,
                                      java.lang.String encoding)
parse the full byte array as a URL-encoded string

Parameters:
map - output parameter map
data - byte array to parse
encoding - character encoding

parseURLParameters

public static void parseURLParameters(java.util.Map map,
                                      byte[] data,
                                      int useLen,
                                      java.lang.String encoding)
26-Nov-02 OLSOK -- adapted parseParameters from Tomcat 4.0.4 and merged with PegaRULES heuristics (dealing with '&' entities in query strings) in order to get internationalization logic correct and plausible... see also:
Internationalized Resource Identifiers: http://www.w3.org/International/O-URL-and-ident
RFC-2718, Guidelines for new URL Schemes http://www.ietf.org/rfc/rfc2718.txt
HTML 4.0 Recommendation for handling non-ascii characters in URLs (encode the URL as UTF-8, then escape bytes using the %hh mechanism -- this results in using %hh as a byte of a UTF-8 character, NOT a character in some other encoding). http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1 Append request parameters from the specified String to the specified Map. It is presumed that the specified Map is not accessed from any other thread, so no synchronization is performed.

IMPLEMENTATION NOTE: URL decoding is performed individually on the parsed name and value elements, rather than on the entire query string ahead of time, to properly deal with the case where the name or value includes an encoded "=" or "&" character that would otherwise be interpreted as a delimiter. NOTE: byte array data is modified by this method. Caller beware.

Parameters:
map - Map that accumulates the resulting parameters
data - Input byte array containing request parameters
useLen - length of "data" byte array to consider during parse
encoding - Encoding to use for converting bytes to String

xlateBytesToString

public static java.lang.String xlateBytesToString(byte[] aData,
                                                  int useLen,
                                                  java.lang.String encoding)
Translate byte array using the specified character encoding

Parameters:
aData - byte array to translate
useLen - length of aData to translate, use full length if useLen is negative
encoding - Character encoding to use, defaults to UTF-8
Returns:
String output string in specified encoding, null if aData is null or if an UnsupportedEncodingException occurs.

stripQuotes

public static java.lang.String stripQuotes(java.lang.String aString)
Strip quotes from the specified string. If the leading character is not a single or double quote, then the original string is returned, otherwise the quote (single or double) will be removed from the string. NOTE: We assume the final character will be a matching quote.

Parameters:
aString -
Returns:
string which is not quoted.

indexOfEsc

public static int indexOfEsc(java.lang.String s,
                             char c,
                             int p)
String.indexOf - like function that respects back-slash escaping of the searched-for character

Parameters:
s - string to search within for c
c - char to search for in s, ignored if escaped by a preceeding backslash
p - position in s to start the search
Returns:
index Of c in s

indexOfEsc

public static int indexOfEsc(java.lang.StringBuffer s,
                             char c,
                             int p)
String.indexOf - like function that respects back-slash escaping of the searched-for character and works in jdk 1.3.x with StringBuffers

Parameters:
s - string to search within for c
c - char to search for in s, ignored if escaped by a preceeding backslash
p - position in s to start the search
Returns:
index Of c in s

indexOf

public static int indexOf(java.lang.StringBuffer s,
                          char c,
                          int p)
String.indexOf - like function that works with StringBuffers and works in jdk 1.3.x

Parameters:
s - string to search for c
c - char to search for in s, ignored if escaped by a preceeding backslash
p - position in s to start the search
Returns:
index Of c in s

encodeURL

public static java.lang.String encodeURL(java.lang.String strParameterValue)
Translates a string into application/x-www-form-urlencoded format using the UTF-8 encoding scheme. This method uses UTF-8 encoding to obtain the bytes for unsafe characters.

Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

Parameters:
strParameterValue - String to be translated.
Returns:
the translated String.

decodeURL

public static java.lang.String decodeURL(java.lang.String s)
Decodes a application/x-www-form-urlencoded string using the UTF-8 encoding scheme. UTF-8 encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".

Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

Parameters:
s - the String to decode
Returns:
the newly decoded String

startsWith

public static boolean startsWith(java.lang.CharSequence aSequenceToCheck,
                                 java.lang.String aLookingFor)

insertInteger

public static void insertInteger(java.lang.StringBuffer aTarget,
                                 int aAtPosition,
                                 int aIntValue)

toHexString

public static java.lang.String toHexString(byte[] in)
Convert byte array to a string of hex.

Parameters:
in -
Returns:
string of hex representing the input byte array

fromHexString

public static byte[] fromHexString(java.lang.String in)
Convert string of hex to a byte array

Parameters:
in -
Returns:
byte array representing the string of hex

crossScriptingFilter

public static java.lang.String crossScriptingFilter(java.lang.String aBuf)
Converts the special characters into html entities for the given string

Parameters:
aBuf - the source string
Returns:
string

escapeCrossScriptingFilter

public static java.lang.String escapeCrossScriptingFilter(java.lang.String aBuf)
Converts the special characters into html entities also appends escape character for single quote and double quote for the given string

Parameters:
aBuf - the source string
Returns:
string

escapeForExpression

public static java.lang.String escapeForExpression(java.lang.String value)

filterRichText

public static final java.lang.String filterRichText(java.lang.String html)

indexOf

public static final int indexOf(char[] aSource,
                                int aSourceStart,
                                int aSourceLength,
                                java.lang.String aToBeFound)
Locate a substring within a character array

Parameters:
aSource - The character array to be searched
aSourceStart - Location in the character array to start searching from
aSourceLength - The number of characters from aSourceStart to stop searching at
aToBeFound - The string to be located in the array
Returns:
the character array index where the given string starts from, or -1 if not found
Engineering owner
Jim Gajnak

isBlank

public static final boolean isBlank(java.lang.String aString)
Returns true iff the string is non-null and has size greated than zero.

Parameters:
aString - the string
Returns:
true if not blank

getPackageQualifier

public static final java.lang.String getPackageQualifier(ClassDefinition aClass)

compareStringsHandleNulls

public static final boolean compareStringsHandleNulls(java.lang.String lhs,
                                                      java.lang.String rhs)


Copyright © 2012 Pegasystems Inc. All Rights Reserved.