Package org.glassfish.admin.amx.util
Class StringUtil
- java.lang.Object
-
- org.glassfish.admin.amx.util.StringUtil
-
public final class StringUtil extends Object
Escapes/unescapes strings
-
-
Field Summary
Fields Modifier and Type Field Description static String
LS
Line separator as returned by System.getProperty()static String
QUOTE
static char
QUOTE_CHAR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
findAndStripPrefix(Set<String> prefixes, String s)
static String
getMillisString(long nanos)
static String
getPrefix(Set<String> prefixes, String s)
static String
getSecondsString(long nanos)
static String
getTimingString(long nanos)
Get a String representing the specified number of nanoseconds, choosing the appropriate units based on magnitude of the value.static String
getTimingString(long nanos, TimeUnit timeUnit)
static List<String>
objectNamesToStrings(Collection<ObjectName> objectNames)
Convert ObjectName into a Set of String.static String[]
objectNamesToStrings(ObjectName[] objectNames)
Convert a Set of ObjectName into a Set of Stringstatic String
quote(Object o)
static String
quote(Object o, char leftHandChar)
static String
replaceSuffix(String s, String fromSuffix, String toSuffix)
static String
stripPrefix(String s, String prefix)
static String
stripPrefixAndSuffix(String s, String prefix, String suffix)
static String
stripSuffix(String s, String suffix)
static String
toHexString(byte theByte)
static String
toHexString(byte[] bytes)
static String
toHexString(byte[] bytes, String delim)
static String
toLines(List<String> items)
static String
toString(Object o)
static String
toString(String[] args)
static String
toString(String delim, Object... args)
Turn an array (or varargs) set of Objects into a String using the specified delimiter.static String
toString(String delim, String... args)
static String
toString(Collection c)
static String
toString(Collection c, String delim)
static String[]
toStringArray(Object[] items)
static <T> String[]
toStringArray(Collection<T> c)
static String
upperCaseFirstLetter(String s)
-
-
-
Field Detail
-
QUOTE_CHAR
public static final char QUOTE_CHAR
- See Also:
- Constant Field Values
-
QUOTE
public static final String QUOTE
- See Also:
- Constant Field Values
-
LS
public static final String LS
Line separator as returned by System.getProperty()
-
-
Method Detail
-
toHexString
public static String toHexString(byte theByte)
-
toHexString
public static String toHexString(byte[] bytes)
-
stripPrefixAndSuffix
public static String stripPrefixAndSuffix(String s, String prefix, String suffix)
-
toString
public static String toString(String delim, Object... args)
Turn an array (or varargs) set of Objects into a String using the specified delimiter.
-
getPrefix
public static String getPrefix(Set<String> prefixes, String s)
- Returns:
- the prefix found, or null if not found
-
findAndStripPrefix
public static String findAndStripPrefix(Set<String> prefixes, String s)
- Returns:
- the String after stripping the prefix
- Throws:
IllegalArgumentException
- if no prefix found
-
getSecondsString
public static String getSecondsString(long nanos)
- Parameters:
nanos
- elapsed nanoseconds- Returns:
- a String describing the elapsed duration in seconds
-
getMillisString
public static String getMillisString(long nanos)
- Parameters:
nanos
- elapsed nanoseconds- Returns:
- a String describing the elapsed duration in seconds
-
getTimingString
public static String getTimingString(long nanos)
Get a String representing the specified number of nanoseconds, choosing the appropriate units based on magnitude of the value.- Parameters:
nanos
- elapsed nanoseconds- Returns:
- a String describing the elapsed duration
-
toStringArray
public static <T> String[] toStringArray(Collection<T> c)
- Returns:
- String[]
-
toString
public static String toString(Collection c, String delim)
- Returns:
- a String
-
toString
public static String toString(Collection c)
-
objectNamesToStrings
public static List<String> objectNamesToStrings(Collection<ObjectName> objectNames)
Convert ObjectName into a Set of String. The resulting strings are more readable than just a simple toString() on the ObjectName; they are sorted and output in preferential order.
-
objectNamesToStrings
public static String[] objectNamesToStrings(ObjectName[] objectNames)
Convert a Set of ObjectName into a Set of String
-
-