public final class StringMangler
extends java.lang.Object
Constructor and Description |
---|
StringMangler() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
condensePackageString(java.lang.String classname)
Condenses a classname by stripping down the package name to just the first character of each package name
segment.
|
static java.lang.CharSequence |
escapeJava(java.lang.String string)
Clean the input string of control characters that can
impact the output to the logs in harmful ways.
|
static java.lang.String |
maxStringLength(int max,
java.lang.String raw)
Smash a long string to fit within the max string length, by taking the middle section of the string and replacing them with an ellipsis "..."
|
public static java.lang.String condensePackageString(java.lang.String classname)
Examples: "org.eclipse.jetty.test.FooTest" = "oejt.FooTest" "org.eclipse.jetty.server.logging.LogTest" = "oejsl.LogTest"
classname
- the fully qualified class namepublic static java.lang.String maxStringLength(int max, java.lang.String raw)
Examples: .maxStringLength( 9, "Eatagramovabits") == "Eat...its" .maxStringLength(10, "Eatagramovabits") == "Eat...bits" .maxStringLength(11, "Eatagramovabits") == "Eata...bits"
max
- the maximum size of the string (minimum size supported is 9)raw
- the raw string to smashpublic static java.lang.CharSequence escapeJava(java.lang.String string)
string
- input stringCopyright © 1995–2024 Mort Bay Consulting. All rights reserved.