C# Class Org.IdentityConnectors.Common.StringUtil

Show file Open project: Tirasa/ConnId

Public Methods

Method Description
EndsWith ( string str, char value ) : bool

Determines if the string parameter 'str' ends with the character value.

IndexOf ( string src, char ch ) : int
IndexOf ( string src, char ch, int idx ) : int
IndexOfDigit ( string str ) : int

Finds the index of the first digit.

IndexOfDigit ( string str, int startidx ) : int

Finds the index of the first digit and starts from the index specified.

IndexOfIgnoreCase ( string src, string cmp ) : int

Finds the start index of the comparison string regards of case.

IndexOfNonDigit ( string str ) : int

Finds the index of the first non digit.

IndexOfNonDigit ( string str, int startidx ) : int

Finds the index of the first non digit and starts from the index specified.

IsBlank ( string val ) : bool

Checks if a String is whitespace, empty ("") or null.

 StringUtil.IsBlank(null)      = true StringUtil.IsBlank("")        = true StringUtil.IsBlank(" ")       = true StringUtil.IsBlank("bob")     = false StringUtil.IsBlank("  bob  ") = false 

IsEmpty ( string value ) : bool

Determines if a string is empty. Empty is defined as null or empty string.

 StringUtil.IsEmpty(null)     = true StringUtil.IsEmpty("")       = true StringUtil.IsEmpty(" ")      = false StringUtil.IsEmpty("bob")    = false StringUtil.IsEmpty(" bob ")  = false 

IsNotBlank ( string val ) : bool

Checks if a String is not empty (""), not null and not whitespace only.

 StringUtil.IsNotBlank(null)      = false StringUtil.IsNotBlank("")        = false StringUtil.IsNotBlank(" ")       = false StringUtil.IsNotBlank("bob")     = true StringUtil.IsNotBlank("  bob  ") = true 

IsNotEmpty ( string val ) : bool

Determines if a string is not empty. Its the exact opposite for #IsEmpty(String).

IsTrue ( string val ) : bool
IsWhitespace ( char ch ) : bool

Determine if this is a white space character. Whitespace characters are defined as the character ' ' and the tab character.

NewGuardedString ( char val ) : GuardedString

Constructs a secure string from a char []. The char[] will be cleared out when finished.

ParseLine ( string line, char fsep, char tqul ) : IList

Parses a line into a List of strings.

RandomString ( ) : string

Create a random Unicode string.

RandomString ( Random r ) : string

Create a random length Unicode string based on the Random object passed in.

RandomString ( Random random, int length ) : string

Create a random string of fixed length based on the Random object passed in. Insure that the string is built w/ Unicode characters.

ReplaceVariable ( string o, string variable, string val ) : string

Simple variable replacement internally using regular expressions.

 String o = "Some string with a ${variable} in it." String n = replaceVariable(o, "variable", "something"); String r = "Some string with a something in it" assert r.equals(n); 

StripNewlines ( string src ) : string

Removes newline characters (0x0a and 0x0d) from a string.

StripXmlAttribute ( string src, string attrName ) : string

Removes the attribute from the source string and returns.

StripXmlComments ( string src ) : string

Strip XML comments.

SubDigitString ( string str ) : string

Return the string of digits from string.

SubDigitString ( string str, int idx ) : string

Return the string of digits from string.

Method Details

EndsWith() public static method

Determines if the string parameter 'str' ends with the character value.
public static EndsWith ( string str, char value ) : bool
str string /// String to check for the character at the end.
value char /// The character to look for at the end of the string.
return bool

IndexOf() public static method

public static IndexOf ( string src, char ch ) : int
src string
ch char
return int

IndexOf() public static method

public static IndexOf ( string src, char ch, int idx ) : int
src string
ch char
idx int
return int

IndexOfDigit() public static method

Finds the index of the first digit.
public static IndexOfDigit ( string str ) : int
str string /// String to seach for a digit.
return int

IndexOfDigit() public static method

Finds the index of the first digit and starts from the index specified.
public static IndexOfDigit ( string str, int startidx ) : int
str string /// String to search for a digit.
startidx int /// Starting index from which to search
return int

IndexOfIgnoreCase() public static method

Finds the start index of the comparison string regards of case.
public static IndexOfIgnoreCase ( string src, string cmp ) : int
src string /// String to search.
cmp string /// Comparsion string to find.
return int

