public class ASTStr
extends java.lang.Object
These methods are provided to simplify translating the code to other languages.
Copyright (c) 2018
Constructor and Description |
---|
ASTStr() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
abbrevRight(java.lang.String strIn,
int maxlen)
Abbreviates a string on the right, if necessary.
|
static int |
compareAlphaNumeric(java.lang.String str1,
java.lang.String str2)
Compares two strings that may contain alphanumeric characters so that a string such
as 'A9' is "less" than the string 'A11'.
|
static int |
countChars(java.lang.String str,
char ch)
Counts all occurrences of a specified character in a string.
|
static java.lang.String |
extractAlphaNumSubstr(java.lang.String str,
int start)
Extract a substring from the input string that is all numeric or all alphabetic.
|
static java.lang.String |
insertCommas(double x)
Convert a number to a string and insert commas.
|
static java.lang.String |
removeWhitespace(java.lang.String str)
Removes all whitespace (spaces, tabs, ctrl-lf, etc.) from a string, including
embedded whitespace.
|
static java.lang.String |
replaceStr(java.lang.String strIn,
java.lang.String strTarget,
java.lang.String strReplace)
Replaces all occurrences of strTarget in strIn with strReplace.
|
public static java.lang.String abbrevRight(java.lang.String strIn, int maxlen)
strIn
- input stringmaxlen
- maximum length not counting ellipsespublic static int compareAlphaNumeric(java.lang.String str1, java.lang.String str2)
Note that this method only supports integers (e.g., numbers such as 5.9 vs 3.01 may not compare as expected) and that the maximum size integer in the string is limited to that which can be represented by a Java int data type.
str1
- First string to compare.str2
- Second string to compare.public static int countChars(java.lang.String str, char ch)
str
- input stringch
- character to search forpublic static java.lang.String extractAlphaNumSubstr(java.lang.String str, int start)
str
- the input stringstart
- where in str to begin extraction (0-based indexing!)public static java.lang.String insertCommas(double x)
x
- number to convertpublic static java.lang.String removeWhitespace(java.lang.String str)
str
- input stringpublic static java.lang.String replaceStr(java.lang.String strIn, java.lang.String strTarget, java.lang.String strReplace)
strIn
- input string to be modifiedstrTarget
- target string to be searched for in strInstrReplace
- replacement string