jv.number

## Class PuString

- java.lang.Object
- - jv.number.PuString

-     public abstract class PuString
      extends java.lang.Object

  Utility functions comparing and operating with strings.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `m_bConvertDoubleToFloat` HACK: flag if methods PuString.toString(double ..) convert doubles to floats in order to reduce file size.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PuString()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `bracketedString(java.lang.String str, char leftDelim, char rightDelim)` Get part of string which is bracketed by two given characters.
    `static java.lang.String[][]` | `clone(java.lang.String[][] src)` Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners.
    `static int` | `commonInitials(java.lang.String str1, java.lang.String str2)` Returns the length of the initial segment of str1 that equals str2.
    `static int` | `containsChars(java.lang.String str, char c)` Returns the number of times the given character appears in the string.
    `static java.lang.String` | `doubleToString(double d, int mantissa)` Converts a double to a String with given number of mantissa digits in exponential form '-d.dddddEdd' or ' d.dddddEdd'.
    `static java.lang.String` | `doubleToString(double d, int mantissa, int width)` Converts a double to a string with given number of mantissa digits in non exponential form.
    `static int` | `fromCharSet(java.lang.String str, java.lang.String charSet, int fromIdx)` Returns the length of the initial segment of str which consists entirely of characters from charSet, starting at the given index.
    `static int` | `indexOfString(java.lang.String[] strings, java.lang.String string)` Locates a String in an array of Strings.
    `static int` | `indexOfStringIgnoreCase(java.lang.String[] strings, java.lang.String string)` Locates a String in an array of Strings, ignoring case.
    `static java.lang.String` | `intToString(int i, int width)` Converts an integer to a string with given width of the string.
    `static boolean` | `isEmpty(java.lang.String str)` Check if string is empty or consists of empty string.
    `static boolean` | `matchPattern(java.lang.String string, java.lang.String pattern)` Checks whether a string matches a given wildcard pattern.
    `static java.lang.String` | `mergeStrings(java.lang.String[] str, char delim)` Merges an array of strings into a single string separated by the specified delimiter.
    `static java.lang.String` | `mergeStrings(java.lang.String[] str, java.lang.String delim)` Merges an array of strings into a single string separated by the specified delimiter.
    `static int` | `notFromCharSet(java.lang.String str, java.lang.String charSet, int fromIdx)` Returns the length of the initial segment of str which consists entirely of characters NOT from charSet, starting at the given index.
    `static int` | `numSplitStrings(java.lang.String str, char delim)` Turns a string into an array of strings, by splitting it at the specified character.
    `static java.lang.String` | `replace(java.lang.String str, java.lang.String sub, java.lang.String newSub)` Replaces all substrings one after another with new substring.
    `static java.lang.String` | `replaceTab(java.lang.String str, int numSpaces)` Replaces all TAB ('\t') characters by the given number of spaces.
    `static void` | `sort(java.lang.String[] strings)` Sorts an array of Strings and modifies array in place.
    `static java.lang.String[]` | `sort(java.lang.String[] origStrings, int[] index)` Sorts an array of Strings without modifying the original array.
    `static java.lang.String[]` | `splitString(java.lang.String str, char delim)` Turns a string into an array of strings, by splitting it at the specified character.
    `static java.lang.String[]` | `splitString(java.lang.String str, int maxCharsPerString)` Tries to split the given string into segments at most `maxCharsPerString` long.
    `static java.lang.String[]` | `splitString(java.lang.String str, int maxWidth, java.awt.FontMetrics fm)` Tries to split the given string into segments at most `maxWidth` pixels long w.r.t. the given FontMetrics.
    `static java.lang.String` | `toString(double d)` Converts a double to a string in non exponential form.
    `static java.lang.String` | `toString(double[] data)` Create single line string of double array where components are separated by blanks.
    `static java.lang.String` | `toString(double[] data, boolean bExp)` Create single line string of double array where components are separated by blanks.
    `static java.lang.String` | `toString(double[] data, boolean bFloat, boolean bExp)` Create single line string of double array where components are separated by blanks.
    `static java.lang.String` | `toString(double d, int digits)` Returns a String representation of a double number in a non-exponential form.
    `static java.lang.String` | `toString(float d)` Converts a float to a string in non exponential form.
    `static java.lang.String` | `toString(float[] data)` Create single line string of float array where components are separated by blanks.
    `static java.lang.String` | `toString(float[] data, boolean bExp)` Create single line string of float array where components are separated by blanks.
    `static java.lang.String` | `toString(int[] data)` Create single line string of integer array where components are separated by blanks.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### m_bConvertDoubleToFloat

          public static boolean m_bConvertDoubleToFloat

      HACK: flag if methods PuString.toString(double ..) convert doubles to floats in order to reduce file size.

  - ### Constructor Detail

    - #### PuString

          public PuString()

  - ### Method Detail

    - #### clone

          public static java.lang.String[][] clone(java.lang.String[][] src)

      Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to external classes. In general, all links of the clone to external objects are set to `null`.

    - #### fromCharSet

          public static int fromCharSet(java.lang.String str,
                        java.lang.String charSet,
                        int fromIdx)

      Returns the length of the initial segment of str which consists entirely of characters from charSet, starting at the given index.

    - #### notFromCharSet

          public static int notFromCharSet(java.lang.String str,
                           java.lang.String charSet,
                           int fromIdx)

      Returns the length of the initial segment of str which consists entirely of characters NOT from charSet, starting at the given index.

    - #### matchPattern

          public static boolean matchPattern(java.lang.String string,
                             java.lang.String pattern)

      Checks whether a string matches a given wildcard pattern. Only does ? and *, and multiple patterns separated by |.

    - #### commonInitials

          public static int commonInitials(java.lang.String str1,
                           java.lang.String str2)

      Returns the length of the initial segment of str1 that equals str2.

    - #### containsChars

          public static int containsChars(java.lang.String str,
                          char c)

      Returns the number of times the given character appears in the string.

    - #### isEmpty

          public static boolean isEmpty(java.lang.String str)

      Check if string is empty or consists of empty string.
      Returns:
        `true` if string is empty or consists of empty string.
      Since:
        JavaView 3.54.000

    - #### bracketedString

          public static java.lang.String bracketedString(java.lang.String str,
                                         char leftDelim,
                                         char rightDelim)

      Get part of string which is bracketed by two given characters. Method looks for left most appearance of leftDelim, and right most appearance of rightDelim. To avoid ambiguous situations, both characters should appear only once inside the full string.

      Method issues a warning if only one delimiter is found.

      Parameters:
        `str` - String containing bracketed substring.
        `leftDelim` - left bracket character
        `rightDelim` - right bracket character
      Returns:
        part of string between both brackets, `null` if delimiter no found.

    - #### splitString

          public static java.lang.String[] splitString(java.lang.String str,
                                       char delim)

      Turns a string into an array of strings, by splitting it at the specified character. This does not use StringTokenizer, and therefore can handle empty fields.

      If argument string ends with the delimiter then delimiter is ignored.

      If delimiter is blank then consecutive sequences of blanks are identified to a single blank. This identification is not performed with other delimiters.

      If string does not contain the delimiter, then the string is returned as array of length 1. Unless the delimiter is blank or appears at the end of the original string, the original string can always be reconstructed from the returned array.

      If the string is null then null is return.

      Parameters:
        `str` - Delimiter separated strings to split.
        `delim` - Character delimiter.
      Returns:
        Array with strings obtained from splitting

    - #### numSplitStrings

          public static int numSplitStrings(java.lang.String str,
                            char delim)

      Turns a string into an array of strings, by splitting it at the specified character. This does not use StringTokenizer, and therefore can handle empty fields.

      If argument string ends with the delimiter then delimiter is ignored.

      If delimiter is blank then consecutive sequences of blanks are identified to a single blank. This identification is not performed with other delimiters.

      Parameters:
        `str` - Delimiter separated strings to split.
        `delim` - Character delimiter.
      Returns:
        Array with strings obtained from splitting

    - #### splitString

          public static java.lang.String[] splitString(java.lang.String str,
                                       int maxCharsPerString)

      Tries to split the given string into segments at most `maxCharsPerString` long. Connected (non-whitespace ' \t\n') characters are not split up into different Strings. A '\n' forces a new string (and is removed afterwards). A '\n' at the end of the original string is ignored. If two words are split, then all whitespace at the beginning of the next part are removed. This does not happen if the split was forced by a '\n'. A '\t' counts as 4x' '.
      Parameters:
        `str` - the string to be split
        `maxCharsPerString` - the maximum number of characters a single result string shall contain
      Returns:
        array with strings obtained from splitting

    - #### splitString

          public static java.lang.String[] splitString(java.lang.String str,
                                       int maxWidth,
                                       java.awt.FontMetrics fm)

      Tries to split the given string into segments at most `maxWidth` pixels long w.r.t. the given FontMetrics. Connected (non-whitespace ' \t\n') characters are not split up into different Strings. A '\n' forces a new string (and is removed afterwards). A '\n' at the end of the original string is ignored. If two words are split, then all whitespace at the beginning of the next part are removed. This does not happen if the split was forced by a '\n'. A '\t' counts as 4x' '.
      Parameters:
        `str` - the string to be split
        `maxWidth` - the maximum number of pixels a single result string shall contain
        `fm` - font metrics that represents the font w.r.t. the system
      Returns:
        array with strings obtained from splitting

    - #### replaceTab

          public static java.lang.String replaceTab(java.lang.String str,
                                    int numSpaces)

      Replaces all TAB ('\t') characters by the given number of spaces.
      Parameters:
        `str` - the string to be converted
        `numSpaces` - number of ' '-characters that replace one '\t'
      Returns:
        string without tabs but sequences of ' ' instead

    - #### replace

          public static java.lang.String replace(java.lang.String str,
                                 java.lang.String sub,
                                 java.lang.String newSub)

      Replaces all substrings one after another with new substring.
      Parameters:
        `str` - the string to be converted
        `sub` - substring to be replaced
        `newSub` - replacement substring
      Returns:
        modified string
      Since:
        JavaView v.3.64.001

    - #### mergeStrings

          public static java.lang.String mergeStrings(java.lang.String[] str,
                                      char delim)

      Merges an array of strings into a single string separated by the specified delimiter.

      If the array is null, then an empty string is returned. Otherwise, the number of delimiters in the resulting string is equal to str.length-1. Missing strings are considered empty strings.

      If the delimiter is the empty string, then strings are concatenated.

      Parameters:
        `str` - Array with strings to merge.
        `delim` - Character to separate merged strings.
      Returns:
        merged string with entries separated by the specified delimiter

    - #### mergeStrings

          public static java.lang.String mergeStrings(java.lang.String[] str,
                                      java.lang.String delim)

      Merges an array of strings into a single string separated by the specified delimiter.

      If the array is null, then an empty string is returned. Otherwise, the number of delimiters in the resulting string is equal to str.length-1. Missing strings are considered empty strings.

      If the delimiter is the empty string, then strings are concatenated.

      Parameters:
        `str` - Array with strings to merge.
        `delim` - String to separate merged strings.
      Returns:
        merged string with entries separated by the specified delimiter
      Since:
        JavaView 2.99.035

    - #### sort

          public static void sort(java.lang.String[] strings)

      Sorts an array of Strings and modifies array in place.

    - #### sort

          public static java.lang.String[] sort(java.lang.String[] origStrings,
                                int[] index)

      Sorts an array of Strings without modifying the original array. Returns an index vector and the sorted array.

    - #### indexOfString

          public static int indexOfString(java.lang.String[] strings,
                          java.lang.String string)

      Locates a String in an array of Strings. Returns -1 if the String is not found.

    - #### indexOfStringIgnoreCase

          public static int indexOfStringIgnoreCase(java.lang.String[] strings,
                                    java.lang.String string)

      Locates a String in an array of Strings, ignoring case. Returns -1 if the String is not found.

    - #### intToString

          public static java.lang.String intToString(int i,
                                     int width)

      Converts an integer to a string with given width of the string. If integer is positive then string contains a leading white space.

      If string is too small then string is filled with '9' and a warning message issued.

      Parameters:
        `i` - the integer to be converted
        `width` - width of the returned string including leading ' ' resp. '-'.
      Returns:
        integer converted into a string

    - #### toString

          public static java.lang.String toString(double d)

      Converts a double to a string in non exponential form.

      If d is in the range 10^-3 <= |d| <=10^7, then the result coincides with the result of Double.toString(double), i.e. the result is a string in the style [-]ddd.ddd.

      Otherwise, the result of Double.toString(double) is postprocessed to obtain a non-exponential form. There is always a minimum of one digit after the decimal point. The number of digits is the minimum needed to uniquely distinguish the argument value from adjacent values of type double.

      Parameters:
        `d` - the double
      Returns:
        the string representation of the double value

    - #### toString

          public static java.lang.String toString(double d,
                                  int digits)

      Returns a String representation of a double number in a non-exponential form. The number of digits behind the decimal point can be specified.
      Parameters:
        `d` - The double to convert.
        `digits` - Number of decimal places.

    - #### toString

          public static java.lang.String toString(double[] data,
                                  boolean bExp)

      Create single line string of double array where components are separated by blanks.
      Parameters:
        `data` - array of double number to be printed.
        `bExp` - if false, then use non-exponential representation
      Returns:
        single-line string, or empty string.

    - #### toString

          public static java.lang.String toString(double[] data,
                                  boolean bFloat,
                                  boolean bExp)

      Create single line string of double array where components are separated by blanks.
      Parameters:
        `data` - array of double number to be printed.
        `bFloat` - if true, then convert to float before saving
        `bExp` - if false, then use non-exponential representation
      Returns:
        single-line string, or empty string.

    - #### toString

          public static java.lang.String toString(double[] data)

      Create single line string of double array where components are separated by blanks. Do not convert to float and use exponential form.
      Parameters:
        `data` - array of double number to be printed.
      Returns:
        single-line string, or empty string.

    - #### toString

          public static java.lang.String toString(float d)

      Converts a float to a string in non exponential form.

      If d is in the range 10^-3 <= |d| <=10^7, then the result coincides with the result of Double.toString(double), i.e. the result is a string in the style [-]ddd.ddd.

      Otherwise, the result of Double.toString(double) is postprocessed to obtain a non-exponential form. There is always a minimum of one digit after the decimal point. The number of digits is the minimum needed to uniquely distinguish the argument value from adjacent values of type double.

      Parameters:
        `d` - the double
      Returns:
        the string representation of the double value

    - #### toString

          public static java.lang.String toString(float[] data,
                                  boolean bExp)

      Create single line string of float array where components are separated by blanks.
      Parameters:
        `data` - array of float number to be printed.
        `bExp` - if false, then use non-exponential representation
      Returns:
        single-line string, or empty string.

    - #### toString

          public static java.lang.String toString(float[] data)

      Create single line string of float array where components are separated by blanks.
      Parameters:
        `data` - array of float number to be printed.
      Returns:
        single-line string, or empty string.

    - #### doubleToString

          public static java.lang.String doubleToString(double d,
                                        int mantissa,
                                        int width)

      Converts a double to a string with given number of mantissa digits in non exponential form. The length of the returned String can be specified. If the representation of the number is smaller, then the String will start with blanks.

      The passed number of mantissa digits must be greater or equal to one and the difference between mantissa and width must be greater or equal to three, otherwise `""` is returned.

      Parameters:
        `d` - the double
        `mantissa` - an int with the number of mantissa digits
        `width` - an int with the width of the returned string
      Returns:
        the string, or `""` if mantissa<1 or width-mantissa<3.

    - #### doubleToString

          public static java.lang.String doubleToString(double d,
                                        int mantissa)

      Converts a double to a String with given number of mantissa digits in exponential form '-d.dddddEdd' or ' d.dddddEdd'. The passed number of mantissa digits must be greater or equal to one, otherwise null is returned.
      Parameters:
        `d` - the double
        `mantissa` - an int with the number of digits behind the period
      Returns:
        the string, or "" if mantissa<1.

    - #### toString

          public static java.lang.String toString(int[] data)

      Create single line string of integer array where components are separated by blanks.
      Parameters:
        `data` - array of integer number to be printed.
      Returns:
        single-line string, or null of argument==null or zero length.

"

The software JavaView? is copyright protected. All Rights Reserved.
"