public class MString extends Object
MString class.
| Modifier and Type | Field and Description |
|---|---|
static String |
CHARSET_DEFAULT
Constant
CHARSET_DEFAULT="CHARSET_UTF_8" |
static String |
CHARSET_ISO_8859_1
Constant
CHARSET_ISO_8859_1="ISO-8859-1" |
static String |
CHARSET_UTF_16
Constant
CHARSET_UTF_16="UTF-16" |
static String |
CHARSET_UTF_8
Constant
CHARSET_UTF_8="UTF-8" |
static String |
DEFAULT_SEPARATOR
Constant
DEFAULT_SEPARATOR="," |
static char[] |
WHITESPACE
Constant
WHITESPACE=new char[] { ' ', '\n', '\r', '\t' } |
| 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 |
afterIndex(String _s,
String _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 String |
afterLastIndex(String string,
String 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 |
beforeIndex(String _s,
String _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 |
beforeLastIndex(String string,
String 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)
compareRegexPattern.
|
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)
decodeCSV.
|
static String |
decodeUnicode(String _in)
decodeUnicode.
|
static String |
decodeURIComponent(String _in)
decodeURIComponent.
|
static String |
encodeCSV(String _field)
encodeCSV.
|
static String |
encodeCSVLine(String[] _fields)
encodeCSVLine.
|
static String |
encodeUnicode(String _in)
encodeUnicode.
|
static String |
encodeURIComponent(String _in)
encodeURIComponent.
|
static String |
encodeWebUnicode(String _in)
Encodes for the web.
|
static boolean |
equals(String in1,
String in2)
equals.
|
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)
getPart.
|
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)
getPart.
|
static String |
getPart(String value,
String separator,
int nr,
String def)
getPart.
|
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)
getSelectedPart.
|
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 String |
integerPart(String in)
integerPart.
|
static boolean |
isComposedOf(String in,
String composed)
Check a string against all characters in another 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 |
isIndex(String _s,
String _c)
Return, if the char is located in the string (indexOf).
|
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)
isUnicode.
|
static boolean |
isWhitespace(char c)
Return true if the character is in the list of whitespaces.
|
static String |
join(Iterator<?> src,
String glue)
join.
|
static String |
join(List<?> src,
String glue)
join.
|
static String |
join(String[] src,
char glue)
join.
|
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 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)
replaceSQLLikePattern.
|
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)
splitIgnoreEmpty.
|
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
CHARSET_UTF_8="UTF-8"public static final String CHARSET_UTF_16
CHARSET_UTF_16="UTF-16"public static final String CHARSET_ISO_8859_1
CHARSET_ISO_8859_1="ISO-8859-1"public static final char[] WHITESPACE
WHITESPACE=new char[] { ' ', '\n', '\r', '\t' }public static final String DEFAULT_SEPARATOR
DEFAULT_SEPARATOR=","public static final String CHARSET_DEFAULT
CHARSET_DEFAULT="CHARSET_UTF_8"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 - a String object.public static String[] split(String _in, String _pattern)
public static String[] splitIgnoreEmpty(String _in, String _pattern)
public static String[] splitIgnoreEmpty(String _in, String _pattern, boolean trim)
splitIgnoreEmpty.
public static String replaceAll(String _src, String _pattern, String _replacement)
public static void replaceAll(StringBuffer _src, String _pattern, String _replacement)
_src - a StringBuffer object._pattern - a String object._replacement - a String object.public static boolean isIndex(String _s, String _c)
public static String beforeIndex(String _s, String _c)
public static String afterIndex(String _s, String _c)
public static boolean isIndex(String _s, char _c)
_s - a String object._c - a char.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 - a String object._c - an array of char.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 - a String object._c - an array of char.offset - a int.public static int indexOf(String _s, char[] _c)
_s - a String object._c - an array of char.public static String encodeWebUnicode(String _in)
public static boolean isUnicode(String _in, char _joker)
isUnicode.
_in - a String object._joker - a char.public static boolean compareRegexPattern(String str, String pattern)
compareRegexPattern.
public static boolean compareSQLLikePattern(String str, String pattern)
public static boolean compareFsLikePattern(String str, String pattern)
public static String replaceSQLLikePattern(String str, String pattern, String replace)
replaceSQLLikePattern.
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 String rep(char c, int count)
c - the character to repeatcount - the number of times to repeatString object.public 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)
public static String beforeLastIndex(String string, char c)
public static String afterLastIndex(String string, char c)
public static String beforeLastIndex(String string, String c)
public static String afterLastIndex(String string, 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)
getSelectedPart.
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)
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 fillString object.public static boolean isWhitespace(char c)
c - a char.public static int countCharacters(String in, char c)
in - a String object.c - a char.public static int countCharacters(String in, char[] c)
in - a String object.c - an array of char.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.public static boolean isComposedOf(String in, String composed)
Copyright © 2016. All Rights Reserved.