Namespace: Consultingwerk.Util
Class 
StringHelper Copy to Clipboard
Parent classes:
Inherits: Progress.Lang.Object

File:StringHelper
Purpose:Routines to support string (CHARACTER) operations
Author(s):Mike Fechner / Consultingwerk Ltd.
Created:Wed Oct 24 12:34:34 CEST 2012



Top Method Summary
Options Name Purpose
+ CHARACTER CamelCaseWord (character) CamelCases a single word
+ CHARACTER CamelCaseWords (character) CamelCases a string from "Camel case" to "CamelCase"
+ CHARACTER CamelCaseWords2 (character) CamelCases a string from "Camel case" to "CamelCase"
+ CHARACTER CapitalizeFirstLetter (character) Capitalizes the first letter of a given string
+ LOGICAL ContainsAnyStringOf (longchar, character[]) Returns true when the source string contains at least one of the target strings
+ INTEGER CountOccurencesOf (character, character) Counts the occurences of the given target string in the source string
+ LOGICAL Ends (character, character) Returns TRUE when the given source string ends in the ending string
+ INTEGER FindClosingBracket (longchar, integer) Returns the position of the closing bracket for the bracket opened at the given position in the String
+ INTEGER FindClosingComment (longchar, integer) Returns the position of the closing comment for the comment opened at the given position in the String
+ INTEGER FindClosingQuote (longchar, integer) Returns the position of the closing quote sign (either " or ') in a String
+ CHARACTER FirstNonEmptyString (character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character, character, character) Returns the first non empty string of the parameter list
+ CHARACTER FirstNonEmptyString (character[]) Returns the first non empty string of the provided array
+ INTEGER FirstOccurenceOf (character, character) Returns the first position of any of the given characters in the source string
+ INTEGER FirstOccurenceOf (character, character, integer) Returns the first position of any of the given characters in the source string
+ LONGCHAR FixLineEnding (longchar) Fixes the line ending characters of the given longchar
+ CHARACTER GenerateUuid () Returns the CHARACTER representation of a new UUID
+ CHARACTER Indent (character, integer) Indents a string by inserting a SPACE character at the beginning of every line
+ CHARACTER Indent (longchar, integer) Indents a string by inserting a SPACE character at the beginning of every line
+ CHARACTER Insert (character, integer, character) Inserts a string into another string at a give position
+ LONGCHAR Insert (longchar, integer, character) Inserts a string into another string at a give position
+ LOGICAL IsLowercaseCharacter (character) Returns true when the given character is UPPERCASE
+ LOGICAL IsUppercaseCharacter (character) Returns true when the given character is UPPERCASE
+ INTEGER NextNonWhiteSpaceCharacter (longchar) Returns position of the next non whispace character
+ INTEGER NextNonWhiteSpaceCharacter (longchar, integer) Returns position of the next non whispace character
+ LONGCHAR PrefixLines (longchar, character) Prefixes every line in the given LONGCHAR with a given CHARACTR
+ Consultingwerk.Framework.Collections.CharacterList QuoteAndBracketSafeEntriesToList (character) Returns an CharacterList of the Entries in a delimited String
+ Consultingwerk.Framework.Collections.CharacterList QuoteAndBracketSafeEntriesToList (character, character) Returns an CharacterList of the Entries in a delimited String
+ Consultingwerk.Framework.Collections.CharacterList QuoteSafeEntriesToList (character) Returns an CharacterList of the Entries in a delimited String
+ Consultingwerk.Framework.Collections.CharacterList QuoteSafeEntriesToList (character, character) Returns an CharacterList of the Entries in a delimited String
+ CHARACTER RemovePrefix (character, character) Removes the given prefix at the beginning of the passed in String
+ CHARACTER RemoveSuffix (character, character) Removes the given suffix at the beginning of the passed in String
+ CHARACTER Unquote (character) Removes quotes from a Character String
+ LONGCHAR Unquote (longchar) Removes quotes from a Longchar String
+ CHARACTER UrlEncode (character, character) Encodes unsafe characters in a URL as per RFC 1738 section 2.2. http://ds.internic.net/rfc/rfc1738.txt
+ CHARACTER WellFormFromCamelCase (character) Turns a CamelCased string into a well formed sentence (Camel Cased)

Top Constructor Summary
Options Name Purpose
# StringHelper () Disallow instance creation


Method Detail
Top

PUBLIC CHARACTER CamelCaseWord (character)

Purpose: CamelCases a single word
Notes: Does support standard letters (ASCII only), no Umlaute

Parameters:
pcWord CHARACTER
The string containing a single word to camelcase
Returns CHARACTER
The CamelCased version of the word
Top

PUBLIC CHARACTER CamelCaseWords (character)

Purpose: CamelCases a string from "Camel case" to "CamelCase"
Notes: Does support standard letters (ASCII only), no Umlaute

Parameters:
pcString CHARACTER
The string containing a single word to camelcase
Returns CHARACTER
The CamelCased version of the string
Top

PUBLIC CHARACTER CamelCaseWords2 (character)

Purpose: CamelCases a string from "Camel case" to "CamelCase"
Notes: Does support standard letters (ASCII only), no Umlaute
This version of CamelCaseWords does only enforece uppercase on the
first letter of each word and does not change the case of any other
character - so existing upper case chars stay upper case (which is
different from the method CamelCaseWords)

Parameters:
pcString CHARACTER
The string containing a single word to camelcase
Returns CHARACTER
The CamelCased version of the string
Top

PUBLIC CHARACTER CapitalizeFirstLetter (character)

Purpose: Capitalizes the first letter of a given string
Notes:

Parameters:
pcString CHARACTER
The string in which to capitalize the first letter
Returns CHARACTER
The string with the first letter capitalized
Top

PUBLIC LOGICAL ContainsAnyStringOf (longchar, character[])

Purpose: Returns true when the source string contains at least one of the target strings
Notes:

Parameters:
pcSourceString LONGCHAR
The string to locate the target strings in
pcTargetStrings CHARACTER
The array of strings to locate in the target string
Returns LOGICAL
Logical value indicating if the source string contains at least on of the target strings
Top

PUBLIC INTEGER CountOccurencesOf (character, character)

Purpose: Counts the occurences of the given target string in the source string
Notes: Does ignore occurences within quotes

Parameters:
pcTargetString CHARACTER
The string to count in the pcSourceString
pcSourceString CHARACTER
The string to count in
Returns INTEGER
The number of occurences of the target string within the source string excluding occurences in quotes
Top

PUBLIC LOGICAL Ends (character, character)

Purpose: Returns TRUE when the given source string ends in the ending string
Notes: Equivalint to the ABL BEGINS operator / function

Parameters:
pcSourceString CHARACTER
The source string to check if it ends with the ending string
pcEndingString CHARACTER
The string to check if the source string ends with
Returns LOGICAL
Logical value indicating if the given source string ends in the ending string
Top

PUBLIC INTEGER FindClosingBracket (longchar, integer)

Purpose: Returns the position of the closing bracket for the bracket opened
at the given position in the String
Notes: Ignores brackets that are within a quote
Throws: Consultingwerk.Exceptions.UnmatchedBracketException, Consultingwerk.Exceptions.InvalidParameterValueException

Parameters:
pcString LONGCHAR
The LONGCHAR string to locate the closing bracket in
piPosition INTEGER
The position of the opening bracket in the string
Returns INTEGER
The position of the closing quote
Top

PUBLIC INTEGER FindClosingComment (longchar, integer)

Purpose: Returns the position of the closing comment for the comment opened
at the given position in the String
Notes: Returns the position of a / of the comment terminator star slash,
Comments in quotes are ignored, it is however expected that the
opening comment is not inside a quote
Throws: Consultingwerk.Exceptions.UnmatchedCommentException, Consultingwerk.Exceptions.InvalidParameterValueException

Parameters:
pcString LONGCHAR
The LONGCHAR string to locate the closing bracket in
piPosition INTEGER
The position of the opening bracket in the string
Returns INTEGER
The position of the closing quote
Top

PUBLIC INTEGER FindClosingQuote (longchar, integer)

Purpose: Returns the position of the closing quote sign (either " or ') in a String
Notes:
Throws: Consultingwerk.Exceptions.UnmatchedQuoteException, Consultingwerk.Exceptions.InvalidParameterValueException

Parameters:
pcString LONGCHAR
The LONGCHAR string to locate the closing quote in
piPosition INTEGER
The position of the opening quote in the string
Returns INTEGER
The position of the closing quote
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
pcString6 CHARACTER
The sixth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
pcString6 CHARACTER
The sixth string
pcString7 CHARACTER
The seventh string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
pcString6 CHARACTER
The sixth string
pcString7 CHARACTER
The seventh string
pcString8 CHARACTER
The eigth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
pcString6 CHARACTER
The sixth string
pcString7 CHARACTER
The seventh string
pcString8 CHARACTER
The eigth string
pcString9 CHARACTER
The nineth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character, character, character, character, character, character, character, character, character, character)

Purpose: Returns the first non empty string of the parameter list
Notes:

Parameters:
pcString1 CHARACTER
The first string
pcString2 CHARACTER
The second string
pcString3 CHARACTER
The third string
pcString4 CHARACTER
The fourth string
pcString5 CHARACTER
The fifth string
pcString6 CHARACTER
The sixth string
pcString7 CHARACTER
The seventh string
pcString8 CHARACTER
The eigth string
pcString9 CHARACTER
The nineth string
pcString10 CHARACTER
The tenth string
Returns CHARACTER
The first non empty string of the parameter list
Top

PUBLIC CHARACTER FirstNonEmptyString (character[])

Purpose: Returns the first non empty string of the provided array
Notes:

Parameters:
pcStrings CHARACTER
The first string
Returns CHARACTER
The first non empty string of the array
Top

PUBLIC INTEGER FirstOccurenceOf (character, character)

Purpose: Returns the first position of any of the given characters in the
source string
Notes: Returns 0 when none of the characters can be found

Parameters:
pcSourceString CHARACTER
The source string
pcCharacters CHARACTER
The comma-delimited list of characters
Returns INTEGER
The first position of any of the given characters
Top

PUBLIC INTEGER FirstOccurenceOf (character, character, integer)

Purpose: Returns the first position of any of the given characters in the
source string
Notes: Returns 0 when none of the characters can be found

Parameters:
pcSourceString CHARACTER
The source string
pcCharacters CHARACTER
The comma-delimited list of characters
piStarting INTEGER
An integer that specifies at which left-most position in the string to start the search
Returns INTEGER
The first position of any of the given characters
Top

PUBLIC LONGCHAR FixLineEnding (longchar)

Purpose: Fixes the line ending characters of the given longchar
Notes: Line Ending will be set to Consultingwerk.Environment:NewLine

Parameters:
plcString LONGCHAR
The Longchar to fix the line ending at
Returns LONGCHAR
The Longchar value with the fixed line ending characters
Top

PUBLIC CHARACTER GenerateUuid ()

Purpose: Returns the CHARACTER representation of a new UUID
Notes:

Returns CHARACTER
The CHARACTER representation of the new UUID
Top

PUBLIC CHARACTER Indent (character, integer)

Purpose: Indents a string by inserting a SPACE character at the beginning
of every line
Notes:

Parameters:
pcString CHARACTER
The string to indent
piIndent INTEGER
The number of characters to indent the string
Returns CHARACTER
The indented string
Top

PUBLIC CHARACTER Indent (longchar, integer)

Purpose: Indents a string by inserting a SPACE character at the beginning
of every line
Notes:

Parameters:
plcString LONGCHAR
The string to indent
piIndent INTEGER
The number of characters to indent the string
Returns CHARACTER
The indented string
Top

PUBLIC CHARACTER Insert (character, integer, character)

Purpose: Inserts a string into another string at a give position
Notes:

Parameters:
pcSourceString CHARACTER
The source string, into which you want to insert another string
piPosition INTEGER
The position at which you want to insert the target string
pcTargetString CHARACTER
The target string, which will be inserted into the source string
Returns CHARACTER
The Source String with the Target string inserted
Top

PUBLIC LONGCHAR Insert (longchar, integer, character)

Purpose: Inserts a string into another string at a give position
Notes:

Parameters:
pcSourceString LONGCHAR
The source string, into which you want to insert another string
piPosition INTEGER
The position at which you want to insert the target string
pcTargetString CHARACTER
The target string, which will be inserted into the source string
Returns LONGCHAR
The Source String with the Target string inserted
Top

PUBLIC LOGICAL IsLowercaseCharacter (character)

Purpose: Returns true when the given character is UPPERCASE
Notes:

Parameters:
pcCharacter CHARACTER
The character to test
Returns LOGICAL
True when the given character is UPPERCASE
Top

PUBLIC LOGICAL IsUppercaseCharacter (character)

Purpose: Returns true when the given character is UPPERCASE
Notes:

Parameters:
pcCharacter CHARACTER
The character to test
Returns LOGICAL
True when the given character is UPPERCASE
Top

PUBLIC INTEGER NextNonWhiteSpaceCharacter (longchar)

Purpose: Returns position of the next non whispace character
Notes: Returns the starting position, when that's not a white space

Parameters:
pcSourceString LONGCHAR
The string to search in
Returns INTEGER
The position of the next non white space character
Top

PUBLIC INTEGER NextNonWhiteSpaceCharacter (longchar, integer)

Purpose: Returns position of the next non whispace character
Notes: Returns the starting position, when that's not a white space, returns ?
when no non whitespace character was found

Parameters:
pcSourceString LONGCHAR
The string to search in
piStartingPosition INTEGER
The position to start searching at
Returns INTEGER
The position of the next non white space character
Top

PUBLIC LONGCHAR PrefixLines (longchar, character)

Purpose: Prefixes every line in the given LONGCHAR with a given CHARACTR
Notes: Useful for formatted log-file output

Parameters:
plcLongchar LONGCHAR
The source LONGCHAR value
pcPrefix CHARACTER
The prefix to add to each line from the source LONGCHAR
Returns LONGCHAR
The new LONGCHAR value
Top

PUBLIC Consultingwerk.Framework.Collections.CharacterList QuoteAndBracketSafeEntriesToList (character)

Purpose: Returns an CharacterList of the Entries in a delimited String
Notes: This method is similar to the ABL ENTRY/NUM-ENTRIES functions, but
does consider " or ' and ( ) when parsing the string

Parameters:
pcString CHARACTER
The delimited string
Returns Consultingwerk.Framework.Collections.CharacterList
The CharacterList with the entries from the source delimited string
Top

PUBLIC Consultingwerk.Framework.Collections.CharacterList QuoteAndBracketSafeEntriesToList (character, character)

Purpose: Returns an CharacterList of the Entries in a delimited String
Notes: This method is similar to the ABL ENTRY/NUM-ENTRIES functions, but
does consider " or ' and ( ) when parsing the string

Parameters:
pcString CHARACTER
The delimited string
pcDelimiter CHARACTER
The string delimiter (single char)
Returns Consultingwerk.Framework.Collections.CharacterList
The CharacterList with the entries from the source delimited string
Top

PUBLIC Consultingwerk.Framework.Collections.CharacterList QuoteSafeEntriesToList (character)

Purpose: Returns an CharacterList of the Entries in a delimited String
Notes: This method is similar to the ABL ENTRY/NUM-ENTRIES functions, but
does consider " or ' when parsing the string

Parameters:
pcString CHARACTER
The delimited string
Returns Consultingwerk.Framework.Collections.CharacterList
The CharacterList with the entries from the source delimited string
Top

PUBLIC Consultingwerk.Framework.Collections.CharacterList QuoteSafeEntriesToList (character, character)

Purpose: Returns an CharacterList of the Entries in a delimited String
Notes: This method is similar to the ABL ENTRY/NUM-ENTRIES functions, but
does consider " or ' when parsing the string

Parameters:
pcString CHARACTER
The delimited string
pcDelimiter CHARACTER
The string delimiter (single char)
Returns Consultingwerk.Framework.Collections.CharacterList
The CharacterList with the entries from the source delimited string
Top

PUBLIC CHARACTER RemovePrefix (character, character)

Purpose: Removes the given prefix at the beginning of the passed in String
Notes: When the String does not begin with the prefix, the original string
is returned

Parameters:
pcSourceString CHARACTER
The source string to remove the prefix from
pcPrefixString CHARACTER
The prefix to remove from the source string
Returns CHARACTER
The resulting strging without the prefix
Top

PUBLIC CHARACTER RemoveSuffix (character, character)

Purpose: Removes the given suffix at the beginning of the passed in String
Notes: When the String does not begin with the suffix, the original string
is returned

Parameters:
pcSourceString CHARACTER
The source string to remove the suffix from
pcSuffixString CHARACTER
The suffix to remove from the source string
Returns CHARACTER
The resulting strging without the suffix
Top

PUBLIC CHARACTER Unquote (character)

Purpose: Removes quotes from a Character String
Notes:

Parameters:
pcString CHARACTER
The source string to remove quotes
Returns CHARACTER
The string without the quotes
Top

PUBLIC LONGCHAR Unquote (longchar)

Purpose: Removes quotes from a Longchar String
Notes:

Parameters:
pcString LONGCHAR
The source string to remove quotes
Returns LONGCHAR
The string without the quotes
Top

PUBLIC CHARACTER UrlEncode (character, character)

Purpose: Encodes unsafe characters in a URL as per RFC 1738 section 2.2.
http://ds.internic.net/rfc/rfc1738.txt
Notes: See Progress K-Base 000042261, http://knowledgebase.progress.com/articles/Article/000042261

Parameters:
pcValue CHARACTER
Character string to encode
pcEnctype CHARACTER
Encoding option where "query", "cookie", "default" or any specified string of characters are valid
Returns CHARACTER
Encoded string (unkown value is returned as blank)
Top

PUBLIC CHARACTER WellFormFromCamelCase (character)

Purpose: Turns a CamelCased string into a well formed sentence (Camel Cased)
Notes:

Parameters:
pcSource CHARACTER
The source String
Returns CHARACTER
The well formed string


Constructor Detail
Top

PROTECTED StringHelper ()

Purpose: Disallow instance creation
Notes:



©2006-2016 Consultingwerk Ltd.         info@consultingwerk.de         http://www.consultingwerk.de       26.08.2016 08:46:51