|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.molwind.util.Stringx
public final class Stringx
The Stringx class provides a collection of static methods for extended string processing.
Method Summary | |
---|---|
static java.lang.String |
after(java.lang.String source,
java.lang.String delimiter)
Tailors a source string to the string beginning after a given delimiter string. |
static java.lang.String |
afterLast(java.lang.String source,
java.lang.String delimiter)
Determines the string's portion after the last occurrence of the delimiter. |
static java.lang.String |
before(java.lang.String source,
java.lang.String delimiter)
Cuts a substring out of a source string ending at a given delimiter string. |
static java.lang.String |
concat(java.lang.String source)
Concatenates a paragraph of text into a single line by removing line ends and unnecessary blanks (i.e. |
static java.lang.String |
currentDateString(java.lang.String format)
Formats the current date according to the given format string. |
static java.lang.String |
deleteAll(java.lang.String source,
java.lang.String delete)
Deletes all occurrences of a substring from a source string. |
static java.lang.String |
deleteBetweenAll(java.lang.String source,
java.lang.String leftMark,
java.lang.String rightMark)
Deletes all occurrences of a substring between a left delimiter and a right delimiter string. |
static java.lang.String |
escapeChar(java.lang.String string)
Replaces in the given string all meta character sequences such as \n , \t etc. |
static java.lang.String |
escapeXmlAttributeValue(java.lang.String value)
Escapes all xml meta-characters in the given string by the corresponding entity char sequences. |
static java.lang.String |
extract(java.lang.String source,
java.lang.String leftMark,
java.lang.String rightMark)
Extracts a substring from a source string between a left and a right delimiter string. |
static java.lang.String[] |
extractAll(java.lang.String source,
java.lang.String leftMark,
java.lang.String rightMark)
Extracts a substring from a source string between a left and a right delimiter string. |
static java.lang.String |
fill(char character,
int length)
Constructs a string with the specified length that only consists of the given character. |
static int |
fractionDigits(java.lang.String num)
Counts the digits of the fraction of a number's string representation of a source string. |
static java.lang.String |
getClassName(java.lang.Class clazz)
Extracts the base class name (i.e. |
static java.lang.String |
getDateString(java.lang.String format,
java.util.Date date)
Formats a given date according to the format string. |
static java.lang.String |
getDefault(java.lang.String string,
java.lang.String def)
If the given string is null the default value provided is returned. |
static boolean |
isHexDigit(char character)
Checks whether a given char can be part of a hex string. |
static boolean |
isIdentifier(java.lang.String token)
Checks whether a given string follows the rules for identifiers or not. |
static java.lang.String |
localDate()
Formats the current date according to local formating conventions. |
static java.lang.String |
localDate(long date)
Formats the current date according to local formating conventions. |
static java.lang.String |
localMediumDate(long date)
Formats the current date according to local formating conventions to display medium format length. |
static java.lang.String |
localTime()
Formats the current time according to local formating conventions. |
static java.lang.String |
localTime(long date)
Formats the current time according to local formating conventions. |
static long |
parseDate(java.lang.String dateString)
Parses a date string according to local formating conventions. |
static long |
parseDate(java.lang.String dateString,
java.lang.String pattern)
Parses a date string conforming to a given date format pattern. |
static long |
parseTime(java.lang.String timeString)
Parses a time string according to local formating conventions. |
static java.lang.String |
strapp(java.lang.String source,
java.lang.String append)
Append a string to the source string if it has not been appended already. |
static java.lang.String |
strbreak(java.lang.String source,
java.lang.String insert,
int length)
Breaks up a string into smaller pieces of specified length appended by the given string. |
static java.lang.String |
strcut(java.lang.String source,
java.lang.String delimiter)
Discards all characters of a source string after a delimiter string. |
static java.lang.String |
strnewline(java.lang.String source,
int length)
Breaks up a string into smaller pieces of specified length appended by a newline. |
static java.lang.String[] |
strtok(java.lang.String source)
Determines all tokens of a source string that are delimited by whitespaces. |
static java.lang.String[] |
strtok(java.lang.String source,
java.lang.String delimiter)
Determines all tokens of a source string that are delimited by characters of a delimiter string. |
static java.lang.String[] |
strtok(java.lang.String source,
java.lang.String delimiter,
boolean trim)
Determines all tokens of a source string that are delimited by characters of a delimiter string, optionally trims the tokens. |
static java.lang.String |
strtrunc(java.lang.String source,
int length)
Truncates a string if it exceeds a certain length. |
static java.lang.String |
strtrunc(java.lang.String source,
int length,
java.lang.String cont)
Truncates a string if it exceeds a certain length and appends a given continuation string instead. |
static java.lang.String |
substitute(java.lang.String source,
java.lang.String substitute,
java.lang.String replacement)
Replaces one occurrence of a string to be substituted in a source string by a replacing string. |
static java.lang.String |
substituteAll(java.lang.String source,
java.lang.String substitute,
java.lang.String replacement)
Replaces all occurrences of a string to be substituted in a source string by a replacing string. |
static java.lang.String |
subtoken(java.lang.String source,
int index,
java.lang.String delimiter)
Extracts a substring from a source string beginning at a specified position and ending with a specific delimiter. |
static boolean |
toBoolean(java.lang.String string,
boolean def)
Converts a String to a boolean value. |
static java.awt.Color |
toColor(java.lang.String colorName)
Converts a color name or description like #FFCC00 into a
color object. |
static long |
toCRC(java.lang.String string)
Creates a crc checksum from a String. |
static double |
toDouble(java.lang.String string,
double def)
Converts a String to a double value. |
static float |
toFloat(java.lang.String string,
float def)
Converts a String to a float value. |
static int |
toInt(java.lang.String string,
int def)
Converts a String to an int value. |
static long |
toLong(java.lang.String string,
long def)
Converts a String to a long value. |
static java.util.Properties |
toProperties(java.lang.String itemString,
java.lang.String delimiter)
Creates a Properties object from a key-value pair string which looks something like item1 = value1; item2 = value2; ... |
static java.lang.String |
toStringList(java.util.Collection items,
java.lang.String delimiter)
Creates a string consisting of the array's items separated by the given delimiter. |
static java.lang.String |
toStringList(java.lang.Object[] items,
java.lang.String delimiter)
Creates a string consisting of the array's items separated by the given delimiter. |
static java.lang.String |
trimZero(java.lang.String source)
Removes all leading non-digits and zeros from a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String currentDateString(java.lang.String format)
dd.MM.YYYY
.
See SimpleDateFormat
for formatting options.
format
- the format string
public static java.lang.String getDateString(java.lang.String format, java.util.Date date)
dd.MM.YYYY
.
See SimpleDateFormat
for formatting options.
format
- the format stringdate
- the date
public static java.lang.String localDate()
public static java.lang.String localTime()
public static java.lang.String localDate(long date)
date
- milliseconds since era
public static java.lang.String localMediumDate(long date)
date
- milliseconds since era
public static long parseDate(java.lang.String dateString)
dateString
- a date string
-1
if an error
occurredpublic static long parseDate(java.lang.String dateString, java.lang.String pattern)
dateString
- a date stringpattern
- a date pattern
-1
if an error
occurredpublic static java.lang.String localTime(long date)
date
- milliseconds since era
public static long parseTime(java.lang.String timeString)
timeString
- a time string
-1
if an error
occurredpublic static java.lang.String before(java.lang.String source, java.lang.String delimiter)
source
- the source stringdelimiter
- a delimiter string
public static java.lang.String after(java.lang.String source, java.lang.String delimiter)
source
- the source stringdelimiter
- a delimiter string
public static java.lang.String afterLast(java.lang.String source, java.lang.String delimiter)
source
- the source stringdelimiter
- a delimiter string
public static java.lang.String strcut(java.lang.String source, java.lang.String delimiter)
source
- the source stringdelimiter
- a delimiter string
public static java.lang.String[] strtok(java.lang.String source, java.lang.String delimiter)
source
- the source stringdelimiter
- a delimiter string
public static java.lang.String toStringList(java.lang.Object[] items, java.lang.String delimiter)
items
- the string itemsdelimiter
- a delimiter string
public static java.lang.String toStringList(java.util.Collection items, java.lang.String delimiter)
items
- the string itemsdelimiter
- a delimiter string
public static java.lang.String[] strtok(java.lang.String source, java.lang.String delimiter, boolean trim)
source
- the source stringdelimiter
- a delimiter stringtrim
- true if tokens shall be trimmed
public static java.lang.String[] strtok(java.lang.String source)
source
- the source string
public static java.lang.String substitute(java.lang.String source, java.lang.String substitute, java.lang.String replacement)
source
- the source stringsubstitute
- the string to be substitutedreplacement
- the replacing string
public static java.lang.String substituteAll(java.lang.String source, java.lang.String substitute, java.lang.String replacement)
source
- the source stringsubstitute
- the string to be substitutedreplacement
- the replacing string
public static java.lang.String extract(java.lang.String source, java.lang.String leftMark, java.lang.String rightMark)
source
- the source stringleftMark
- left delimiter stringrightMark
- right delimiter string
public static java.lang.String[] extractAll(java.lang.String source, java.lang.String leftMark, java.lang.String rightMark)
source
- the source stringleftMark
- the left delimiter stringrightMark
- the right delimiter string
public static java.lang.String concat(java.lang.String source)
source
- the source string
public static java.lang.String deleteAll(java.lang.String source, java.lang.String delete)
source
- the source string.delete
- string to be deleted
public static int fractionDigits(java.lang.String num)
num
- string representation of a number
public static java.lang.String deleteBetweenAll(java.lang.String source, java.lang.String leftMark, java.lang.String rightMark)
source
- the source stringleftMark
- the left delimiter stringrightMark
- the right delimiter string
public static java.lang.String subtoken(java.lang.String source, int index, java.lang.String delimiter)
source
- the source stringindex
- the index to start withdelimiter
- delimiting string of the subtoken
public static java.lang.String strtrunc(java.lang.String source, int length)
source
- the source stringlength
- the maximum length
public static java.lang.String strtrunc(java.lang.String source, int length, java.lang.String cont)
source
- the source stringlength
- the maximum lengthcont
- the continuation to be appended
public static java.lang.String trimZero(java.lang.String source)
source
- the source string
public static java.lang.String fill(char character, int length)
character
- the characterlength
- number of characters
public static java.lang.String strbreak(java.lang.String source, java.lang.String insert, int length)
source
- the source stringinsert
- the string to insertlength
- the maximum line length
public static java.lang.String strnewline(java.lang.String source, int length)
source
- the source stringlength
- maximum line length
public static java.lang.String escapeChar(java.lang.String string)
\n
, \t
etc. by its corresponding character.
string
- string containing meta character sequences
public static boolean toBoolean(java.lang.String string, boolean def)
string
- the number stringdef
- the default value
public static int toInt(java.lang.String string, int def)
NumberFormatException
.
string
- the number stringdef
- the default value
public static float toFloat(java.lang.String string, float def)
NumberFormatException
.
string
- the number stringdef
- the default value
public static long toLong(java.lang.String string, long def)
NumberFormatException
.
string
- the number stringdef
- the default value
public static double toDouble(java.lang.String string, double def)
NumberFormatException
.
string
- the number stringdef
- the default value
public static java.lang.String getDefault(java.lang.String string, java.lang.String def)
string
- the number stringdef
- the default value
public static java.awt.Color toColor(java.lang.String colorName)
#FFCC00
into a
color object.
colorName
- the color name
public static long toCRC(java.lang.String string)
string
- the string
public static java.lang.String getClassName(java.lang.Class clazz)
clazz
- the class
public static boolean isIdentifier(java.lang.String token)
token
- the token to be analyzed
public static boolean isHexDigit(char character)
character
- the character to be analyzed
public static java.lang.String strapp(java.lang.String source, java.lang.String append)
source
- the source stringappend
- string to be appended
public static java.util.Properties toProperties(java.lang.String itemString, java.lang.String delimiter)
item1 = value1; item2 = value2; ...
itemString
- a string containing key-value pairsdelimiter
- delimiter string
public static java.lang.String escapeXmlAttributeValue(java.lang.String value)
value
- the value string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |