public abstract class PuString
extends java.lang.Object
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 and Description |
---|
PuString() |
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.
|
public static boolean m_bConvertDoubleToFloat
public static java.lang.String[][] clone(java.lang.String[][] src)
null
.public static int fromCharSet(java.lang.String str, java.lang.String charSet, int fromIdx)
public static int notFromCharSet(java.lang.String str, java.lang.String charSet, int fromIdx)
public static boolean matchPattern(java.lang.String string, java.lang.String pattern)
public static int commonInitials(java.lang.String str1, java.lang.String str2)
public static int containsChars(java.lang.String str, char c)
public static boolean isEmpty(java.lang.String str)
true
if string is empty or consists of empty string.public static java.lang.String bracketedString(java.lang.String str, char leftDelim, char rightDelim)
Method issues a warning if only one delimiter is found.
str
- String containing bracketed substring.leftDelim
- left bracket characterrightDelim
- right bracket characternull
if delimiter no found.public static java.lang.String[] splitString(java.lang.String str, char delim)
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.
str
- Delimiter separated strings to split.delim
- Character delimiter.public static int numSplitStrings(java.lang.String str, char delim)
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.
str
- Delimiter separated strings to split.delim
- Character delimiter.public static java.lang.String[] splitString(java.lang.String str, int maxCharsPerString)
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' '.str
- the string to be splitmaxCharsPerString
- the maximum number of characters a single result string shall containpublic static java.lang.String[] splitString(java.lang.String str, int maxWidth, java.awt.FontMetrics fm)
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' '.str
- the string to be splitmaxWidth
- the maximum number of pixels a single result string shall containfm
- font metrics that represents the font w.r.t. the systempublic static java.lang.String replaceTab(java.lang.String str, int numSpaces)
str
- the string to be convertednumSpaces
- number of ' '-characters that replace one '\t'public static java.lang.String replace(java.lang.String str, java.lang.String sub, java.lang.String newSub)
str
- the string to be convertedsub
- substring to be replacednewSub
- replacement substringpublic static java.lang.String mergeStrings(java.lang.String[] str, char delim)
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.
str
- Array with strings to merge.delim
- Character to separate merged strings.public static java.lang.String mergeStrings(java.lang.String[] str, java.lang.String delim)
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.
str
- Array with strings to merge.delim
- String to separate merged strings.public static void sort(java.lang.String[] strings)
public static java.lang.String[] sort(java.lang.String[] origStrings, int[] index)
public static int indexOfString(java.lang.String[] strings, java.lang.String string)
public static int indexOfStringIgnoreCase(java.lang.String[] strings, java.lang.String string)
public static java.lang.String intToString(int i, int width)
If string is too small then string is filled with '9' and a warning message issued.
i
- the integer to be convertedwidth
- width of the returned string including leading ' ' resp. '-'.public static java.lang.String toString(double d)
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.
d
- the doublepublic static java.lang.String toString(double d, int digits)
d
- The double to convert.digits
- Number of decimal places.public static java.lang.String toString(double[] data, boolean bExp)
data
- array of double number to be printed.bExp
- if false, then use non-exponential representationpublic static java.lang.String toString(double[] data, boolean bFloat, boolean bExp)
data
- array of double number to be printed.bFloat
- if true, then convert to float before savingbExp
- if false, then use non-exponential representationpublic static java.lang.String toString(double[] data)
data
- array of double number to be printed.public static java.lang.String toString(float d)
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.
d
- the doublepublic static java.lang.String toString(float[] data, boolean bExp)
data
- array of float number to be printed.bExp
- if false, then use non-exponential representationpublic static java.lang.String toString(float[] data)
data
- array of float number to be printed.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.
d
- the doublemantissa
- an int with the number of mantissa digitswidth
- an int with the width of the returned string""
if mantissa<1 or width-mantissa<3.public static java.lang.String doubleToString(double d, int mantissa)
d
- the doublemantissa
- an int with the number of digits behind the periodpublic static java.lang.String toString(int[] data)
data
- array of integer number to be printed."