|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.semaine.util.SEMAINEUtils
public class SEMAINEUtils
Field Summary | |
---|---|
static java.lang.String |
LOGPREFIX
|
Constructor Summary | |
---|---|
SEMAINEUtils()
|
Method Summary | |
---|---|
static java.io.File |
getConfigFile(java.lang.String configSystemProperty)
Get a config file as defined in the given system property. |
static java.io.File |
getConfigFile(java.lang.String configSystemProperty,
java.lang.String defaultValue)
Get a config file as defined in the given system property, using the given default value if the property is not set. |
static org.apache.log4j.Logger |
getLogger(java.lang.Class clazz)
Provide a Logger object whose name is built from SEMAINEUtils.LOGPREFIX and the name of the given class as a suffix. |
static org.apache.log4j.Logger |
getLogger(java.lang.String nameSuffix)
Provide a Logger object whose name is built from SEMAINEUtils.LOGPREFIX and the given nameSuffix. |
static long |
getLongProperty(java.lang.String propertyName,
long defaultValue)
Try to get the system property with the given name as a long value. |
static java.lang.String |
getReaderAsString(java.io.Reader reader)
|
static java.lang.String |
getStreamAsString(java.io.InputStream inputStream,
java.lang.String encoding)
|
static boolean |
isLog4jConfigured()
Returns true if it appears that log4j have been previously configured. |
static java.lang.String |
locale2xmllang(java.util.Locale locale)
Convert a locale into a string that is conform with XML's xml:lang attribute. |
static float |
parseFloat(java.lang.String valueString,
float defaultValue)
Convert the given string into a float value, if possible. |
static long |
parseLong(java.lang.String valueString,
long defaultValue)
Convert the given string into a long value, if possible. |
static void |
setupLog4j()
Set up the log4j logging system using a default configuration. |
static java.util.Locale |
string2locale(java.lang.String localeString)
|
static java.util.Map<java.lang.String,java.lang.String> |
string2map(java.lang.String s,
boolean keysFirst)
For a given string containing lines of key-value pairs, construct a map of key-value pairs. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String LOGPREFIX
Constructor Detail |
---|
public SEMAINEUtils()
Method Detail |
---|
public static boolean isLog4jConfigured()
public static void setupLog4j()
public static org.apache.log4j.Logger getLogger(java.lang.String nameSuffix)
nameSuffix
- the suffix to use for the logger name.
public static org.apache.log4j.Logger getLogger(java.lang.Class clazz)
the
- class whose simple name to use asthe suffix for the logger name.
public static java.io.File getConfigFile(java.lang.String configSystemProperty)
configSystemProperty
- the name of a config setting containing the filename and path of the config file to load, e.g. "semaine.character-config".
public static java.io.File getConfigFile(java.lang.String configSystemProperty, java.lang.String defaultValue)
configSystemProperty
- the name of a config setting containing the filename and path of the config file to load, e.g. "semaine.character-config".
public static java.lang.String getStreamAsString(java.io.InputStream inputStream, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.lang.String getReaderAsString(java.io.Reader reader) throws java.io.IOException
java.io.IOException
public static java.util.Locale string2locale(java.lang.String localeString)
public static java.lang.String locale2xmllang(java.util.Locale locale)
locale
- a locale, must not be null
java.lang.IllegalArgumentException
- if locale is nullpublic static java.util.Map<java.lang.String,java.lang.String> string2map(java.lang.String s, boolean keysFirst)
key1 value1
key2 value2
Leading or trailing whitespace is ignored.
If a line contains only a single field, it is treated as a key that maps to the empty string.
Empty lines are ignored.
s
- keysFirst
- if true, the first item in a line is the key, and the rest is the value; if false, the first item in the line is the value and the rest is the key.
public static float parseFloat(java.lang.String valueString, float defaultValue)
valueString
- string to be converted into a float.defaultValue
- value to use if the string cannot be converted into a float.
public static long parseLong(java.lang.String valueString, long defaultValue)
valueString
- string to be converted into a long.defaultValue
- value to use if the string cannot be converted into a long.
public static long getLongProperty(java.lang.String propertyName, long defaultValue)
propertyName
- defaultValue
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |