public abstract class StringUtils extends StringUtilities
Modifier and Type | Class and Description |
---|---|
static class |
StringUtils.ErrorLineParser
This class is used to parse the test error message.
|
static class |
StringUtils.ErrorLinkTrace
This class encapsulate the test error message.
|
StringUtilities.TestStacktraceCaller
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AND
string and &
|
static java.lang.String |
BACK_SLASH
string back slash \
|
static java.lang.String |
CARET
string caret ^
|
static java.lang.String |
CARRIAGE_RETURN
"\r" carriage return
|
static java.lang.String |
CASE_INSENSITIVE
"CASE-INSENSITIVE"
|
static java.lang.String |
CASEINSENSITIVE
"CASEINSENSITIVE"
|
static char |
CHAR_AND
character and &
|
static char |
CHAR_BACK_SLASH
character back slash \
|
static char |
CHAR_CARET
character caret ^
|
static char |
CHAR_COLON
character colon :
|
static char |
CHAR_COMMA
','
|
static char |
CHAR_DOLLAR
character dollar $
|
static char |
CHAR_DOT
character dot .
|
static char |
CHAR_DOUBLE_QUOTE
character double quote "
|
static char |
CHAR_EQUAL
character equal =
|
static char |
CHAR_INTERROGATION
character interrogation ?
|
static char |
CHAR_MINUS
'-'
|
static char |
CHAR_NUMBER
character number #
|
static char |
CHAR_PERCENTAGE
'%'
|
static char |
CHAR_PLUS
'+'
|
static char |
CHAR_QUOTE
character single quote '
|
static char |
CHAR_SEMI_COLON
';'
|
static char |
CHAR_SLASH
character slash /
|
static char |
CHAR_SPACE
' '
|
static char |
CHAR_STAR
character star *
|
static java.lang.String |
CHARSET_UTF8
"UTF-8" charset
|
static java.lang.String |
COLON
string colon :
|
static java.lang.String |
COMMA
","
|
static java.lang.String |
CRLF
"\r\n" PC new line string
|
static int |
DEFAULT_BUFFER_SIZE
1024*10
|
static int |
DEFAULT_X_COORDINATE
'5', the default x coordinate in pixel.
|
static int |
DEFAULT_Y_COORDINATE
'5', the default y coordinate in pixel.
|
static java.lang.String |
DOLLAR
string dollar $
|
static java.lang.String |
DOT
string dot .
|
static java.lang.String |
DOUBLE_QUOTE
string double quote "
|
static java.lang.String |
EQUAL
string equal =
|
static java.lang.String |
INTERROGATION
string interrogation ?
|
static java.lang.String |
KEY_UTF8_CHARSET
The charset used to translate the base64 encoded bytes to string,
and translate that string back to base64 encoded bytes.
|
static java.lang.String |
LOCAL_HOST
'localhost'
|
static java.lang.String |
LOCAL_HOST_IP
'127.0.0.1'
|
static int |
maxBytesPerRead
10000
|
static java.lang.String |
MINUS
"-"
|
static java.lang.String |
NEW_LINE
"\n" new line string
|
static java.lang.String |
NUMBER
string number #
|
static java.lang.String |
PERCENTAGE
"%"
|
static java.lang.String |
PLUS
"+"
|
static java.lang.String |
PROPERTY_START |
static java.lang.String |
QUOTE
string single quote '
|
static java.lang.String |
REGEX_CHARACTER_ANY
"."
|
static java.lang.String |
REGEX_CHARACTER_MATCH_MANY
"*"
|
static java.lang.String |
REGEX_CHARACTER_MATCH_ONE
"?"
|
static java.lang.Character |
REGEX_ESCAPE_CHARACTER
'\'
|
static java.lang.String |
SEMI_COLON
";"
|
static java.lang.String |
SLASH
string slash /
|
static java.lang.String |
SPACE
" "
|
static java.lang.String[] |
specialKeys
"~", "+", "^", "%", "(", ")", "{", "}"
|
static java.lang.String |
SYSTEM_PROPERTY_NON_PROXY_HOSTS
'http.nonProxyHosts'
|
static java.lang.String |
SYSTEM_PROPERTY_PROXY_BYPASS
'http.proxyBypass'
|
static java.lang.String |
SYSTEM_PROPERTY_PROXY_HOST
'http.proxyHost'
|
static java.lang.String |
SYSTEM_PROPERTY_PROXY_PORT
'http.proxyPort'
|
static char[] |
URL_ENCODING_IGNORE_CHARACTERS
An array defines the characters should not be encoded.
|
static char[] |
WILDCARD_CHARS
'*', '$'
|
DATE_FORMAT_a, DATE_FORMAT_AM_PM_DATE_TIME, DATE_FORMAT_AM_PM_TIME, DATE_FORMAT_DATE, DATE_FORMAT_MILITARY_DATE_TIME, DATE_FORMAT_MILITARY_TIME, FILE_TIME_BASE, JAVA_TIME_BASE, SAFS_DEFAULT_START_INDEX, TIME_OF_AM, TIME_OF_PM, TimeBaseDifferenceFromFileTimeToJavaTimeInMillisecond
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.List<T> |
arrayToList(T[] array)
As the List returned by Arrays.asList() does not support remove operation.
So we provide this method ourselves. |
static java.lang.String |
arrayToString(java.lang.Object[] values)
Convert an array to a string, which contains the array's value separated by a space.
|
static java.lang.String |
arrayToString(java.lang.Object[] values,
java.lang.String delimiter)
Convert an array to a string, which contains the array's value separated by parameter delimiter.
|
static java.lang.String[] |
breakXpath(java.lang.String xpath,
boolean onlyLeaf,
boolean rootToLeaf)
Break the xpath into multiple xparts by slash and return these xparts as an array.
The slash between quote or double-quote will not be considered as separator of xpart. |
static java.lang.String |
concat(java.lang.String s1,
java.lang.String s2,
java.lang.String s3)
Purpose: concatenate strings |
static java.lang.String |
concatURL(java.lang.String baseURL,
java.lang.String relativeURI) |
static boolean |
contains(java.lang.String content,
char[] characters)
check if a string contains one of characters given by an array.
|
static boolean |
containsSepcialKeys(java.lang.String value) |
static java.util.Map<java.lang.String,java.lang.String> |
convertCollectionToMap(java.util.Collection<java.lang.String> contents,
java.lang.String sep)
Convert a collection of text entries formatted as name=value into a Map file.
|
static java.awt.Point |
convertCoords(java.lang.String coords)
Convert coordinates string formats:
"x;y"
"x,y"
"x y"
"Coords=x;y"
"Coords=x,y"
"Coords=x y"
into a java.awt.Point object.
|
static java.awt.Point |
convertCoords(java.lang.String[] coordsPair)
Convert the coordinate (given by array of String) into java.awt.Point format.
|
static java.awt.Point |
convertCoords(java.lang.String[] coordsPair,
java.awt.Rectangle compRect)
Convert the coordinate (given by array of String) into java.awt.Point format.
|
static java.lang.String[] |
convertCoordsToArray(java.lang.String coords,
int length)
Convert coordinates string of the formats:
"x1;y1;x2;y2"
"x1,y1,x2,y2"
"x1 y1 x2 y2"
"x1;y1;x2;y2;x3;y3;x4;y4"
"Coords=x1;y1;x2;y2"
"Coords=x1,y1,x2,y2"
"Coords=x1 y1 x2 y2"
"Coords=x1 y1 x2 y2 x3 y3 x4 y4"
into an array object.
|
static java.awt.Polygon |
convertLine(java.lang.String coords)
Convert 2-point Line coordinates string of the formats:
"x1;y1;x2;y2"
"x1,y1,x2,y2"
"x1 y1 x2 y2"
"Coords=x1;y1;x2;y2"
"Coords=x1,y1,x2,y2"
"Coords=x1 y1 x2 y2"
into a java.awt.Polygon object.
|
static java.lang.Integer |
convertNum(java.lang.String num)
Purpose: convertNum: convert into a number Assumptions: all exceptions are handled. |
static java.lang.String |
convertWildcardsToRegularExpression(java.lang.String input)
convert ? and * wildcarding to regular expression wildcarding .? and .*
|
static java.lang.Object |
decodeBase64Object(java.lang.String base64String)
Decode a string to object with charset "UTF-8".
|
static java.lang.String |
deduceUnusedSeparatorString(java.lang.String expression)
Decide what is the best separator to use for a record from a possible separator list:
TestRecordData.POSSIBLE_SEPARATOR . |
static java.lang.String |
deduceUsedSeparatorString(java.lang.String expression)
Deduce the separator used in the expression, it tries each possible separator in list
TestRecordData.POSSIBLE_SEPARATOR and return the first used one. |
static java.lang.String |
encodeBase64Object(java.lang.Object object)
Encode the object to a string with charset "UTF-8".
|
static java.lang.String[] |
extractCoordStringPair(java.lang.String coords)
Deprecated.
call
convertCoordsToArray(String, int) , which is more generic. |
static int |
findExactMatchIndex(java.util.ListIterator iter,
java.lang.String match)
Purpose: find an exact match based on the parameter by walking the list, finding a string which equals the matching string, and returning the index into the list if it matched. |
static int |
findMatchIndex(java.util.ListIterator iter,
java.lang.String match)
Purpose: find a match based on the parameter by walking the list, finding a string which contains the matching substring, and returning the index into the list if it matched. |
static java.lang.String |
generatePositionSepeartor(java.lang.String stepSeparator)
Generate a separator different from 'step separator', and it can be used to separate
the coordinates for the position parameter in a test record. |
static java.lang.String |
generateUniqueName(java.lang.String prefix)
Generate a unique name.
|
static java.lang.String |
getChars(java.lang.Integer num,
java.lang.String chars)
Purpose: get a string with the number of specified sequenced 'chars' |
static java.lang.String |
getDBVal(java.lang.Object m)
Deprecated.
for DatabaseUtils.getDBVal(Object)
|
static java.lang.String |
getDelimitedString(java.util.List<java.lang.String> list,
java.lang.String delimiter)
Purpose: Get text strung delimited by delimiter from a list, delimiter will be considered as a whole string
Example: If delimiter is "->", if the list contains 3 items, "parent" "child" "grandChild" the returned text is "parent->child->grandChild" |
static int |
getFieldCount(java.lang.String input,
int startindex,
java.lang.String seps)
Purpose: Finds the count of all fields within the inputRecord found from startindex to the end of the inputRecord. |
static java.lang.String |
getFirstLine(java.lang.String content) |
static java.lang.String |
getInputToken(java.lang.String input,
int n,
java.lang.String sep)
Purpose: get 0-based field N of input by tokenizing with sep. |
static java.lang.String |
getLastDelimitedToken(java.lang.String delimitedString,
java.lang.String delimiter) |
static java.lang.String |
getMemoryAddress(java.lang.Object object)
Get the object's memory address according to the method hashCode().
Note: The method hashCode() should not be overridden. |
static java.lang.String |
getParentXpath(java.lang.String xpath)
Return the parent part of an xpath.
|
static java.lang.String[] |
getSortArray(java.lang.String[] inp) |
static java.lang.String |
getSpaces(java.lang.Integer num)
Purpose: get a string with the number of specified spaces |
static java.lang.String |
getStackInfo(java.util.Stack<?> stack) |
static java.lang.String |
getSystemProperty(java.lang.String property,
ConfigureInterface config,
java.lang.String section,
java.lang.String key,
java.lang.String... defaultValue)
Get the value of a property from system properties and Set a value from the configuration to System-Properties.
|
static java.lang.String[] |
getTokenArray(java.lang.String text,
java.lang.String delimiter) |
static java.lang.String[] |
getTokenArray(java.lang.String text,
java.lang.String delimiter,
java.lang.Character escapeChar) |
static java.util.List<java.lang.String> |
getTokenList(java.lang.String text,
java.lang.String delimiter)
Purpose: Get tokens of text delimited by delimiter, delimiter will be considered as a whole string
Example: If delimiter is "->", text is "parent->child->grandChild", then the returned list will contains 3 items: "parent", "child" and "grandChild". |
static java.util.List<java.lang.String> |
getTokenList(java.lang.String text,
java.lang.String delimiter,
java.lang.Character escapeChar)
Purpose: Get tokens of text delimited by delimiter, delimiter will be considered as a whole string,
if some token contains the delimiter, user needs to escape the delimiter.
|
static java.util.List<java.lang.String> |
getTrimmedTokenList(java.lang.String text,
java.lang.String delimiter)
Purpose: Get tokens of text delimited by delimiter, delimiter will be considered as a whole string.
|
static java.util.List<java.lang.String> |
getTrimmedTokenList(java.lang.String text,
java.lang.String delimiter,
java.lang.Character escapeChar)
Purpose: Get tokens of text separated by delimiter, delimiter will be considered as a whole string,
if some token contains the delimiter, user needs to escape the delimiter.
|
static java.lang.String |
getTrimmedUnquotedStr(java.lang.String str)
Purpose: This method takes a string trims it of leading and trailing spaces, non-breaking spaces, and tabs, and then strips one leading and/or trailing quotation mark(#34)--if they exist. |
static java.lang.String |
getUniqueSep(java.lang.String sep,
java.lang.String command,
java.lang.String... params)
Get a separator NOT appear in command neither in params; if no such separator
can be found, then the default separator will be return. |
static void |
initIndependantLogByConsole() |
static boolean |
isCaseContainsMatch(java.lang.String source,
java.lang.String target,
boolean exactMatch)
Purpose: evaluate 2 string values to see if they match.
|
static boolean |
isCaseSensitive(java.lang.String caseSensitiveStr)
parse a string to tell if it represnet case insensitive.
|
static boolean |
isMatchingMaps(java.util.Map<java.lang.String,java.lang.String> source,
java.util.Map<java.lang.String,java.lang.String> target) |
static boolean |
isMatchingTargetMapValues(java.util.Map<java.lang.String,java.lang.String> source,
java.util.Map<java.lang.String,java.lang.String> target)
Compares 2 Maps, but only cares about matching those key/value items that exist
in the target/benchmark.
|
static boolean |
isQuoted(java.lang.String value)
Test if the value is double-quoted or not.
|
static boolean |
isValid(java.lang.String value) |
static java.lang.String |
leftTrimSpace(java.lang.String text)
Trims all chars below char (int) 32 EXCEPT for TAB char (int) 9
from the left side of the provided text string.
|
static void |
main(java.lang.String[] args)
java -ea org.safs.StringUtils
|
static boolean |
matchRegex(java.lang.String expression,
java.lang.String value)
Purpose: match a regular expression to a value. |
static boolean |
matchText(java.lang.String actualText,
java.lang.String expectedText,
boolean partialMatch,
boolean ignoreCase)
match a text(provided as fullstring, substing, regex, wildcard) against
the actual text got from application component(list, menu, tree, tab etc.) |
static java.lang.String |
normalizeLineBreaks(java.lang.String source)
Normalize potential line breaks:
|
static boolean |
parseBoolean(java.lang.String booleanString) |
static float |
parseFloat(java.lang.String floatNumber)
Convert s String float number (such as 35%, 0.68, 23, 5.4 etc.) into float.
|
static java.lang.String |
parseSeparator(java.lang.String input)
Parse a string to get the separator.
|
static java.lang.String |
processEmbeddedVariables(java.lang.String stringContainingVariables)
Replace the embedded variables inside a string.
Embedded variables are in the form %VARIABLE_NAME% and will be sought as System Properties, or System Environment variables. |
static java.lang.String |
quote(java.lang.String parameter)
Add double-quote around a string value.
|
static java.lang.StringBuffer |
readBinaryFile(java.lang.String filename)
Purpose: read Binary file based on 'filename', returns String |
static java.util.Collection |
readEncodingfile(java.lang.String filename,
java.lang.String encoding)
read file based on 'filename', returns collection of lines with no CR or
LF.
|
static java.util.Map<java.lang.String,java.lang.String> |
readEncodingMap(java.lang.String filename,
java.lang.String encoding)
read file based on 'filename', returns collection of lines with no CR or
LF.
|
static java.util.Collection |
readfile(java.lang.String filename)
read file based on 'filename', returns collection of lines with no CR or
LF.
|
static java.lang.StringBuffer |
readRawFile(java.lang.String filename)
read file based on 'filename', returns StringBuffer of file contents.
The file is assumed to be in the default System character encoding. |
static java.lang.StringBuffer |
readRawUTF8File(java.lang.String filename)
read file based on 'filename', returns StringBuffer of file contents.
The file is assumed to be using UTF-8 character encoding. |
static java.util.Collection |
readstring(java.lang.String str)
read string, returns collection of lines with no CR or LF.
|
static java.util.Collection |
readUTF8file(java.lang.String filename)
read file based on 'filename', returns collection of lines with no CR or
LF.
|
static java.lang.String |
removeWrappingDoubleQuotes(java.lang.String expression)
Remove the leading and ending double quote.
|
static java.lang.String |
replaceChar(java.lang.String source,
char toReplace,
char by)
Replace a certain char by a new char in the source string.
|
static java.lang.String |
replaceJVMOptionValue(java.lang.String jvmOptions,
java.lang.String option,
java.lang.String value)
Replace the value of an option in the whole JVM options.
|
static java.lang.String[] |
replaceSeparator(java.lang.String originalSeparator,
java.lang.String... params)
If the params contain the originalSeparator, then replace it by a different separator.
|
static <T> boolean |
reverseArray(T[] array)
Reverse an array.
|
static java.lang.String |
rightTrimSpace(java.lang.String text)
Trims all chars below char (int) 32 EXCEPT for TAB characters (int) 9
from the right side of the provided text string.
|
static java.lang.String |
stripFromEnv(java.lang.String envVar,
java.lang.String[] toRemoves) |
static java.lang.String |
toStringWithAddress(java.lang.Object object) |
static java.lang.String |
urlEncode(java.lang.String content)
Encode URL or form-content.
|
static java.lang.String |
urlEncode(java.lang.String content,
java.lang.String encoding)
Encode URL or form-content.
|
static java.lang.String |
urlEncode(java.lang.String content,
java.lang.String encoding,
char[] escapeChars)
Encode URL or form-content following the rule defined at application/x-www-form-urlencoded
|
static java.lang.String |
wildcardToRegex(java.lang.String wildcard)
Convert the wildcard string to regex expression.
|
static java.lang.String |
wildcardToRegex(java.lang.String wildcard,
boolean matchLineBegin,
boolean matchLineEnd)
Convert the wildcard string to regex expression.
The wildcard * represents zero or more characters. |
static void |
writeEncodingfile(java.lang.String filename,
java.util.Collection list,
java.lang.String encoding)
Note: The file will be opened as OutputStreamWriter with encoding
write to file 'filename' the toString() values contained in list.
|
static void |
writeEncodingProperties(java.lang.String filename,
java.util.Map<java.lang.String,java.lang.String> list,
java.lang.String encoding)
Note: The file will be opened as OutputStreamWriter with encoding
write to file 'filename' the toString() values contained in list.
|
static void |
writefile(java.lang.String filename,
java.util.Collection list)
write to file 'filename' the toString() values contained in list.
|
static void |
writefile(java.lang.String filename,
java.util.Collection list,
java.lang.String delim)
Deprecated.
for DatabaseUtils.writefile(String, Collection, String)
|
static void |
writeUTF8file(java.lang.String filename,
java.util.Collection list)
Note: The file will be opened as UTF-8 OutputStreamWriter
write to file 'filename' the toString() values contained in list.
|
charIsInRange, convertBool, convertToInteger, current, debugmsg, debugmsg, debugmsg, debugmsg, debugmsg, debugmsg, findAndReplace, formRectangle, getBoolean, getCallerClassName, getCallerID, getCallerName, getClassName, getCurrentMethodName, getDate, getDateString, getDateString, getDateTimeString, getDouble, getFloat, getIndex, getIndex, getInteger, getLong, getMethodName, getNumber, getNumSubstrings, getStackTraceElement, getString, getSubStrings, getSubStrings, getTimeString, getValue, isLegalVarName, isQuoted, isQuoted, isValidNonStdChar, locateNextNonWhiteSpace, locateNextSubstring, locateNextUnquotedNonWhiteSpace, locateNextUnquotedSingleChar, locateNextUnquotedSingleChar, locateNextUnquotedSubstring, locateNextUnquotedSubstring, locateQuotedSubStrings, LTWhitespace, nextCharIsDQ, parseIndex, parseIndex, removeAllNonQuotedWhitespace, removeAllNonQuotedWhitespace, removeDoubleQuotes, removePrefix, removeRelativeFilePathPrefix, removeSingleQuotes, removeSuffix, replaceString, reverse, RTWhitespace, sleep, spacePad, TWhitespace
public static final char CHAR_DOT
public static final char CHAR_STAR
public static final char CHAR_SLASH
public static final char CHAR_QUOTE
public static final char CHAR_DOUBLE_QUOTE
public static final char CHAR_BACK_SLASH
public static final char CHAR_NUMBER
public static final char CHAR_COLON
public static final char CHAR_EQUAL
public static final char CHAR_AND
public static final char CHAR_INTERROGATION
public static final char CHAR_CARET
public static final char CHAR_DOLLAR
public static final char CHAR_PLUS
public static final char CHAR_MINUS
public static final char CHAR_COMMA
public static final char CHAR_SEMI_COLON
public static final char CHAR_PERCENTAGE
public static final char CHAR_SPACE
public static final char[] WILDCARD_CHARS
public static final java.lang.String REGEX_CHARACTER_ANY
public static final java.lang.String REGEX_CHARACTER_MATCH_MANY
public static final java.lang.String REGEX_CHARACTER_MATCH_ONE
public static final java.lang.Character REGEX_ESCAPE_CHARACTER
public static final java.lang.String SLASH
public static final java.lang.String QUOTE
public static final java.lang.String DOUBLE_QUOTE
public static final java.lang.String BACK_SLASH
public static final java.lang.String NUMBER
public static final java.lang.String COLON
public static final java.lang.String DOT
public static final java.lang.String EQUAL
public static final java.lang.String AND
public static final java.lang.String INTERROGATION
public static final java.lang.String CARET
public static final java.lang.String DOLLAR
public static final java.lang.String PLUS
public static final java.lang.String MINUS
public static final java.lang.String COMMA
public static final java.lang.String SEMI_COLON
public static final java.lang.String PERCENTAGE
public static final java.lang.String SPACE
public static final int maxBytesPerRead
public static final int DEFAULT_BUFFER_SIZE
public static final java.lang.String[] specialKeys
public static final java.lang.String LOCAL_HOST
public static final java.lang.String LOCAL_HOST_IP
public static final java.lang.String CASE_INSENSITIVE
public static final java.lang.String CASEINSENSITIVE
public static final java.lang.String NEW_LINE
public static final java.lang.String CRLF
public static final java.lang.String CARRIAGE_RETURN
public static final java.lang.String CHARSET_UTF8
public static final java.lang.String KEY_UTF8_CHARSET
public static final java.lang.String SYSTEM_PROPERTY_PROXY_HOST
public static final java.lang.String SYSTEM_PROPERTY_PROXY_PORT
public static final java.lang.String SYSTEM_PROPERTY_PROXY_BYPASS
public static final java.lang.String SYSTEM_PROPERTY_NON_PROXY_HOSTS
public static java.lang.String PROPERTY_START
public static final char[] URL_ENCODING_IGNORE_CHARACTERS
public static final int DEFAULT_X_COORDINATE
public static final int DEFAULT_Y_COORDINATE
public static int findMatchIndex(java.util.ListIterator iter, java.lang.String match)
iter,
- ListIteratormatch,
- Stringpublic static int findExactMatchIndex(java.util.ListIterator iter, java.lang.String match)
iter,
- ListIteratormatch,
- Stringpublic static boolean isCaseSensitive(java.lang.String caseSensitiveStr)
public static boolean isCaseContainsMatch(java.lang.String source, java.lang.String target, boolean exactMatch)
source,
- String to match against target. Can be a case-insensitive
substring of target if exactMatch is false.
target,
- String to compare with source.
exactMatch,
- false allows a case-insensitive comparison for a source
substring in target. Otherwise, the source and target must match exactly.
public static java.lang.String getSpaces(java.lang.Integer num)
num
- Integerpublic static java.lang.String getChars(java.lang.Integer num, java.lang.String chars)
num
- Integerchars
- Stringpublic static java.util.Collection readfile(java.lang.String filename) throws java.io.IOException
filename,
- Stringjava.io.IOException
FileUtilities.getSystemBufferedFileReader(String)
,
readBuffer(BufferedReader)
public static java.lang.StringBuffer readRawFile(java.lang.String filename) throws java.io.IOException
filename,
- Stringjava.io.IOException
FileUtilities.getSystemBufferedFileReader(String)
,
readRawBuffer(BufferedReader)
public static java.util.Collection readUTF8file(java.lang.String filename) throws java.io.IOException
filename,
- Stringjava.io.IOException
FileUtilities.getUTF8BufferedFileReader(String)
,
readBuffer(BufferedReader)
public static java.lang.StringBuffer readRawUTF8File(java.lang.String filename) throws java.io.IOException
filename,
- Stringjava.io.IOException
FileUtilities.getUTF8BufferedFileReader(String)
,
readRawBuffer(BufferedReader)
public static java.util.Collection readEncodingfile(java.lang.String filename, java.lang.String encoding) throws java.io.IOException
filename,
- Stringencoding,
- the character encoding used to read a file.java.io.IOException
FileUtilities.getUTF8BufferedFileReader(String)
,
readBuffer(BufferedReader)
public static java.util.Map<java.lang.String,java.lang.String> readEncodingMap(java.lang.String filename, java.lang.String encoding) throws java.io.IOException
filename,
- Stringencoding,
- the character encoding used to read a file.java.io.IOException
FileUtilities.getUTF8BufferedFileReader(String)
,
readBuffer(BufferedReader)
public static java.lang.String encodeBase64Object(java.lang.Object object) throws java.lang.IllegalThreadStateException
object,
- Object an object must implements interface Serializable.java.lang.IllegalThreadStateException
#decodeBase64Object(String)}
public static java.lang.Object decodeBase64Object(java.lang.String base64String) throws java.lang.IllegalThreadStateException
base64String,
- String, the base64 encoded string with charset "UTF-8"java.lang.IllegalThreadStateException
#encodeBase64Object(Object)}
public static boolean isMatchingMaps(java.util.Map<java.lang.String,java.lang.String> source, java.util.Map<java.lang.String,java.lang.String> target)
source
- target
- public static boolean isMatchingTargetMapValues(java.util.Map<java.lang.String,java.lang.String> source, java.util.Map<java.lang.String,java.lang.String> target)
source
- -- runtime Map to be compared against the target/benchmark.target
- -- benchmark to be compared against.public static java.util.Collection readstring(java.lang.String str) throws java.io.IOException
str,
- String,java.io.IOException
StringReader
,
BufferedReader.readLine()
public static java.lang.StringBuffer readBinaryFile(java.lang.String filename) throws java.io.IOException
filename,
- Stringjava.io.IOException
public static void writefile(java.lang.String filename, java.util.Collection list) throws java.io.IOException
filename
- String full absolute path filename of file to write.list
- Collection of lines to write.java.io.FileNotFoundException
- if file cannot be created for any reason.java.io.IOException
- if an error occurs during write operations.FileUtilities.getSystemBufferedFileWriter(String)
,
FileUtilities.writeCollectionToFile(BufferedWriter, Collection, String)
public static void writeUTF8file(java.lang.String filename, java.util.Collection list) throws java.io.IOException
filename
- String full absolute path filename of file to write.list
- Collection of lines to write.java.io.FileNotFoundException
- if file cannot be created for any reason.java.io.IOException
- if an error occurs during write operations.FileUtilities.getSystemBufferedFileWriter(String)
,
FileUtilities.writeCollectionToFile(BufferedWriter, Collection, String)
public static void writeEncodingfile(java.lang.String filename, java.util.Collection list, java.lang.String encoding) throws java.io.IOException
filename
- String full absolute path filename of file to write.list
- Collection of lines to write.encoding
- Encoding is used to write a file.java.io.FileNotFoundException
- if file cannot be created for any reason.java.io.IOException
- if an error occurs during write operations.FileUtilities.getSystemBufferedFileWriter(String)
,
FileUtilities.writeCollectionToFile(BufferedWriter, Collection, String)
public static java.util.Map<java.lang.String,java.lang.String> convertCollectionToMap(java.util.Collection<java.lang.String> contents, java.lang.String sep)
contents
- sep
- the separator used to delimit the name from the valuenormalizeLineBreaks(String)
public static void writeEncodingProperties(java.lang.String filename, java.util.Map<java.lang.String,java.lang.String> list, java.lang.String encoding) throws java.io.IOException
filename
- String full absolute path filename of file to write.list
- Properties to write.encoding
- Encoding is used to write a file.java.io.FileNotFoundException
- if file cannot be created for any reason.java.io.IOException
- if an error occurs during write operations.FileUtilities.getSystemBufferedFileWriter(String)
,
FileUtilities#writePropertiesFile(BufferedWriter, Properties)
@Deprecated public static void writefile(java.lang.String filename, java.util.Collection list, java.lang.String delim) throws java.io.IOException
java.io.IOException
DatabaseUtils.writefile(String, Collection, String)
@Deprecated public static java.lang.String getDBVal(java.lang.Object m)
DatabaseUtils.getDBVal(Object)
public static java.lang.String leftTrimSpace(java.lang.String text)
public static java.lang.String rightTrimSpace(java.lang.String text)
public static java.lang.String getTrimmedUnquotedStr(java.lang.String str)
str,
- String to unquotepublic static java.lang.String concat(java.lang.String s1, java.lang.String s2, java.lang.String s3)
s1,
- Strings2,
- Strings3,
- Stringpublic static java.lang.String concatURL(java.lang.String baseURL, java.lang.String relativeURI)
baseURL
- StringrelativeURI
- Stringpublic static java.lang.String convertWildcardsToRegularExpression(java.lang.String input)
public static boolean matchRegex(java.lang.String expression, java.lang.String value) throws SAFSException
expression,
- Stringvalue,
- StringSAFSRegExException
- if an error occurs.SAFSRegExNotFoundException
- if no RegEx support class can be found.SAFSException
public static boolean matchText(java.lang.String actualText, java.lang.String expectedText, boolean partialMatch, boolean ignoreCase)
actualText
- String, the actual text of the component's labelexpectedText
- String, the expected text, it can be full-string, sub-string, regex or wildcard string.partialMatch
- boolean, if the expectedText is provided as sub-stringignoreCase
- boolean, if the texts are case in-sensitive to comparepublic static java.lang.String[] getSortArray(java.lang.String[] inp)
public static java.lang.String getInputToken(java.lang.String input, int n, java.lang.String sep) throws SAFSNullPointerException
input,
- Stringn,
- int 0-based indexsep,
- StringSAFSNullPointerException
- if input or sep are nulljava.lang.StringIndexOutOfBoundsException
- if not found for index npublic static int getFieldCount(java.lang.String input, int startindex, java.lang.String seps) throws SAFSNullPointerException
input,
- Stringstartindex,
- intseps,
- StringSAFSNullPointerException
- if input or sep are nullpublic static <T> java.util.List<T> arrayToList(T[] array)
array
- T[], an array containing some valuepublic static java.util.List<java.lang.String> getTrimmedTokenList(java.lang.String text, java.lang.String delimiter)
text
- String, the delimited stringdelimiter
- String, the delimitergetTrimmedTokenList(String, String, Character)
public static java.util.List<java.lang.String> getTrimmedTokenList(java.lang.String text, java.lang.String delimiter, java.lang.Character escapeChar)
text
- String, the delimited stringdelimiter
- String, the delimiterescapeChar
- Character, the char to escape the delimitergetTokenList(String, String, Character)
public static java.util.List<java.lang.String> getTokenList(java.lang.String text, java.lang.String delimiter)
text
- String, the delimited stringdelimiter
- String, the delimitergetTokenList(String, String, Character)
public static java.util.List<java.lang.String> getTokenList(java.lang.String text, java.lang.String delimiter, java.lang.Character escapeChar)
text
- String, the delimited stringdelimiter
- String, the delimiterescapeChar
- Character, the char to escape the delimiterpublic static java.lang.String[] getTokenArray(java.lang.String text, java.lang.String delimiter)
text
- String, the delimited stringdelimiter
- String, the delimitergetTokenList(String, String, Character)
public static java.lang.String[] getTokenArray(java.lang.String text, java.lang.String delimiter, java.lang.Character escapeChar)
text
- String, the delimited stringdelimiter
- String, the delimiterescapeChar
- Character, the char to escape the delimitergetTokenList(String, String, Character)
public static java.lang.String getLastDelimitedToken(java.lang.String delimitedString, java.lang.String delimiter)
delimitedString
- String, the delimited stringdelimiter
- String, the delimiterpublic static java.lang.String getDelimitedString(java.util.List<java.lang.String> list, java.lang.String delimiter)
list
- delimiter
- public static boolean containsSepcialKeys(java.lang.String value)
public static java.lang.String urlEncode(java.lang.String content)
CHARSET_UTF8
, and the escape characters are URL_ENCODING_IGNORE_CHARACTERS
.content
- String, the URL or form-content to encodeurlEncode(String, String, char[])
public static java.lang.String urlEncode(java.lang.String content, java.lang.String encoding)
URL_ENCODING_IGNORE_CHARACTERS
.content
- String, the URL or form-content to encodeencoding
- String, the encoding to useurlEncode(String, String, char[])
public static java.lang.String urlEncode(java.lang.String content, java.lang.String encoding, char[] escapeChars)
content
- String, the URL or form-content to encodeencoding
- String, the encoding to useescapeChars
- char[], an array of characters to escape, which means these characters will not be encoded.public static boolean contains(java.lang.String content, char[] characters)
content
- String, the string to checkcharacters
- char[], an array of characterspublic static java.lang.String arrayToString(java.lang.Object[] values)
values
- Object[], the array to convertArrays.toString(Object[])
public static java.lang.String arrayToString(java.lang.Object[] values, java.lang.String delimiter)
For example: String[] numbers = {"one", "two", "three"}; System.out.println(arrayToString(numbers, "$"));//one$two$three System.out.println(arrayToString(numbers, "^"));//one^two^three
values
- Object[], the array to convertdelimiter
- String, used to separate each value from the array in the final string.public static java.lang.Integer convertNum(java.lang.String num)
numStr,
- String
(indexed from 1, 1 will be subtracted from the number before returned)public static float parseFloat(java.lang.String floatNumber)
floatNumber
- String, the String float number need to be converted@Deprecated public static java.lang.String[] extractCoordStringPair(java.lang.String coords)
convertCoordsToArray(String, int)
, which is more generic.coords
- String, x;y or x,y or Coords=x;y or Coords=x,ypublic static java.awt.Point convertCoords(java.lang.String[] coordsPair, java.awt.Rectangle compRect)
The 'coordinate' could be provided in 2 formats:
It could be number, such as [12, 15], [5, 10]. With this format
the second parameter 'compRect' is not needed (could be provided as null).
Or it could be in percentage format, such as [30%, 45%], [0.25, 0.8], [-30%, -45%], [-0.25, -0.8]. With this
format, the second parameter 'compRect' SHOULD be provided, and the width and
height of component rectangle are necessary.
coordsPair
- String[], the 2 dimension array representing the [x,y] coordinate.compRect
- Rectangle, it represents the component relative to which the coordinate will be calculated.public static java.awt.Point convertCoords(java.lang.String[] coordsPair)
coordsPair
- String[], a 2 dimension array containing [x,y] to be converted.public static java.awt.Point convertCoords(java.lang.String coords)
Subclasses may override to convert alternative values, such as Row and Column values as is done in org.safs.rational.CFTable
coords
- String, x;y or x,y or Coords=x;y or Coords=x,yextractCoordStringPair(String)
,
convertCoords(String[])
,
convertCoordsToArray(String, int)
public static java.awt.Polygon convertLine(java.lang.String coords)
coords
- String, x1;y1;x2;y2 or x1,y1,x2,y2 or Coords=x1;y1;x2;y2 or Coords=x1,y1,x2,y2public static java.lang.String[] convertCoordsToArray(java.lang.String coords, int length)
coords
- String, x1;y1;x2;y2 or x1,y1,x2,y2 or Coords=x1;y1;x2;y2 or Coords=x1,y1,x2,y2length
- int, the number of token contained in the first parameter coords.public static java.lang.String replaceChar(java.lang.String source, char toReplace, char by)
source
- String, the source stringtoReplace
- char, the char to replaceby
- char, the char used to replace the old char.public static java.lang.String[] replaceSeparator(java.lang.String originalSeparator, java.lang.String... params)
originalSeparator
- String, the original separator to search in parametersparams
- String..., an array of parameterpublic static java.lang.String generatePositionSepeartor(java.lang.String stepSeparator)
stepSeparator
- String, the separator in the step test record.public static java.lang.String parseSeparator(java.lang.String input)
input
- String, the string to parsepublic static java.lang.String getFirstLine(java.lang.String content)
content
- String, multiple lines, delimited by "\n"public static <T> boolean reverseArray(T[] array)
array
- T[], the array to reverse.public static java.lang.String deduceUnusedSeparatorString(java.lang.String expression)
TestRecordData.POSSIBLE_SEPARATOR
.expression
- String, to examine to find which of the separators does NOT exist inside
the expression.public static java.lang.String deduceUsedSeparatorString(java.lang.String expression)
TestRecordData.POSSIBLE_SEPARATOR
and return the first used one.expression
- String, to examine to find which separator does exist inside the expression.public static java.lang.String getUniqueSep(java.lang.String sep, java.lang.String command, java.lang.String... params)
sep
- String, the default separatorcommand
- String, the commandparams
- String[], the parameterspublic static java.lang.String removeWrappingDoubleQuotes(java.lang.String expression)
expression
- #processExpression(String)
,
#processExpression(String, String)
public static java.lang.String quote(java.lang.String parameter)
parameter
- String, the string to be double-quoted.public static boolean isQuoted(java.lang.String value)
value
- String, the string value to be tested.public static java.lang.String normalizeLineBreaks(java.lang.String source)
into a single uniformCRLF
,CARRIAGE_RETURN
,
NEW_LINE
linebreak.source
- NEW_LINE
.public static java.lang.String[] breakXpath(java.lang.String xpath, boolean onlyLeaf, boolean rootToLeaf)
xpath
- String, the xpathonlyLeaf
- boolean, if we only need to get the leafrootToLeaf
- boolean, true if we want the list begins with root, ends with leaf; false otherwise.public static java.lang.String getParentXpath(java.lang.String xpath)
xpath
- String, the xpath to parsepublic static java.lang.String getSystemProperty(java.lang.String property, ConfigureInterface config, java.lang.String section, java.lang.String key, java.lang.String... defaultValue)
Get the value of a property from system properties and Set a value from the configuration to System-Properties. If the System-Properties contains the 'property', keep the value in the System-Properties (don't override by the value from ConfigureInterface). Otherwise, if the System-Properties does NOT contain the 'property', then get the value from the ConfigureInterface, if the value is null or empty, assign the 'default value' if it is provided. Finally set this value to System-Properties.
property
- String, The property name in System-Properties.config
- ConfigureInterface, containing the configuration initial parameterssection
- String, The section name in the ConfigureInterfacekey
- String, The key name in the ConfigureInterfacedefaultValue
- String[], String[0] is the default value if no value can be got from system-properties and config.public static boolean isValid(java.lang.String value)
value
- String, the string value to testpublic static boolean parseBoolean(java.lang.String booleanString) throws SAFSParamException
booleanString,
- the boolean string to parse.SAFSParamException
- if the parameter 'booleanString' is not a valid boolean string.public static java.lang.String generateUniqueName(java.lang.String prefix)
prefix
- String, the prefix of the unique namepublic static java.lang.String replaceJVMOptionValue(java.lang.String jvmOptions, java.lang.String option, java.lang.String value)
jvmOptions
- String, the JVM options to modifyoption
- String, the JVM option to replacevalue
- String, the new value to usepublic static java.lang.String getMemoryAddress(java.lang.Object object)
object
- Object, the object to get memory address for.public static java.lang.String toStringWithAddress(java.lang.Object object)
object
- Object, the object to get stringpublic static java.lang.String getStackInfo(java.util.Stack<?> stack)
stack
- Stack, a stack holding some objects.toStringWithAddress(Object)
public static java.lang.String wildcardToRegex(java.lang.String wildcard)
wildcard
- String, the wildcard string.public static java.lang.String wildcardToRegex(java.lang.String wildcard, boolean matchLineBegin, boolean matchLineEnd)
wildcard
- String, the wildcard stringmatchLineBegin
- boolean, add ^ at the beginning of regex stringmatchLineEnd
- boolean, add $ at the end of regex stringpublic static java.lang.String processEmbeddedVariables(java.lang.String stringContainingVariables)
stringContainingVariables
- Stringpublic static java.lang.String stripFromEnv(java.lang.String envVar, java.lang.String[] toRemoves)
envVar
- String, the environment variable's name, like "CLASSPATH", "PATH" etc.toRemoves
- String[], an array of items to strip. It is partial matched, for example {"rational_ft.jar", "bfg.jar"}.public static void initIndependantLogByConsole()
public static void main(java.lang.String[] args)
args
- Copyright © SAS Institute. All Rights Reserved.