com.sas.edir.util
Class StringOp

java.lang.Object
  |
  +--com.sas.edir.util.StringOp

public class StringOp
extends java.lang.Object

String operator utilities History: 02Aug96 Created [bdw] 13Aug96 Add split with escape character [bdw] 10Apr97 Added equals() and equalsIgnoreCase() [djc] 06Jun97 Added splitAndTrim methods [djc] Notes: o splitAndTrim() should be merged into split()


Constructor Summary
StringOp()
           
 
Method Summary
static int compare(java.lang.String s1, java.lang.String s2)
          Compares its two strings for order.
static int compareIgnoreCase(java.lang.String s1, java.lang.String s2)
          Compares its two strings for order.
static int contains(java.lang.String[] source, java.lang.String str)
          Check to see if a string is contained in an array of strings or if a string is a substring in the array of strings.
static int containsIgnoreCase(java.lang.String[] source, java.lang.String str)
          Case insensitive check to see if a string is contained in an array of strings or if a string is a substring in the array of strings.
static boolean endsWith(java.lang.String source, java.lang.String str)
          Check to see if the end characters of source matches the given str.
static boolean endsWithIgnoreCase(java.lang.String source, java.lang.String str)
          Check to see if the end characters of source matches the given str and ignores the case sensitivity.
static boolean equals(java.lang.String[] s1, java.lang.String[] s2)
           
static boolean equals(java.lang.String s1, java.lang.String s2)
          This is the quickest way to check for string equality.
static boolean equalsIgnoreCase(java.lang.String s1, java.lang.String s2)
          This is the quickest way to check for string equality.
static java.lang.String escape(java.lang.String inString)
          Add escape backslashes to special characters in string.
static int in(java.lang.String[] source, java.lang.String str)
          Check to see if a string is in a array of strings
static int inIgnoreCase(java.lang.String[] source, java.lang.String str)
          Case insensitive check to see if a string is in an array of strings
static boolean isEmpty(java.lang.String s1)
          See if a string is null or the empty string ("").
static java.lang.String nameFromInt(int num)
          Return a string representation of the value.
static java.lang.String nameFromLong(long num)
          Return a string representation of the value.
static java.lang.Object parseObject(java.lang.String str)
          Parse the given string and return it.
static java.lang.String removeBlanks(java.lang.String source)
          Remove and white space from the supplied source.
static java.lang.String[] split(java.lang.String inString, char delim)
          Split a string into an array of strings.
static java.lang.String[] split(java.lang.String inString, char delim, char escape)
          Split a string into an array of strings.
static java.lang.String[] splitAndTrim(java.lang.String inString, char delim)
          Split a string into an array of strings and trim whitespace.
static java.lang.String[] splitAndTrim(java.lang.String inString, char delim, char escape)
          Split a string into an array of strings and trim whitespace.
static boolean startsWith(java.lang.String source, java.lang.String str)
          Check to see if the first characters of source matches the given str.
static boolean startsWithIgnoreCase(java.lang.String source, java.lang.String str)
          Check to see if the first characters of source matches the given str and ignores the case sensitivity.
static java.lang.String substitute(java.lang.String inString, java.lang.String from, java.lang.String to)
          Change all occurances of from to the value to in the provided string.
static java.lang.String substituteIgnoreCase(java.lang.String inString, java.lang.String from, java.lang.String to)
          Change all occurances of from to the value to in the provided string, ignoring case.
static java.lang.String trim(java.lang.String string)
          Returns a string with white space removed from both ends of a string.
static java.lang.String wrap(java.lang.String source, int width)
          Wrap a string by inserting newlines.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringOp

public StringOp()
Method Detail

compare

public static final int compare(java.lang.String s1,
                                java.lang.String s2)
Compares its two strings for order.

Parameters:
s1 - One of the strings to compare.
s2 - One of the strings to compare.
Returns:
A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compareIgnoreCase

public static final int compareIgnoreCase(java.lang.String s1,
                                          java.lang.String s2)
Compares its two strings for order.

Parameters:
s1 - One of the strings to compare.
s2 - One of the strings to compare.
Returns:
A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

equals

public static final boolean equals(java.lang.String s1,
                                   java.lang.String s2)
This is the quickest way to check for string equality.

Parameters:
s1 - One of the strings to check.
s2 - One of the strings to check.
Returns:
true if the strings are equal, false otherwise.

equalsIgnoreCase

public static final boolean equalsIgnoreCase(java.lang.String s1,
                                             java.lang.String s2)
This is the quickest way to check for string equality.

Parameters:
s1 - One of the strings to check.
s2 - One of the strings to check.
Returns:
true if the strings are equal, false otherwise.

equals

public static final boolean equals(java.lang.String[] s1,
                                   java.lang.String[] s2)

isEmpty

public static final boolean isEmpty(java.lang.String s1)
See if a string is null or the empty string ("").

Parameters:
s1 - The string to check.
Returns:
true if the string is null or empty, false otherwise.

removeBlanks

