public class MaryUtils extends Object
Modifier and Type | Field and Description |
---|---|
protected static char[] |
germanToAsciiLetterTable |
static String |
LOGPREFIX |
protected static char[] |
punctuationTable |
protected static char[] |
toGermanLetterTable |
protected static char[] |
toItalianLetterTable |
Constructor and Description |
---|
MaryUtils() |
Modifier and Type | Method and Description |
---|---|
static Map<String,String> |
arrayToMap(String[] a)
Create a map from an Object array which contains paired entries (key, value, key, value, ....).
|
static long |
availableMemory()
Determine the amount of available memory.
|
static File |
createSelfDeletingTempFile(int lifetimeInSeconds)
Create a temporary file that will be deleted after a specified number of seconds.
|
static String |
getExtension(File f)
Get the extension of a file.
|
static String |
getFirstMeaningfulMessage(Throwable t)
From the given throwable or its cause, or cause's cause, etc., get the first one that has a non-empty message, and return
that message.
|
static org.apache.log4j.Logger |
getLogger(Class clazz)
Provide a Logger object whose name is built from MaryUtils.LOGPREFIX and the given nameSuffix.
|
static org.apache.log4j.Logger |
getLogger(String nameSuffix)
Provide a Logger object whose name is built from MaryUtils.LOGPREFIX and the given nameSuffix.
|
static int |
getNumber(String string)
For a string containing a number as judged by
isNumber() , return the numerical value, rounded to an integer. |
static int |
getNumberDelta(String string)
For a string containing a number delta as judged by
isNumberDelta() , return the numerical value, rounded to an
integer. |
static int |
getPercentageDelta(String string)
For a string containing a percentage delta as judged by
isPercentageDelta() , return the numerical value,
rounded to an integer. |
static double |
getSemitonesDelta(String string)
For a string containing a semitones delta as judged by
isSemitonesDelta() , return the numerical value, as a
double. |
static String |
getThrowableAndCausesAsString(Throwable t)
Apply the toString() method recursively to this throwable and all its causes.
|
static int |
getUnsignedNumber(String string)
For a string containing an unsigned number as judged by
isUnsignedNumber() , return the numerical value,
rounded to an integer. |
static double |
getUnsignedSemitones(String string)
For a string containing an unsigned semitones expression as judged by
isUnsignedSemitones() , return the
numerical value as a double. |
static int |
indexOf(byte[] bytes,
byte[] pattern)
Check if bytes contains a subsequence identical with pattern, and return the index position.
|
static boolean |
isLittleEndian() |
static boolean |
isLog4jConfigured()
Returns true if it appears that log4j have been previously configured.
|
static boolean |
isNumber(String string)
Tell whether the string contains a number.
|
static boolean |
isNumberDelta(String string)
Tell whether the string contains a positive or negative number delta, i.e., a number with an obligatory + or - sign.
|
static boolean |
isPercentageDelta(String string)
Tell whether the string contains a positive or negative percentage delta, i.e., a percentage number with an obligatory + or
- sign.
|
static boolean |
isSemitonesDelta(String string)
Tell whether the string contains a positive or negative semitones delta, i.e., a semitones number with an obligatory + or -
sign, such as "+3.2st" or "-13.2st".
|
static boolean |
isUnsignedNumber(String string)
Tell whether the string contains an unsigned number.
|
static boolean |
isUnsignedSemitones(String string)
Tell whether the string contains an unsigned semitones expression, such as "12st" or "5.4st".
|
static boolean |
isWindows() |
static String |
joinStrings(Collection<String> strings)
Join a collection of strings into a single String object, in the order indicated by the collection's iterator.
|
static String |
locale2xmllang(Locale locale)
Convert a locale into a string that is conform with XML's xml:lang attribute.
|
static String |
normaliseUnicodeLetters(String unicodeText,
Locale targetLocale)
Normalise the Unicode text by mapping "exotic" letter characters to "standard" ones.
|
static String |
normaliseUnicodePunctuation(String unicodeText)
Normalise the Unicode text by mapping "exotic" punctuation characters to "standard" ones.
|
static int |
romanToInt(String romanNumber) |
static int |
shellExecute(String strCommand) |
static int |
shellExecute(String strCommand,
boolean bDisplayProgramOutput) |
static String[] |
splitIntoSensibleXMLUnits(String s) |
static Locale |
string2locale(String localeString) |
static Character[] |
StringToCharacterArray(String s) |
static boolean |
subsumes(Locale general,
Locale specific)
Test for lax Locale equality.
|
static String |
toHumanReadableSize(long byteCount) |
static void |
writeCopyrightNotice(PrintWriter out,
String commentChar) |
public static final String LOGPREFIX
protected static final char[] punctuationTable
protected static final char[] toGermanLetterTable
protected static final char[] toItalianLetterTable
protected static final char[] germanToAsciiLetterTable
public static Map<String,String> arrayToMap(String[] a)
a
- apublic static String joinStrings(Collection<String> strings)
strings
- a collection containing exclusively String objectspublic static int indexOf(byte[] bytes, byte[] pattern)
bytes
- bytespattern
- patternpublic static String getExtension(File f)
f
- fpublic static int romanToInt(String romanNumber)
public static boolean isPercentageDelta(String string)
string
- stringpublic static int getPercentageDelta(String string)
isPercentageDelta()
, return the numerical value,
rounded to an integer.string
- stringpublic static boolean isSemitonesDelta(String string)
string
- stringpublic static double getSemitonesDelta(String string)
isSemitonesDelta()
, return the numerical value, as a
double.string
- stringpublic static boolean isNumberDelta(String string)
string
- stringpublic static int getNumberDelta(String string)
isNumberDelta()
, return the numerical value, rounded to an
integer.string
- stringpublic static boolean isUnsignedSemitones(String string)
string
- stringpublic static double getUnsignedSemitones(String string)
isUnsignedSemitones()
, return the
numerical value as a double.string
- stringpublic static boolean isUnsignedNumber(String string)
string
- stringpublic static int getUnsignedNumber(String string)
isUnsignedNumber()
, return the numerical value,
rounded to an integer.string
- stringpublic static boolean isNumber(String string)
string
- stringpublic static int getNumber(String string)
isNumber()
, return the numerical value, rounded to an integer.string
- stringpublic static String locale2xmllang(Locale locale)
locale
- a locale, must not be nullIllegalArgumentException
- if locale is nullpublic static boolean subsumes(Locale general, Locale specific)
general
- generalspecific
- specificpublic static long availableMemory()
(max - total) + free
.public static File createSelfDeletingTempFile(int lifetimeInSeconds) throws IOException
lifetimeInSeconds
- the number of seconds after which the file will be deleted -- e.g., 3600 means that the file will be deleted one
hour after creation.IOException
- IOExceptionpublic static String normaliseUnicodePunctuation(String unicodeText)
unicodeText
- a string that may include "exotic" punctuation characterspublic static String normaliseUnicodeLetters(String unicodeText, Locale targetLocale)
unicodeText
- a string that may include "exotic" letter characterstargetLocale
- the locale against which normalisation is to be performed.public static String getThrowableAndCausesAsString(Throwable t)
t
- the throwable to print.public static boolean isWindows()
public static boolean isLittleEndian()
public static int shellExecute(String strCommand)
public static int shellExecute(String strCommand, boolean bDisplayProgramOutput)
public static void writeCopyrightNotice(PrintWriter out, String commentChar)
public static String toHumanReadableSize(long byteCount)
public static org.apache.log4j.Logger getLogger(String nameSuffix)
nameSuffix
- the suffix to use for the logger name.public static org.apache.log4j.Logger getLogger(Class clazz)
clazz
- the class to use for the logger name.public static boolean isLog4jConfigured()
Copyright © 2000–2016 DFKI GmbH. All rights reserved.