public final class StringHelper
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
baseOnly(java.lang.String str)
Returns only the base capitilazid characters [A-Z][0-9]
All other characters are removed from the String
|
static java.lang.String |
breakLine(java.lang.String str,
int maxLen)
Breaks a String after a maximun number of characters
on the first space or punctuation before that maximum.
|
static int |
count(java.lang.String s,
char c)
Count the number of characters c in String s
|
static int |
getNonBaseCharacter(java.lang.String value)
get the first non-base character (not A-Z,a-z,0-9) from the start of the String
|
static int |
getNonBaseCharacter(java.lang.String value,
int start)
get the first non-base character (not A-Z,a-z,0-9) from start
|
static int |
indexOfWord(java.lang.String source,
java.lang.String word,
int begin)
get the index of the start of word within the String
|
static java.lang.String |
initCaps(java.lang.String str,
char c)
Capitalize the first Letter in a String and
all letters following the char.
|
static boolean |
isEmpty(java.lang.String s)
check if a String is empty, meaning a String of length zero or null
|
static boolean |
isNumber(java.lang.String s)
check if the given String is a number.
|
static boolean |
isQuoteCharacter(char a)
check is a character is a quote: " or &
|
static java.lang.String |
join(java.lang.String seperator,
java.util.Collection s)
Deprecated.
From Java 1.8 use String#join
|
static java.lang.String |
leftPad(java.lang.String str,
java.lang.String filler,
int len)
Pads a String to the left with th filler String until len is reached
If the String is longer then the length the string will be truncated on
the left to not return more then lenght characters
|
static java.lang.String |
leftTrim(java.lang.String s)
Trim spaces to the left
|
static int |
matchBracket(char left,
java.lang.String line)
Finds the matching bracket for the first character given by left in
String line.
|
static int |
matchBracket(int pos,
java.lang.String line)
Finds the matching bracket for the bracket character at pos
in line.
|
static java.lang.String |
rightPad(java.lang.String str,
java.lang.String filler,
int len)
Pads a String to the right with the filler String until len is reached
If the String is longer then the length the string will be truncated on
the right to not return more then lenght characters
|
static java.lang.String |
rightTrim(java.lang.String s)
Trim spaces to the right
|
static java.lang.String |
rightTrim(java.lang.String s,
char c)
Trim off all chars c from the right
|
static java.lang.String |
stripper(java.lang.String str,
char c)
Strips a character from a String.
|
public static java.lang.String initCaps(java.lang.String str,
char c)
str - String, the String that needs to be InitCapped.c - char, The character after which letters should be capitalizedpublic static java.lang.String stripper(java.lang.String str,
char c)
str - String, from which the character should be
removedc - char, the Character that needs to be removdpublic static int getNonBaseCharacter(java.lang.String value)
value - Stringpublic static int getNonBaseCharacter(java.lang.String value,
int start)
value - Stringstart - intpublic static java.lang.String baseOnly(java.lang.String str)
str - String, the value to be 'based'public static final java.lang.String breakLine(java.lang.String str,
int maxLen)
public static java.lang.String leftPad(java.lang.String str,
java.lang.String filler,
int len)
str - String, if str is null, it will be threated as a zero length stringfiller - String, the String that fills the original String on the left until length.len - int, the length of the output stringjava.lang.NullPointerException - thrown if filler is nullpublic static java.lang.String rightPad(java.lang.String str,
java.lang.String filler,
int len)
str - String, if str is null, it will be threated as a zero length stringfiller - String, the String that fills the original String on the left until lengthlen - int, the length of the output stringjava.lang.NullPointerException - thrown if filler is nullpublic static java.lang.String leftTrim(java.lang.String s)
s - String, inputpublic static java.lang.String rightTrim(java.lang.String s)
s - String, inputpublic static java.lang.String rightTrim(java.lang.String s,
char c)
s - String, inputc - char to trim offpublic static int matchBracket(char left,
java.lang.String line)
left - char, the bracket character ",',{,[,( one is looking forline - String, the line to find the matching bracket inmatchBracket(int, String)public static int matchBracket(int pos,
java.lang.String line)
pos - int, The position of the matching bracket, valid
brackets are ",',{,[,( line - String, the line to find the matching bracket inpublic static boolean isQuoteCharacter(char a)
a - char, the char to testpublic static boolean isEmpty(java.lang.String s)
s - String, to test for emptypublic static final boolean isNumber(java.lang.String s)
s - Stringpublic static final int count(java.lang.String s,
char c)
s - Stringc - char@Deprecated
public static final java.lang.String join(java.lang.String seperator,
java.util.Collection s)
seperator - the chosen separators - Collection of Strings to concatpublic static final int indexOfWord(java.lang.String source,
java.lang.String word,
int begin)
source - Stringword - String the word to find checking for whitespace around itbegin - int start index