Class StringUtil

java.lang.Object
ucar.unidata.util.StringUtil

public class StringUtil extends Object
String utilities
  • Field Details

    • debug

      public static boolean debug
      debug flag
    • ordinalNames

      public static final String[] ordinalNames
      Ordinal names for images
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • notEmpty

      public static boolean notEmpty(String s)
      Check if the string is not empty
      Parameters:
      s - String to check
      Returns:
      true if it's not the empty string (len > 0)
    • collapseWhitespace

      public static String collapseWhitespace(String s)
      Collapse continuous whitespace into one single " ".
      Parameters:
      s - operate on this string
      Returns:
      result with collapsed whitespace
    • findFormatString

      public static String findFormatString(String macroName, String macroDelimiter, String text)
      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 macro
      macroDelimiter - The delimiter used. e.g. '%'
      text - the text
      Returns:
      the format string or null
    • substitute

      public static String substitute(String original, String match, String subst)
      Find all occurences of the "match" in original, and substitute the "subst" string.
      Parameters:
      original - starting string
      match - string to match
      subst - string to substitute
      Returns:
      a new string with substitutions
    • repeat

      public static String repeat(String s, int cnt)
      Concatentate the given string cnt times
      Parameters:
      s - base string
      cnt -
      Returns:
      repeated string
    • substitute

      public static String substitute(String original, String[] match, String[] subst)
      Find all occurences of match strings in original, and substitute the corresponding subst string.
      Parameters:
      original - starting string
      match - array of strings to match
      subst - array of strings to substitute
      Returns:
      a new string with substitutions
    • substitute

      public 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.
      Parameters:
      sbuff - starting string buffer
      match - string to match
      subst - string to substitute
    • isDigits

      public static boolean isDigits(String s)
      Return true if all characters are numeric.
      Parameters:
      s - operate on this String
      Returns:
      true if all characters are numeric
    • quoteHtmlContent

      public static String quoteHtmlContent(String x)
      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

      public static String quoteXmlContent(String x)
      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

      public static String unquoteXmlContent(String x)
      Reverse XML quoting to recover the original string.
      Parameters:
      x - string to quote
      Returns:
      equivilent string
    • quoteXmlAttribute

      public static String quoteXmlAttribute(String x)
      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

      public static String unquoteXmlAttribute(String x)
      Reverse XML quoting to recover the original string.
      Parameters:
      x - string to quote
      Returns:
      equivilent string
    • makeValidCdmObjectName

      public static String makeValidCdmObjectName(String name)
    • replace

      public static String replace(String x, char[] replaceChar, String[] replaceWith)
      Replace all occurences of replaceChar with replaceWith
      Parameters:
      x - operate on this string
      replaceChar - get rid of these
      replaceWith - replace with these
      Returns:
      resulting string
    • unreplace

      public static String unreplace(String x, String[] orgReplace, char[] orgChar)
      Replace all occurences of orgReplace with orgChar; inverse of replace().
      Parameters:
      x - operate on this string
      orgReplace - get rid of these
      orgChar - replace with these
      Returns:
      resulting string
    • match

      public static int match(String s1, String s2)
      Count number of chars that match in two strings, starting from front.
      Parameters:
      s1 - compare this string
      s2 - compare this string
      Returns:
      number of matching chars, starting from first char
    • replace

      public static void replace(StringBuffer sb, char out, String in)
      Replace any char "out" in sb with "in".
      Parameters:
      sb - StringBuffer to replace
      out - repalce this character
      in - with this string
    • unreplace

      public static void unreplace(StringBuffer sb, String out, char in)
      Replace any String "out" in sb with char "in".
      Parameters:
      sb - StringBuffer to replace
      out - repalce this String
      in - with this char
    • replace

      public static String replace(String s, char out, String in)
      Replace any char "out" in s with "in".
      Parameters:
      s - string to replace
      out - repalce this character
      in - with this string
      Returns:
      modified string if needed
    • escape

      public static String escape(String x, String okChars)
      Escape any char not alphanumeric or in okChars. Escape by replacing char with %xx (hex).
      Parameters:
      x - escape this string
      okChars - these are ok.
      Returns:
      equivilent escaped string.
    • ignoreescape

      public static String ignoreescape(String x, String okChars)
    • toHexString

      public static String toHexString(Color c)
      Convert the given color to is string hex representation
      Parameters:
      c - color
      Returns:
      hex represenation
    • findMatch

      public static Object findMatch(String source, List patternList, Object dflt)
      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

      public static Object findMatch(String source, List patternList, List results, Object dflt)
      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

      public static boolean containsRegExp(String patternString)
      See if a pattern string contains regular expression characters (^,*,$,+).
      Parameters:
      patternString - pattern string to check
      Returns:
      true if it contains (^,*,$,+).
    • stringMatch

      public static boolean stringMatch(String input, String patternString)
      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 substrings
      caseSensitive - Is case sensitive
      Returns:
      true if the pattern match the input.
    • regexpMatch

      public static boolean regexpMatch(String input, String patternString)
      Match a regular expression
      Parameters:
      input - string to match
      patternString - reg ex pattern string
      Returns:
      true if a match
    • wildcardToRegexp

      public static String wildcardToRegexp(String wildcard)
      Change a wildcard expression to a proper regular expression
      Parameters:
      wildcard - wildcard string (*, ?);
      Returns:
      the corresponding regular expression
    • startsWithVowel

      public static boolean startsWithVowel(String value)
      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

      public static String breakText(String text, String insert, int lineSize)
      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 convert
      insert - string to insert
      lineSize - line size to insert at
      Returns:
      The text with added br tags.
    • breakTextAtWords

      public static String breakTextAtWords(String text, String insert, int lineSize)
      Break the given text into lines, respecting word boundaries (blank space).
      Parameters:
      text - The text to convert
      insert - break to insert
      lineSize - line size to insert at
      Returns:
      The text with added br tags.
    • stripHtmlTag

      public static String stripHtmlTag(String html)
      Remove any beginning or ending <html> tags
      Parameters:
      html - the html
      Returns:
      the stripped html
    • stripTags

      public static String stripTags(String html)
      Remove all text contained within "< >" tags.
      Parameters:
      html - The source html string.
      Returns:
      The raw text.
    • stripAndReplace

      public 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 ... pattern2"
      Parameters:
      s - initial string
      pattern1 - delimiter 1
      pattern2 - delimiter 2
      replace - replace with
      Returns:
      replaced string
    • removeWhitespace

      public static String removeWhitespace(String inputString)
      Remove any whitespace (ie., Character.isWhitespace) from the input string.
      Parameters:
      inputString - The string to remove the whitespace.
      Returns:
      The whitespaceless result.
    • zeroString

      public static String zeroString(int value)
      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

      public static String padZero(int value, int numDigits)
      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

      public static String padLeft(String s, int desiredLength)
      Pad the given string with spaces on the left up to the given length.
      Parameters:
      s - String to pad
      desiredLength - ending length
      Returns:
      padded String
    • padLeft

      public static String padLeft(String s, int desiredLength, String padString)
      Pad the given string with padString on the left up to the given length.
      Parameters:
      s - String to pad
      desiredLength - ending length
      padString - String to pad with (e.g, " ")
      Returns:
      padded String
    • padRight

      public static String padRight(String s, int desiredLength)
      Pad the given string with spaces on the right up to the given length.
      Parameters:
      s - String to pad
      desiredLength - ending length
      Returns:
      padded String
    • padRight

      public static String padRight(String s, int desiredLength, String padString)
      Pad the given string with padString on the right up to the given length.
      Parameters:
      s - String to pad
      desiredLength - ending length
      padString - String to pad with (e.g, " ")
      Returns:
      padded String
    • join

      public static String join(String[] args)
      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

      public static String join(String delimiter, Object[] args)
      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

      public static String join(String delimiter, Object[] args, boolean ignoreEmptyStrings)
      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

      public static String join(String delimiter, List args)
      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

      public static String join(String delimiter, List args, boolean ignoreEmptyStrings)
      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

      public static List<String> split(Object source)
      Tokenize the toString value of the given source object, splitting on ",".
      Parameters:
      source - The source object string.
      Returns:
      List of String tokens.
    • parseDate

      public static Date parseDate(String dttm)
      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

      public static List parseIntegerListString(String s)
      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

      public static List parseFloatListString(String s)
      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 parse
      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.
    • 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 parse
      indices - 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

      public static String[] splitString(String source)
      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

      public static List<String> split(Object source, String delimiter)
      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

      public static List<String> split(Object source, String delimiter, boolean trim)
      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

      public static List<String> splitWithQuotes(String s)
      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

      public static String[] split(String s, String delimiter, int cnt)
      Split the given string into the first cnt number of substrings as delimited by the given delimiter.
      Parameters:
      s - String to split
      delimiter - token delimeter
      cnt - max number of tokens
      Returns:
      array of strings or null if unable to split the string.
    • splitUpTo

      public static List<String> splitUpTo(String s, String delimiter, int cnt)
      Split up to a certain number of characters
      Parameters:
      s - the string to split
      delimiter - the delimiter
      cnt - the max number
      Returns:
      the list of split strings
    • replaceDate

      public static String replaceDate(String s, String macroName, Date date)
      Replace the macro within s with the formatted date. s can contain macros of the form ${macroName:some date format}
      Parameters:
      s - source string
      macroName - macro name_
      date - date to use
      Returns:
      formatted string
    • replaceDate

      public static String replaceDate(String s, String macroName, Date date, TimeZone timeZone)
      Replace the macro within s with the formatted date. s can contain macros of the form ${macroName:some date format}
      Parameters:
      s - source string
      macroName - macro name_
      date - date to use
      timeZone - 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 form macroName:some date format
      Parameters:
      s - source string
      macroName - macro name_
      date - date to use
      macroPrefix - the macro prefix
      macroSuffix - 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 form macroName:some date format
      Parameters:
      s - source string
      macroName - macro name
      date - date to use
      macroPrefix - the macro prefix
      macroSuffix - the macro suffix
      timeZone - for the dates
      Returns:
      formatted string
    • listToStringArray

      public static String[] listToStringArray(List objectList)
      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

      public 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 semicolons
      Parameters:
      l - list of objects
      Returns:
      semicolon separated String of Strings.
    • toString

      public static List toString(List l)
      Convert the list of objects to a list of strings.
      Parameters:
      l - List of objects
      Returns:
      List of strings.
    • replace

      public static String replace(String string, String pattern, String value)
      Replaces all occurrences of "pattern" in "string" with "value"
      Parameters:
      string - string to munge
      pattern - pattern to replace
      value - replacement value
      Returns:
      munged string
    • replaceList

      public static String replaceList(String v, String[] patterns, String[] values)
      Replaces all occurrences of "patterns" in "v" with "values"
      Parameters:
      v - original String
      patterns - patterns to match
      values - replacement values
      Returns:
      munged String
    • replaceList

      public static String replaceList(String v, List patterns, List values)
      Replaces all occurrences of "patterns" in "v" with "values"
      Parameters:
      v - original String
      patterns - patterns to match
      values - replacement values
      Returns:
      munged String
    • replaceList

      public 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 .
      Parameters:
      sourceList - original list of Strings
      patterns - patterns to replace
      values - replacement values
      Returns:
      new list with replaced values
    • append

      public static StringBuffer append(StringBuffer sb, Object s1)
      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 be null)
      s1 - object to append
      Returns:
      StringBuffer with appended object
    • append

      public static StringBuffer append(StringBuffer sb, Object s1, Object s2)
      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 be null)
      s1 - first object to append
      s2 - second object to append
      Returns:
      StringBuffer with appended objects
    • append

      public static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3)
      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 be null)
      s1 - first object to append
      s2 - second object to append
      s3 - third object to append
      Returns:
      StringBuffer with appended objects
    • append

      public static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3, Object s4)
      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 be null)
      s1 - first object to append
      s2 - second object to append
      s3 - third object to append
      s4 - 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 be null)
      s1 - first object to append
      s2 - second object to append
      s3 - third object to append
      s4 - fourth object to append
      s5 - fifth object to append
      Returns:
      StringBuffer with appended objects
    • parseCsv

      public static List parseCsv(String s, boolean skipFirst)
      Parse a comma separated value (CVS) String
      Parameters:
      s - String to parse
      skipFirst - true to skip the first value
      Returns:
      list of parsed Strings
    • shorten

      public static final String shorten(String s, int length)
      Shorten a string using elipses (...)
      Parameters:
      s - String to shorten
      length - shortened length where elipses will start
      Returns:
      shortened string.
    • toString

      public static String toString(Object[] array)
      Create a string representation of the given array
      Parameters:
      array - array to print
      Returns:
      array as a String
    • expandIso8601

      public static List expandIso8601(String time)
      A first attempt at parsing a dttm range string
      Parameters:
      time - The time
      Returns:
      List iof times
    • findPattern

      public static String findPattern(String source, String patternString)
      Find the pattern in a string
      Parameters:
      source - String to search
      patternString - pattern
      Returns:
      the String that matches
    • isUpperCase

      public static boolean isUpperCase(String s)
      Is the string all upper case?
      Parameters:
      s - string to check
      Returns:
      true if all uppercase
    • isLowerCase

      public static boolean isLowerCase(String s)
      Is the string all lower case?
      Parameters:
      s - string to check
      Returns:
      true if all characters are lowercase
    • camelCase

      public static String camelCase(String s)
      Camel case a string (eg howard -> Howard)
      Parameters:
      s - string to camel case
      Returns:
      the camel cased string
    • parseIso8601

      public static Date parseIso8601(String time)
      Not working yet but this is supposed to parse an iso8601 date format
      Parameters:
      time - date
      Returns:
      date
    • parseTimePeriod

      public static long parseTimePeriod(String s)
      Note, right now this just parses the hour/minute/second periods
      Parameters:
      s - The date string
      Returns:
      The time
    • parsePropertiesString

      public static Hashtable parsePropertiesString(String s)
      Parse the semi-colon delimited string of name=value properties.
      Parameters:
      s - Semi-colon delimited name=value string
      Returns:
      properties
    • parseHtmlProperties

      public static Hashtable parseHtmlProperties(String s)
      Parse HTML Properties
      Parameters:
      s - the string
      Returns:
      a hashtable of properties
    • main

      public static void main(String[] args)
    • main2

      public static void main2(String[] args)
      test
      Parameters:
      args - args
    • main1

      public static void main1(String[] args) throws Exception
      Method for debugging.
      Parameters:
      args - arguments
      Throws:
      Exception - some problem
    • splitMacros

      public static List<String> splitMacros(String s)
      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

      public static String applyMacros(String s, Hashtable props, boolean throwError)
      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 process
      props - Contains the macro values
      throwError - Throw exception when macro is missing
      Returns:
      Processed string
    • parseCoordinates

      public static double[][] parseCoordinates(String coords)
      Parse the lat/lon/alt coordinate string
      Parameters:
      coords - comma and space separated coord string
      Returns:
      coords
    • getAnOrA

      public static String getAnOrA(String subject)
      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

      public static void string_Sort(String[] my_arr, int substart, int subend)
      sort a string array by comparing the sub string
      Parameters:
      substart - sub string start index
      subend - sub string end index