JavaView® v2.00.008

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.

Version:
12.02.01, 1.70 revised (kp) New method mergeStrings() added.
17.11.00, 1.60 revised (kp) Method for cloneing of strings added.
08.11.00, 1.50 revised (kp) Number formatting methods added.
30.10.99, 1.00 created (kp)
Author:
Konrad Polthier

Constructor Summary
PuString()
           
 
Method Summary
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 int to a String with given width of 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 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.
See Also:
#copy(String)

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.

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.
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.

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

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.

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

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 int to a String with given width of String. If string is too small then string is filled with '9'.
Parameters:
i - the int
width - an int with the width for the returned String
Returns:
the 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 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 null 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 null in case of failure

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 null if mantissa<1.

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.