IndexOfNonDigit() public static method

Finds the index of the first non digit.
public static IndexOfNonDigit ( string str ) : int
str string /// String to seach for a non digit.
return int

IndexOfNonDigit() public static method

Finds the index of the first non digit and starts from the index specified.
public static IndexOfNonDigit ( string str, int startidx ) : int
str string /// String to seach for a non digit.
startidx int /// Starting index from which to search.
return int

IsBlank() public static method

Checks if a String is whitespace, empty ("") or null.
 StringUtil.IsBlank(null)      = true StringUtil.IsBlank("")        = true StringUtil.IsBlank(" ")       = true StringUtil.IsBlank("bob")     = false StringUtil.IsBlank("  bob  ") = false 
public static IsBlank ( string val ) : bool
val string /// the String to check, may be null ///
return bool

IsEmpty() public static method

Determines if a string is empty. Empty is defined as null or empty string.
 StringUtil.IsEmpty(null)     = true StringUtil.IsEmpty("")       = true StringUtil.IsEmpty(" ")      = false StringUtil.IsEmpty("bob")    = false StringUtil.IsEmpty(" bob ")  = false 
public static IsEmpty ( string value ) : bool
value string
return bool

IsNotBlank() public static method

Checks if a String is not empty (""), not null and not whitespace only.
 StringUtil.IsNotBlank(null)      = false StringUtil.IsNotBlank("")        = false StringUtil.IsNotBlank(" ")       = false StringUtil.IsNotBlank("bob")     = true StringUtil.IsNotBlank("  bob  ") = true 
public static IsNotBlank ( string val ) : bool
val string /// the String to check, may be null ///
return bool

IsNotEmpty() public static method

Determines if a string is not empty. Its the exact opposite for #IsEmpty(String).
public static IsNotEmpty ( string val ) : bool
val string /// string to evaluate.
return bool

IsTrue() public static method

public static IsTrue ( string val ) : bool
val string
return bool

IsWhitespace() public static method

Determine if this is a white space character. Whitespace characters are defined as the character ' ' and the tab character.
public static IsWhitespace ( char ch ) : bool
ch char
return bool

NewGuardedString() public static method

Constructs a secure string from a char []. The char[] will be cleared out when finished.
public static NewGuardedString ( char val ) : GuardedString
val char The characters to use. Will be cleared /// out.
return GuardedString

ParseLine() public static method

Parses a line into a List of strings.
public static ParseLine ( string line, char fsep, char tqul ) : IList
line string /// String to parse.
fsep char /// Field separator
tqul char /// Text qualifier.
return IList

RandomString() public static method

Create a random Unicode string.
public static RandomString ( ) : string
return string

RandomString() public static method

Create a random length Unicode string based on the Random object passed in.
public static RandomString ( Random r ) : string
r System.Random
return string

RandomString() public static method

Create a random string of fixed length based on the Random object passed in. Insure that the string is built w/ Unicode characters.
public static RandomString ( Random random, int length ) : string
random System.Random /// used to get random unicode characters.
length int /// fixed length of string.
return string

ReplaceVariable() public static method

Simple variable replacement internally using regular expressions.
 String o = "Some string with a ${variable} in it." String n = replaceVariable(o, "variable", "something"); String r = "Some string with a something in it" assert r.equals(n); 
/// if o is null, var is blank, or val is null.
public static ReplaceVariable ( string o, string variable, string val ) : string
o string /// Original string to do the replacement on.
variable string /// String representation of the variable to replace.
val string /// Value to replace the variable with.
return string

StripNewlines() public static method

Removes newline characters (0x0a and 0x0d) from a string.
public static StripNewlines ( string src ) : string
src string
return string

StripXmlAttribute() public static method

Removes the attribute from the source string and returns.
public static StripXmlAttribute ( string src, string attrName ) : string
src string
attrName string
return string

StripXmlComments() public static method

Strip XML comments.
public static StripXmlComments ( string src ) : string
src string
return string

SubDigitString() public static method

Return the string of digits from string.
public static SubDigitString ( string str ) : string
str string /// Source string to search.
return string

SubDigitString() public static method

Return the string of digits from string.
public static SubDigitString ( string str, int idx ) : string
str string /// Source string to search.
idx int /// Start index from which to search.
return string