Package ucar.unidata.util
Class StringUtil
java.lang.Object
ucar.unidata.util.StringUtil
String utilities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic boolean
debug flagstatic final String[]
Ordinal names for images -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuffer
append
(StringBuffer sb, Object s1) A utility method to an append to a StringBuffer.static StringBuffer
append
(StringBuffer sb, Object s1, Object s2) A utility method to do multiple appends to a StringBuffer.static StringBuffer
append
(StringBuffer sb, Object s1, Object s2, Object s3) A utility method to do multiple appends to a StringBuffer.static StringBuffer
A utility method to do multiple appends to a StringBuffer.static StringBuffer
A utility method to do multiple appends to a StringBuffer.static String
applyMacros
(String s, Hashtable props, boolean throwError) This takes a string of the following form.static String
Convert the given text to html by adding <br>.static String
breakTextAtWords
(String text, String insert, int lineSize) Break the given text into lines, respecting word boundaries (blank space).static String
Camel case a string (eg howard -> Howard)static String
Collapse continuous whitespace into one single " ".static boolean
containsRegExp
(String patternString) See if a pattern string contains regular expression characters (^,*,$,+).static String
Escape any char not alphanumeric or in okChars.static List
expandIso8601
(String time) A first attempt at parsing a dttm range stringstatic String
findFormatString
(String macroName, String macroDelimiter, String text) Return the format string in the given text for the given macro.static Object
Run through the List of Objects and return the Object whose toString matches the source string.static Object
Run through the List of patterns (pattern, result) and return corresponding result whose pattern matches the source string.static String
findPattern
(String source, String patternString) Find the pattern in a stringstatic String
Get "a" or "an" for prefixing to a string based on the first characterstatic String
ignoreescape
(String x, String okChars) static boolean
Return true if all characters are numeric.static boolean
Is the string all lower case?static boolean
Is the string all upper case?static String
Merge the given strings, using a space between each.static String
Merge the given strings, using the given delimiter between each.static String
Merge the given strings, using the given delimiter between each.static String
Merge the given strings, using the given delimiter between each.static String
Merge the given strings, using the given delimiter between each.static String
listToString
(List l) Take the List of objects and return a String of all the list's elements toString values appended to each other, separated by semicolonsstatic String[]
listToStringArray
(List objectList) Take the List of objects and return a String array of the toString values of each object in the list.static void
static void
Method for debugging.static void
teststatic String
makeValidCdmObjectName
(String name) static int
Count number of chars that match in two strings, starting from front.static boolean
Check if the string is not emptystatic String
Pad the given string with spaces on the left up to the given length.static String
Pad the given string with padString on the left up to the given length.static String
Pad the given string with spaces on the right up to the given length.static String
Pad the given string with padString on the right up to the given length.static String
padZero
(int value, int numDigits) Left pad the given value with zeros up to the number of digitsstatic double[][]
parseCoordinates
(String coords) Parse the lat/lon/alt coordinate stringstatic List
Parse a comma separated value (CVS) Stringstatic Date
Parse the date.static List
Parse the given string and return a list of flost values.static Hashtable
Parse HTML Propertiesstatic List
Parse the given string and return a list of Integer values.static Date
parseIso8601
(String time) Not working yet but this is supposed to parse an iso8601 date formatparseLineWords
(String content, int[] indices, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) This splits the given content String into a set of lines (delimited by the given lineDelimiter).parseLineWords
(String content, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) This splits the given content String into a set of lines (delimited by the given lineDelimiter).static Hashtable
Parse the semi-colon delimited string of name=value properties.static long
Note, right now this just parses the hour/minute/second periodsstatic String
Replace special characters with entities for HTML content.static String
Replace special characters with entities for XML attributes.static String
Replace special characters with entities for XML attributes.static boolean
regexpMatch
(String input, String patternString) Match a regular expressionstatic String
removeWhitespace
(String inputString) Remove any whitespace (ie., Character.isWhitespace) from the input string.static String
Concatentate the given string cnt timesstatic void
replace
(StringBuffer sb, char out, String in) Replace any char "out" in sb with "in".static String
Replace all occurences of replaceChar with replaceWithstatic String
Replace any char "out" in s with "in".static String
Replaces all occurrences of "pattern" in "string" with "value"static String
replaceDate
(String s, String macroName, Date date) Replace the macro within s with the formatted date.static String
Replace the macro within s with the formatted date.static String
replaceDate
(String s, String macroName, Date date, String macroPrefix, String macroSuffix, TimeZone timeZone) Replace the macro within s with the formatted date.static String
replaceDate
(String s, String macroName, Date date, TimeZone timeZone) Replace the macro within s with the formatted date.static String
replaceList
(String v, String[] patterns, String[] values) Replaces all occurrences of "patterns" in "v" with "values"static String
replaceList
(String v, List patterns, List values) Replaces all occurrences of "patterns" in "v" with "values"static List
replaceList
(List sourceList, String[] patterns, String[] values) Construct and return a list of Strings where each string is the result of replacing all of the patterns with the corresponding values for each String in the given sourceList .static final String
Shorten a string using elipses (...)Tokenize the toString value of the given source object, splitting on ",".Tokenize the toString value of the given source object, splitting on the given delimiter.Tokenize the toString value of the given source object, splitting on the given delimiter.Tokenize the toString value of the given source object, splitting on the given delimiter.static String[]
Split the given string into the first cnt number of substrings as delimited by the given delimiter.This parses the given string with the following form.static String[]
splitString
(String source) Split a string on one or more whitespace.Split up to a certain number of characterstokenize the given string on spaces.static boolean
startsWithVowel
(String value) Check to see if the string starts with a vowel.static void
string_Sort
(String[] my_arr, int substart, int subend) sort a string array by comparing the sub stringstatic boolean
stringMatch
(String input, String patternString) Check if the given input String matches the given pattern String.static boolean
stringMatch
(String input, String patternString, boolean substring, boolean caseSensitive) Check if the given input String matches the given pattern String.static String
stripAndReplace
(String s, String pattern1, String pattern2, String replace) Replaces all occurrences of the strings delimited by patter1/pattern2 with replace, e.g.: "pattern1 ...static String
stripHtmlTag
(String html) Remove any beginning or ending <html> tagsstatic String
Remove all text contained within "< >" tags.static void
substitute
(StringBuffer sbuff, String match, String subst) Find all occurences of the "match" in original, and substitute the "subst" string, directly into the original.static String
substitute
(String original, String[] match, String[] subst) Find all occurences of match strings in original, and substitute the corresponding subst string.static String
substitute
(String original, String match, String subst) Find all occurences of the "match" in original, and substitute the "subst" string.static String
toHexString
(Color c) Convert the given color to is string hex representationstatic String
Create a string representation of the given arraystatic List
Convert the list of objects to a list of strings.static String
Reverse XML quoting to recover the original string.static String
Reverse XML quoting to recover the original string.static void
unreplace
(StringBuffer sb, String out, char in) Replace any String "out" in sb with char "in".static String
Replace all occurences of orgReplace with orgChar; inverse of replace().static String
wildcardToRegexp
(String wildcard) Change a wildcard expression to a proper regular expressionstatic String
zeroString
(int value) If the given value is less than 10 than pad the String return with a leading "0".
-
Field Details
-
debug
public static boolean debugdebug flag -
ordinalNames
Ordinal names for images
-
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
notEmpty
Check if the string is not empty- Parameters:
s
- String to check- Returns:
- true if it's not the empty string (len > 0)
-
collapseWhitespace
Collapse continuous whitespace into one single " ".- Parameters:
s
- operate on this string- Returns:
- result with collapsed whitespace
-
findFormatString
Return the format string in the given text for the given macro. text may contain a macro of the form 'macroDelimiter macroName:format string macroDelimiter' e.g.: %count:some format% This returns the format string- Parameters:
macroName
- The name of the macromacroDelimiter
- The delimiter used. e.g. '%'text
- the text- Returns:
- the format string or null
-
substitute
Find all occurences of the "match" in original, and substitute the "subst" string.- Parameters:
original
- starting stringmatch
- string to matchsubst
- string to substitute- Returns:
- a new string with substitutions
-
repeat
Concatentate the given string cnt times- Parameters:
s
- base stringcnt
-- Returns:
- repeated string
-
substitute
Find all occurences of match strings in original, and substitute the corresponding subst string.- Parameters:
original
- starting stringmatch
- array of strings to matchsubst
- array of strings to substitute- Returns:
- a new string with substitutions
-
substitute
Find all occurences of the "match" in original, and substitute the "subst" string, directly into the original.- Parameters:
sbuff
- starting string buffermatch
- string to matchsubst
- string to substitute
-
isDigits
Return true if all characters are numeric.- Parameters:
s
- operate on this String- Returns:
- true if all characters are numeric
-
quoteHtmlContent
Replace special characters with entities for HTML content. special: 'invalid input: '&'', '"', '\'', 'invalid input: '<'', '>', '\n'- Parameters:
x
- string to quote- Returns:
- equivilent string using entities for any special chars
-
quoteXmlContent
Replace special characters with entities for XML attributes. special: 'invalid input: '&'', 'invalid input: '<'', '>', '\'', '"', '\r', '\n'- Parameters:
x
- string to quote- Returns:
- equivilent string using entities for any special chars
-
unquoteXmlContent
Reverse XML quoting to recover the original string.- Parameters:
x
- string to quote- Returns:
- equivilent string
-
quoteXmlAttribute
Replace special characters with entities for XML attributes. special: 'invalid input: '&'', 'invalid input: '<'', '>', '\'', '"', '\r', '\n'- Parameters:
x
- string to quote- Returns:
- equivilent string using entities for any special chars
-
unquoteXmlAttribute
Reverse XML quoting to recover the original string.- Parameters:
x
- string to quote- Returns:
- equivilent string
-
makeValidCdmObjectName
-
replace
Replace all occurences of replaceChar with replaceWith- Parameters:
x
- operate on this stringreplaceChar
- get rid of thesereplaceWith
- replace with these- Returns:
- resulting string
-
unreplace
Replace all occurences of orgReplace with orgChar; inverse of replace().- Parameters:
x
- operate on this stringorgReplace
- get rid of theseorgChar
- replace with these- Returns:
- resulting string
-
match
Count number of chars that match in two strings, starting from front.- Parameters:
s1
- compare this strings2
- compare this string- Returns:
- number of matching chars, starting from first char
-
replace
Replace any char "out" in sb with "in".- Parameters:
sb
- StringBuffer to replaceout
- repalce this characterin
- with this string
-
unreplace
Replace any String "out" in sb with char "in".- Parameters:
sb
- StringBuffer to replaceout
- repalce this Stringin
- with this char
-
replace
Replace any char "out" in s with "in".- Parameters:
s
- string to replaceout
- repalce this characterin
- with this string- Returns:
- modified string if needed
-
escape
Escape any char not alphanumeric or in okChars. Escape by replacing char with %xx (hex).- Parameters:
x
- escape this stringokChars
- these are ok.- Returns:
- equivilent escaped string.
-
ignoreescape
-
toHexString
Convert the given color to is string hex representation- Parameters:
c
- color- Returns:
- hex represenation
-
findMatch
Run through the List of Objects and return the Object whose toString matches the source string. If none found then return the dflt value.- Parameters:
source
- Source String to match on.patternList
- List of objects whose toString is the pattern.dflt
- The default if nothing matches.- Returns:
- The Object whose toString matches the source or the dflt if no matches found.
-
findMatch
Run through the List of patterns (pattern, result) and return corresponding result whose pattern matches the source string. If none found then return the dflt.- Parameters:
source
- Source String to match on.patternList
- List of objects whose toString is the pattern.results
- The list of return objects.dflt
- The default if nothing matches.- Returns:
- The return Object whose toString matches the source or the dflt if no matches found.
-
containsRegExp
See if a pattern string contains regular expression characters (^,*,$,+).- Parameters:
patternString
- pattern string to check- Returns:
- true if it contains (^,*,$,+).
-
stringMatch
Check if the given input String matches the given pattern String. First see if input.equals (patternString). If true then return true. Next if there are no regular expression characters (look for ^, $, *, and +) in the patternString then return false. Else treat the patternString as a regexp and return if it matches the input.- Parameters:
input
- The input source string.patternString
- The regular expression pattern.- Returns:
- true if the pattern match the input.
-
stringMatch
public static boolean stringMatch(String input, String patternString, boolean substring, boolean caseSensitive) Check if the given input String matches the given pattern String. First see if input.equals (patternString). If true then return true. Next, if the pattern string is a simple "*" or begins with a "*" or starts with the prefix "glob:" then is is a glob style pattern and we convert it to a regexp. Next if there are no regular expression characters (look for ^, $, *, and +) in the patternString then return false. Else treat the patternString as a regexp and return if it matches the input.- Parameters:
input
- The input source string.patternString
- The regular expression pattern.substring
- Search for substringscaseSensitive
- Is case sensitive- Returns:
- true if the pattern match the input.
-
regexpMatch
Match a regular expression- Parameters:
input
- string to matchpatternString
- reg ex pattern string- Returns:
- true if a match
-
wildcardToRegexp
Change a wildcard expression to a proper regular expression- Parameters:
wildcard
- wildcard string (*, ?);- Returns:
- the corresponding regular expression
-
startsWithVowel
Check to see if the string starts with a vowel.- Parameters:
value
- String to check- Returns:
- true if value starts with a, e, i, o, or u (but not sometimes y). Check is case insensitive.
-
breakText
Convert the given text to html by adding <br>. If there are new lines then we replace them with a space. Then we break the lines into 50 character (or so) chunks, adding br tags.- Parameters:
text
- The text to convertinsert
- string to insertlineSize
- line size to insert at- Returns:
- The text with added br tags.
-
breakTextAtWords
Break the given text into lines, respecting word boundaries (blank space).- Parameters:
text
- The text to convertinsert
- break to insertlineSize
- line size to insert at- Returns:
- The text with added br tags.
-
stripHtmlTag
Remove any beginning or ending <html> tags- Parameters:
html
- the html- Returns:
- the stripped html
-
stripTags
Remove all text contained within "< >" tags.- Parameters:
html
- The source html string.- Returns:
- The raw text.
-
stripAndReplace
Replaces all occurrences of the strings delimited by patter1/pattern2 with replace, e.g.: "pattern1 ... pattern2"- Parameters:
s
- initial stringpattern1
- delimiter 1pattern2
- delimiter 2replace
- replace with- Returns:
- replaced string
-
removeWhitespace
Remove any whitespace (ie., Character.isWhitespace) from the input string.- Parameters:
inputString
- The string to remove the whitespace.- Returns:
- The whitespaceless result.
-
zeroString
If the given value is less than 10 than pad the String return with a leading "0".- Parameters:
value
- The value.- Returns:
- The String represenation of the value, padded with a leading "0" if value < 10
-
padZero
Left pad the given value with zeros up to the number of digits- Parameters:
value
- The value.numDigits
- number of digits- Returns:
- The String represenation of the value, padded with leading "0"-s if value < 10E(numDigits-1)
-
padLeft
Pad the given string with spaces on the left up to the given length.- Parameters:
s
- String to paddesiredLength
- ending length- Returns:
- padded String
-
padLeft
Pad the given string with padString on the left up to the given length.- Parameters:
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ")- Returns:
- padded String
-
padRight
Pad the given string with spaces on the right up to the given length.- Parameters:
s
- String to paddesiredLength
- ending length- Returns:
- padded String
-
padRight
Pad the given string with padString on the right up to the given length.- Parameters:
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ")- Returns:
- padded String
-
join
Merge the given strings, using a space between each.- Parameters:
args
- An array of Strings to merge.- Returns:
- The given strings concatenated together with a space between each.
-
join
Merge the given strings, using the given delimiter between each.- Parameters:
delimiter
- The delimiter.args
- An array of Strings to merge.- Returns:
- The given strings concatenated together with the delimiter between each.
-
join
Merge the given strings, using the given delimiter between each.- Parameters:
delimiter
- The delimiter.args
- An array of Strings to merge.ignoreEmptyStrings
- Don't join empty strings- Returns:
- The given strings concatenated together with the delimiter between each.
-
join
Merge the given strings, using the given delimiter between each.- Parameters:
delimiter
- The delimiter.args
- A List of objects whose toString value are merged.- Returns:
- The given object.toString values concatenated together with the delimiter between each.
-
join
Merge the given strings, using the given delimiter between each.- Parameters:
delimiter
- The delimiter.args
- A List of objects whose toString value are merged.ignoreEmptyStrings
- Should ignore empty strings- Returns:
- The given object.toString values concatenated together with the delimiter between each.
-
split
Tokenize the toString value of the given source object, splitting on ",".- Parameters:
source
- The source object string.- Returns:
- List of String tokens.
-
parseDate
Parse the date. Can be of a number of forms:yyyy-MM-dd HH:mm:ss z yyyy-MM-dd HH:mm:ss yyyy-MM-dd HH:mm yyyy-MM-dd yyyyMMddHHmmss yyyyMMddHHmm yyyyMMddHH yyyyMMdd
- Parameters:
dttm
- The date string- Returns:
- The Date or null if not able to parse it
-
parseIntegerListString
Parse the given string and return a list of Integer values. The String s is a comma separated list of integer values or integer ranges of the form start:end:stride where stride is optional. So s can be:1,2,3 - the numbers 1 2 and 3 0:10,15:20,30 - 0-10, 15-20 and 30 0:10:2 - 0,2,4,6,8,10
- Parameters:
s
- The string to parse- Returns:
- List of Integers
-
parseFloatListString
Parse the given string and return a list of flost values. So s can be:1.0,2.0,3.0 - the numbers 1.0 2.0 and 3.0
- Parameters:
s
- The string to parse- Returns:
- List of Integers
-
parseLineWords
public static List<String[]> parseLineWords(String content, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) This splits the given content String into a set of lines (delimited by the given lineDelimiter). If a line begins with the given commentString it is ignored. If the length of the trim value of the line is 0 it is ignored. If a line is not to be ignored then the substrings defined by the given fromIndices/toIndices are extracted, placed into a String array and added to the result List.- Parameters:
content
- The String to parselengths
- the length of each word.lineDelimiter
- What to split the line content string on (usually "\n").commentString
- If non-null defines the comment String in the content.trimWords
- Do we trim each word.- Returns:
- A list of String arrays that holds the words.
-
parseLineWords
public static List<String[]> parseLineWords(String content, int[] indices, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) This splits the given content String into a set of lines (delimited by the given lineDelimiter). If a line begins with the given commentString it is ignored. If the length of the trim value of the line is 0 it is ignored. If a line is not to be ignored then the substrings defined by the given fromIndices/toIndices are extracted, placed into a String array and added to the result List.- Parameters:
content
- The String to parseindices
- the index in the line which defines the word start.lengths
- the length of each word.lineDelimiter
- What to split the line content string on (usually "\n").commentString
- If non-null defines the comment String in the content.trimWords
- Do we trim each word.- Returns:
- A list of String arrays that holds the words.
-
splitString
Split a string on one or more whitespace. Cover for STring.split, because who can remember regexp?- Parameters:
source
- split this string- Returns:
- space-seperated tokens
-
split
Tokenize the toString value of the given source object, splitting on the given delimiter.- Parameters:
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.- Returns:
- List of String tokens.
-
split
Tokenize the toString value of the given source object, splitting on the given delimiter. If trim is true the string trim each token.- Parameters:
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.trim
- Do we string trim the tokens.- Returns:
- List of String tokens.
-
splitWithQuotes
tokenize the given string on spaces. Respect double quotes- Parameters:
s
- The string to tokenize- Returns:
- the list of tokens
-
split
public static List<String> split(Object source, String delimiter, boolean trim, boolean excludeZeroLength) Tokenize the toString value of the given source object, splitting on the given delimiter. If trim is true the string trim each token.- Parameters:
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.trim
- Do we string trim the tokens.excludeZeroLength
- If true then don't add in zero length strings.- Returns:
- List of String tokens.
-
split
Split the given string into the first cnt number of substrings as delimited by the given delimiter.- Parameters:
s
- String to splitdelimiter
- token delimetercnt
- max number of tokens- Returns:
- array of strings or
null
if unable to split the string.
-
splitUpTo
Split up to a certain number of characters- Parameters:
s
- the string to splitdelimiter
- the delimitercnt
- the max number- Returns:
- the list of split strings
-
replaceDate
Replace the macro within s with the formatted date. s can contain macros of the form ${macroName:some date format}- Parameters:
s
- source stringmacroName
- macro name_date
- date to use- Returns:
- formatted string
-
replaceDate
Replace the macro within s with the formatted date. s can contain macros of the form ${macroName:some date format}- Parameters:
s
- source stringmacroName
- macro name_date
- date to usetimeZone
- timezone for format- Returns:
- formatted string
-
replaceDate
public static String replaceDate(String s, String macroName, Date date, String macroPrefix, String macroSuffix) Replace the macro within s with the formatted date. s can contain macros of the formmacroName:some date format - Parameters:
s
- source stringmacroName
- macro name_date
- date to usemacroPrefix
- the macro prefixmacroSuffix
- the macro suffix- Returns:
- formatted string
-
replaceDate
public static String replaceDate(String s, String macroName, Date date, String macroPrefix, String macroSuffix, TimeZone timeZone) Replace the macro within s with the formatted date. s can contain macros of the formmacroName:some date format - Parameters:
s
- source stringmacroName
- macro namedate
- date to usemacroPrefix
- the macro prefixmacroSuffix
- the macro suffixtimeZone
- for the dates- Returns:
- formatted string
-
listToStringArray
Take the List of objects and return a String array of the toString values of each object in the list.- Parameters:
objectList
- The list of objects.- Returns:
- The array of the object string values.
-
listToString
Take the List of objects and return a String of all the list's elements toString values appended to each other, separated by semicolons- Parameters:
l
- list of objects- Returns:
- semicolon separated String of Strings.
-
toString
Convert the list of objects to a list of strings.- Parameters:
l
- List of objects- Returns:
- List of strings.
-
replace
Replaces all occurrences of "pattern" in "string" with "value"- Parameters:
string
- string to mungepattern
- pattern to replacevalue
- replacement value- Returns:
- munged string
-
replaceList
Replaces all occurrences of "patterns" in "v" with "values"- Parameters:
v
- original Stringpatterns
- patterns to matchvalues
- replacement values- Returns:
- munged String
-
replaceList
Replaces all occurrences of "patterns" in "v" with "values"- Parameters:
v
- original Stringpatterns
- patterns to matchvalues
- replacement values- Returns:
- munged String
-
replaceList
Construct and return a list of Strings where each string is the result of replacing all of the patterns with the corresponding values for each String in the given sourceList .- Parameters:
sourceList
- original list of Stringspatterns
- patterns to replacevalues
- replacement values- Returns:
- new list with replaced values
-
append
A utility method to an append to a StringBuffer. If the given object is null the string "null" will be appended. If non-null the we append to the StringBuffer the results of s1.toString ();- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- object to append- Returns:
- StringBuffer with appended object
-
append
A utility method to do multiple appends to a StringBuffer. If the given object is null the string "null" will be appended. If non-null then we append to the StringBuffer the results of sn.toString ();- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to append- Returns:
- StringBuffer with appended objects
-
append
A utility method to do multiple appends to a StringBuffer. If the given object is null the string "null" will be appended. If non-null then we append to the StringBuffer the results of sn.toString ();- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to append- Returns:
- StringBuffer with appended objects
-
append
A utility method to do multiple appends to a StringBuffer. If the given object is null the string "null" will be appended. If non-null then we append to the StringBuffer the results of sn.toString ();- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to append- Returns:
- StringBuffer with appended objects
-
append
public static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3, Object s4, Object s5) A utility method to do multiple appends to a StringBuffer. If the given object is null the string "null" will be appended. If non-null then we append to the StringBuffer the results of sn.toString ();- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to appends5
- fifth object to append- Returns:
- StringBuffer with appended objects
-
parseCsv
Parse a comma separated value (CVS) String- Parameters:
s
- String to parseskipFirst
- true to skip the first value- Returns:
- list of parsed Strings
-
shorten
Shorten a string using elipses (...)- Parameters:
s
- String to shortenlength
- shortened length where elipses will start- Returns:
- shortened string.
-
toString
Create a string representation of the given array- Parameters:
array
- array to print- Returns:
- array as a String
-
expandIso8601
A first attempt at parsing a dttm range string- Parameters:
time
- The time- Returns:
- List iof times
-
findPattern
Find the pattern in a string- Parameters:
source
- String to searchpatternString
- pattern- Returns:
- the String that matches
-
isUpperCase
Is the string all upper case?- Parameters:
s
- string to check- Returns:
- true if all uppercase
-
isLowerCase
Is the string all lower case?- Parameters:
s
- string to check- Returns:
- true if all characters are lowercase
-
camelCase
Camel case a string (eg howard -> Howard)- Parameters:
s
- string to camel case- Returns:
- the camel cased string
-
parseIso8601
Not working yet but this is supposed to parse an iso8601 date format- Parameters:
time
- date- Returns:
- date
-
parseTimePeriod
Note, right now this just parses the hour/minute/second periods- Parameters:
s
- The date string- Returns:
- The time
-
parsePropertiesString
Parse the semi-colon delimited string of name=value properties.- Parameters:
s
- Semi-colon delimited name=value string- Returns:
- properties
-
parseHtmlProperties
Parse HTML Properties- Parameters:
s
- the string- Returns:
- a hashtable of properties
-
main
-
main2
test- Parameters:
args
- args
-
main1
Method for debugging.- Parameters:
args
- arguments- Throws:
Exception
- some problem
-
splitMacros
This parses the given string with the following form.some text ${macro1} more text ... ${macro2} ... ${macroN} end text
It returns a list that flip-flops between the text and the macro:[some text, macro1, more text, ..., macro2, ..., macroN, end text]
- Parameters:
s
- String to parse- Returns:
- List of tokens
-
applyMacros
This takes a string of the following form.some text ${macro1} more text ... ${macro2} ... ${macroN} end text
And replaces the macros with values from the given properties table If throwError is true then an IllegalArgumentException is thrown if the properties does not contain one of the macros- Parameters:
s
- String to processprops
- Contains the macro valuesthrowError
- Throw exception when macro is missing- Returns:
- Processed string
-
parseCoordinates
Parse the lat/lon/alt coordinate string- Parameters:
coords
- comma and space separated coord string- Returns:
- coords
-
getAnOrA
Get "a" or "an" for prefixing to a string based on the first character- Parameters:
subject
- subject to prefix- Returns:
- "an" for vowels, "a" for consonants
-
string_Sort
sort a string array by comparing the sub string- Parameters:
substart
- sub string start indexsubend
- sub string end index
-