public static final java.lang.String removeBlanks(java.lang.String source)
Remove and white space from the supplied source.

Parameters:
source - The string to remove white space from.
Returns:
The resulting string with no white space.

wrap

public static final java.lang.String wrap(java.lang.String source,
                                          int width)
Wrap a string by inserting newlines.

Parameters:
source - The string to wrap.
width - How wide to make each line (in characters).
Returns:
The wrapped string.

trim

public static final java.lang.String trim(java.lang.String string)
Returns a string with white space removed from both ends of a string.

This method returns null if the string to be trimmed is null.

Parameters:
string - The string to be trimmed.
Returns:
A trimmed string.

splitAndTrim

public static final java.lang.String[] splitAndTrim(java.lang.String inString,
                                                    char delim)
Split a string into an array of strings and trim whitespace.

Parameters:
inString - string to be split
delim - delimiter character
Returns:
array of strings

splitAndTrim

public static final java.lang.String[] splitAndTrim(java.lang.String inString,
                                                    char delim,
                                                    char escape)
Split a string into an array of strings and trim whitespace.

Parameters:
inString - string to be split
delim - delimiter character
Returns:
array of strings

split

public static final java.lang.String[] split(java.lang.String inString,
                                             char delim)
Split a string into an array of strings.

Parameters:
inString - string to be split
delim - delimiter character
Returns:
array of strings

split

public static final java.lang.String[] split(java.lang.String inString,
                                             char delim,
                                             char escape)
Split a string into an array of strings.

Parameters:
inString - string to be split
delim - delimiter character
escape - escape character
Returns:
array of strings

escape

public static final java.lang.String escape(java.lang.String inString)
Add escape backslashes to special characters in string.

Parameters:
inString - string to be escaped
Returns:
escaped string

substitute

public static final java.lang.String substitute(java.lang.String inString,
                                                java.lang.String from,
                                                java.lang.String to)
Change all occurances of from to the value to in the provided string.

Parameters:
inString - String to be searched.
from - String to look for as occurances.
to - String to replace all occurances of from.
Returns:
The new string with the substitutes made.

substituteIgnoreCase

public static final java.lang.String substituteIgnoreCase(java.lang.String inString,
                                                          java.lang.String from,
                                                          java.lang.String to)
Change all occurances of from to the value to in the provided string, ignoring case.

Parameters:
inString - String to be searched.
from - String to look for as occurances.
to - String to replace all occurances of from.
Returns:
The new string with the substitutes made.

nameFromInt

public static final java.lang.String nameFromInt(int num)
Return a string representation of the value.

Parameters:
num - An integer to be changed.
Returns:
The string representation of the value.

nameFromLong

public static final java.lang.String nameFromLong(long num)
Return a string representation of the value.

Parameters:
num - A long to be changed.
Returns:
The string representation of the value.

parseObject

public static final java.lang.Object parseObject(java.lang.String str)
Parse the given string and return it.

Parameters:
str - The string to parse.
Returns:
The resulting value from the parse..

contains

public static int contains(java.lang.String[] source,
                           java.lang.String str)
Check to see if a string is contained in an array of strings or if a string is a substring in the array of strings.

Parameters:
source - The array of strings to look in
str - The string or substing.

containsIgnoreCase

public static final int containsIgnoreCase(java.lang.String[] source,
                                           java.lang.String str)
Case insensitive check to see if a string is contained in an array of strings or if a string is a substring in the array of strings.

Parameters:
source - The array of strings to look in
str - The string or substing.

endsWith

public static final boolean endsWith(java.lang.String source,
                                     java.lang.String str)
Check to see if the end characters of source matches the given str.

Parameters:
source - The source to check.
str - The string to search for.
Returns:
true if the ending characters of source match the given str, false otherwise.

endsWithIgnoreCase

public static final boolean endsWithIgnoreCase(java.lang.String source,
                                               java.lang.String str)
Check to see if the end characters of source matches the given str and ignores the case sensitivity.

Parameters:
source - The source to check.
str - The string to search for.
Returns:
true if the ending characters of source match the given str, false otherwise.

in

public static final int in(java.lang.String[] source,
                           java.lang.String str)
Check to see if a string is in a array of strings

Parameters:
source - The array of strings to look in
str - The string.

inIgnoreCase

public static final int inIgnoreCase(java.lang.String[] source,
                                     java.lang.String str)
Case insensitive check to see if a string is in an array of strings

Parameters:
source - The array of strings to look in
str - The string.

startsWith

public static final boolean startsWith(java.lang.String source,
                                       java.lang.String str)
Check to see if the first characters of source matches the given str.

Parameters:
source - The source to check.
str - The string to search for.
Returns:
true if the first characters of source match the given str, false otherwise.

startsWithIgnoreCase

public static final boolean startsWithIgnoreCase(java.lang.String source,
                                                 java.lang.String str)
Check to see if the first characters of source matches the given str and ignores the case sensitivity.

Parameters:
source - The source to check.
str - The string to search for.
Returns:
true if the first characters of source match the given str, false otherwise.