public class MString extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CHARSET_DEFAULT |
static String |
CHARSET_ISO_8859_1 |
static String |
CHARSET_UTF_16 |
static String |
CHARSET_UTF_8 |
static String |
DEFAULT_SEPARATOR |
static char[] |
WHITESPACE |
| Constructor and Description |
|---|
MString() |
| Modifier and Type | Method and Description |
|---|---|
static String |
afterIndex(String _s,
char _c)
Return the string after _c in _s.
|
static String |
afterIndex(String _s,
char[] _c)
Return the string after _c in _s.
|
static String |
afterLastIndex(String string,
char c)
Return the part after the last occurrence of the char.
|
static void |
appendRepeating(int amount,
char fill,
StringBuffer buffer)
Append the number of times a character to a string buffer.
|
static String |
beforeIndex(String _s,
char _c)
Return the string before _c in _s.
|
static String |
beforeIndex(String _s,
char[] _c)
Return the string before _c in _s.
|
static String |
beforeLastIndex(String string,
char c)
Return part before last occurrence of the char.
|
static String |
canonical(String s)
Convert String to canonical standard form.
|
static boolean |
compareFsLikePattern(String str,
String pattern)
Use * at the beginning or/and the end and a ! at the beginning for 'not'.
|
static boolean |
compareRegexPattern(String str,
String pattern) |
static boolean |
compareSQLLikePattern(String str,
String pattern)
Use % at the beginning and/or the end
example: %aloa% or !%aloa%
|
static String |
condense(String s)
Collapse multiple spaces in string down to a single space.
|
static int |
countCharacters(String in,
char c)
Return the count of the character in the string.
|
static int |
countCharacters(String in,
char[] c)
Return the count of the characters in the string.
|
static int |
countLeading(String text,
char c)
count of how many leading characters there are on a string matching a
given character.
|
static int |
countTrailing(String text,
char c)
count of how many trailing characters there are on a string matching a
given character.
|
static String |
decodeCSV(String _field) |
static String |
decodeUnicode(String _in) |
static String |
decodeURIComponent(String _in) |
static String |
encodeCSV(String _field) |
static String |
encodeCSVLine(String[] _fields) |
static String |
encodeUnicode(String _in) |
static String |
encodeURIComponent(String _in) |
static String |
encodeWebUnicode(String _in)
Encodes for the web.
|
static boolean |
equals(String in1,
String in2) |
static String |
findInitials(String title,
boolean upperOnly,
boolean digits,
int maxSize)
Try to find initials out of the given title.
|
static String |
getPart(String value,
int nr) |
static String |
getPart(String value,
int nr,
String def)
Split the string in n parts and return the part number nr.
|
static String |
getPart(String value,
String separator,
int nr) |
static String |
getPart(String value,
String separator,
int nr,
String def) |
static String |
getRepeatig(int amount,
char fill)
Repeate the character a given times.
|
static int[] |
getSelectedPart(String text,
int caretPosition)
Search in a string the selected paragraph indicated be empty lines.
|
static int[] |
getSelectedPart(String text,
int caretPosition,
String[] separators) |
static String |
getSelection(String text,
int[] part,
String def)
Returns the string part of the selected part.
|
static int |
indexOf(String _s,
char[] _c)
Returns the position where the first of one of the chars is found in the string.
|
static int |
indexOf(String _s,
char[] _c,
int offset)
Returns the position where the first of one of the chars is found in the string.
|
static boolean |
isEmpty(String _in)
Returns true if the string is null or an empty string.
|
static boolean |
isEmptyTrim(String s)
Is this string empty?
|
static boolean |
isIndex(String _s,
char _c)
Return, if the char is located in the string (indexOf).
|
static boolean |
isIndex(String _s,
char[] _c)
Returns true if one of the chars is found in the string.
|
static boolean |
isLegal(String candidate,
String legalChars)
Ensure the string contains only legal characters
|
static boolean |
isSet(String _in)
Return true if the the string is not empty.
|
static boolean |
isSetTrim(String _in)
Return true if the the string is not empty also trimmed.
|
static boolean |
isUnaccentedLowerCase(char c)
Check if char is plain ASCII lower case.
|
static boolean |
isUnaccentedUpperCase(char c)
Check if char is plain ASCII upper case.
|
static boolean |
isUnicode(String _in,
char _joker) |
static boolean |
isWhitespace(char c)
Return true if the character is in the list of whitespaces.
|
static String |
join(Iterator<String> src,
String glue) |
static String |
join(String[] src,
char glue) |
static String |
leftPad(String s,
int newLen,
boolean chop)
Pads the string out to the given length by applying blanks on the left.
|
static long |
parseDirtyLong(String numStr)
convert a String to a long.
|
static long |
parseLongPennies(String numStr)
convert a String into long pennies.
|
static String |
penniesToString(long pennies)
Print dollar currency, stored internally as scaled int.
|
static int |
pluck(String s)
Extracts a number from a string, returns 0 if malformed.
|
static String |
rep(char c,
int count)
Produce a String of a given repeating character.
|
static void |
replaceAll(StringBuffer _src,
String _pattern,
String _replacement)
Replace all pattern thru replacement strings.
|
static String |
replaceAll(String _src,
String _pattern,
String _replacement)
Replace all pattern thru replacement strings.
|
static String |
replaceSelection(String text,
int[] part,
String replacement)
Replace a text in another text.
|
static String |
replaceSQLLikePattern(String str,
String pattern,
String replace) |
static String |
rightPad(String s,
int newLen,
boolean chop)
Pads the string out to the given length by applying blanks on the right.
|
static String[] |
split(String _in,
String _pattern)
Split the string in parts.
|
static String[] |
splitIgnoreEmpty(String _in,
String _pattern)
Split the string in parts.
|
static String[] |
splitIgnoreEmpty(String _in,
String _pattern,
boolean trim) |
static String |
squish(String s)
Remove all spaces from a String.
|
static String |
toBookTitleCase(String s)
convert to Book Title case, with first letter of each word capitalised.
|
static String |
toHexString(int h)
Convert int to hex with lead zeroes
|
static String |
toLZ(int i,
int len)
Convert an integer to a String, with left zeroes.
|
static String |
toString(Color c)
Get #ffffff html hex number for a colour
|
static String |
trimLeading(String s)
Removes white space from beginning this string.
|
static String |
trimTrailing(String s)
Removes white space from end this string.
|
static String |
truncate(String in,
int length)
This will truncate the string at the end.
|
static String |
truncateNice(String in,
int length)
This will truncate the string, but it also adds three dots (...) at the removed position.
|
public static final String CHARSET_UTF_8
public static final String CHARSET_UTF_16
public static final String CHARSET_ISO_8859_1
public static final char[] WHITESPACE
public static final String DEFAULT_SEPARATOR
public static final String CHARSET_DEFAULT
public static boolean isSetTrim(String _in)
_in - The string to testpublic static boolean isSet(String _in)
_in - The string to testpublic static boolean isEmpty(String _in)
_in - public static String[] split(String _in, String _pattern)
_in - _pattern - public static String[] splitIgnoreEmpty(String _in, String _pattern)
_in - _pattern - public static String replaceAll(String _src, String _pattern, String _replacement)
_src - _pattern - _replacement - public static void replaceAll(StringBuffer _src, String _pattern, String _replacement)
_src - _pattern - _replacement - public static boolean isIndex(String _s, char _c)
public static String beforeIndex(String _s, char _c)
public static String afterIndex(String _s, char _c)
public static boolean isIndex(String _s, char[] _c)
_s - _c - public static String beforeIndex(String _s, char[] _c)
public static String afterIndex(String _s, char[] _c)
public static int indexOf(String _s, char[] _c, int offset)
_s - _c - offset - public static int indexOf(String _s, char[] _c)
_s - _c - public static String encodeWebUnicode(String _in)
_in - public static boolean isUnicode(String _in, char _joker)
public static boolean compareSQLLikePattern(String str, String pattern)
str - pattern - public static boolean compareFsLikePattern(String str, String pattern)
str - pattern - public static String replaceSQLLikePattern(String str, String pattern, String replace)
public static String canonical(String s)
s - String to be converted.public static String condense(String s)
s - String to strip of blanks.public static int countLeading(String text, char c)
text - text with possible leading characters, possibly empty, but not
null.c - the leading character of interest, usually ' ' or '\n'public static int countTrailing(String text, char c)
text - text with possible trailing characters, possibly empty, but
not null.c - the trailing character of interest, usually ' ' or '\n'public static boolean isEmptyTrim(String s)
s - String to be tested for emptiness.public static boolean isLegal(String candidate, String legalChars)
candidate - string to test.legalChars - characters than are legal for candidate.public static boolean isUnaccentedLowerCase(char c)
c - char to checkCharacter.isLowerCase(char)public static boolean isUnaccentedUpperCase(char c)
c - char to check.Character.isUpperCase(char)public static String leftPad(String s, int newLen, boolean chop)
s - String to be padded/chopped.newLen - length of new String desired.chop - true if Strings longer than newLen should be truncated to
newLen chars.public static long parseDirtyLong(String numStr)
numStr - String to be parsed.NumberFormatException - if the number is too big to fit in a long.public static long parseLongPennies(String numStr)
numStr - String to be parsed.NumberFormatException - if the number is too big to fit in a long.public static String penniesToString(long pennies)
pennies - long amount in pennies.public static int pluck(String s)
s - String containing the integer.public static String rep(char c, int count)
c - the character to repeatcount - the number of times to repeatpublic static String rightPad(String s, int newLen, boolean chop)
s - String to be padded/chopped.newLen - length of new String desired.chop - true if Strings longer than newLen should be truncated to
newLen chars.public static String squish(String s)
s - String to strip of blanks.public static String toBookTitleCase(String s)
s - String to convert. May be any mixture of case.public static String toHexString(int h)
h - number you want to convert to hextoString(Color)public static String toLZ(int i, int len)
i - the integer to be convertedlen - the length of the resulting string. Warning. It will chop the
result on the left if it is too long.public static String toString(Color c)
c - Color object whose html colour number you want as a stringtoHexString(int)public static String trimLeading(String s)
'\u0020' (the space character) are
considered to be white space.s - String to process. As always the original in unchanged.public static String trimTrailing(String s)
'\u0020' (the space character) are considered
to be white space.s - String to process. As always the original in unchanged.public static String getPart(String value, int nr, String def)
name - def - index - subset - public static String beforeLastIndex(String string, char c)
string - c - public static String afterLastIndex(String string, char c)
string - c - public static String truncate(String in, int length)
in - String to truncatelength - Max length of the stringpublic static String truncateNice(String in, int length)
in - String to truncatelength - Max length of the stringpublic static int[] getSelectedPart(String text, int caretPosition)
text - The string, must not be nullcaretPosition - Position of the caret.public static int[] getSelectedPart(String text, int caretPosition, String[] separators)
public static String getSelection(String text, int[] part, String def)
text - The text to croppart - The position in the text, first element is the begin second element the end of the selection.def - Return this if a selection is not possible.public static String replaceSelection(String text, int[] part, String replacement)
text - part - replacement - public static void appendRepeating(int amount,
char fill,
StringBuffer buffer)
amount - number of repeatingsfill - char to fillbuffer - targetpublic static String getRepeatig(int amount, char fill)
amount - number of repeatingsfill - char to fillpublic static boolean isWhitespace(char c)
c - public static int countCharacters(String in, char c)
in - c - public static int countCharacters(String in, char[] c)
in - c - public static String findInitials(String title, boolean upperOnly, boolean digits, int maxSize)
title - The input StringupperOnly - Set true if only collect upper characters in titledigits - Set true if digits (after whitespaces) should also be used.maxSize - Max size in characters of the initilas or 0 for no limit.Copyright © 2014. All rights reserved.