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 StringLSLine separator as returned by System.getProperty()static StringQUOTEstatic charQUOTE_CHAR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringfindAndStripPrefix(Set<String> prefixes, String s)static StringgetMillisString(long nanos)static StringgetPrefix(Set<String> prefixes, String s)static StringgetSecondsString(long nanos)static StringgetTimingString(long nanos)Get a String representing the specified number of nanoseconds, choosing the appropriate units based on magnitude of the value.static StringgetTimingString(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 Stringquote(Object o)static Stringquote(Object o, char leftHandChar)static StringreplaceSuffix(String s, String fromSuffix, String toSuffix)static StringstripPrefix(String s, String prefix)static StringstripPrefixAndSuffix(String s, String prefix, String suffix)static StringstripSuffix(String s, String suffix)static StringtoHexString(byte theByte)static StringtoHexString(byte[] bytes)static StringtoHexString(byte[] bytes, String delim)static StringtoLines(List<String> items)static StringtoString(Object o)static StringtoString(String[] args)static StringtoString(String delim, Object... args)Turn an array (or varargs) set of Objects into a String using the specified delimiter.static StringtoString(String delim, String... args)static StringtoString(Collection c)static StringtoString(Collection c, String delim)static String[]toStringArray(Object[] items)static <T> String[]toStringArray(Collection<T> c)static StringupperCaseFirstLetter(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
-
-