public final class Utils extends Object
| Modifier and Type | Method and Description |
|---|---|
static StackTraceElement |
getCaller()
Returns stack trace element corresponding to a class that calls
logging methods.
|
static String |
getCallerClassName()
Returns a name of a class that calls logging methods.
|
static String |
shorten(String string,
int count,
int length)
Shorten string
|
static String |
shortenClassName(String className,
int count,
int maxLength)
Shortens class name till the specified length.
|
public static String getCallerClassName()
getCaller() because
this method tries to use SecurityManager to get
caller context.public static StackTraceElement getCaller()
public static String shorten(String string, int count, int length)
string - modified string.count - the desired minimum length of result.length - the desired maximum of string length.
| Example | Result |
|---|---|
| %6(text) | ' text' |
| %-6(text) | 'text ' |
| %.3(text) | 'tex' |
| %.-3(text) | 'ext' |
public static String shortenClassName(String className, int count, int maxLength)
className - the class name.maxLength - the desired maximum length of result.count - the desired maximum count of packagesCopyright © 2015. All Rights Reserved.