public class Utilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
masterFileSeparator
The file separator on the master.
|
static String |
masterPathSeparator
The path separator on the master.
|
static long |
TO_NANOS |
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static String |
convertPath(String path)
Attempts to convert a path from Windows to Unix.
|
static String |
escapeXML(String message)
Formats the message to be XML compatible, with the XML escaping.
|
static void |
escapeXML(String message,
StringBuilder msgBuffer)
Formats the message to be XML compatible, with the XML escaping.
|
static File |
getJarFile(Class clazz)
Obtains the jar file that contains the class in question.
|
static String |
getJavaHome()
Obtains the javaHome of the current JVM.
|
static boolean |
isIpv4Address(String name)
Tests if a given host name is an ipv4 address.
|
static String |
parseEscapedString(String s)
Parses a string escaped with \n, \t, \020, etc.
|
static List<NameValuePair<Integer>> |
parseHostPorts(String hostPorts)
Parses the host:port string and puts the list of host:port pairs
into a list.
|
static String |
parseHostPorts(String hostPorts,
List<NameValuePair<Integer>> hostPortList,
Set<String> hostSet)
Parses the host:port string and puts the list of host:port pairs
into the hostPortList.
|
static String |
print(Collection<?> c,
String separator) |
static int |
selectBucket(int current,
int total,
int buckets)
Simple, but frequently used utility function to determine which bucket
or group the current value belongs to, providing the total and the number
of buckets the values get divided into.
|
public static final long TO_NANOS
public static String masterFileSeparator
public static String masterPathSeparator
public static String convertPath(String path)
path
- The path to convertpublic static String parseEscapedString(String s)
s
- The string with backslashespublic static String getJavaHome()
public static File getJarFile(Class clazz)
clazz
- The given classpublic static List<NameValuePair<Integer>> parseHostPorts(String hostPorts)
hostPorts
- The host:port stringpublic static String parseHostPorts(String hostPorts, List<NameValuePair<Integer>> hostPortList, Set<String> hostSet)
hostPorts
- The host:port stringhostPortList
- The list to insert the host:port pairshostSet
- The set to insert host names, null if not neededpublic static int selectBucket(int current, int total, int buckets)
current
- The current valuetotal
- The total countbuckets
- The number of buckets to divide the set into.public static String escapeXML(String message)
message
- The raw messagepublic static void escapeXML(String message, StringBuilder msgBuffer)
message
- The raw messagemsgBuffer
- The buffer to write the escaped stringpublic static boolean isIpv4Address(String name)
name
- The host namepublic static String print(Collection<?> c, String separator)