|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.core.SystemUtil
public final class SystemUtil
System Utilities. These are helper functions for dealing with system functions.
| Method Summary | |
|---|---|
static void |
checkCalledFromUnitTest(String className,
String methodName)
Checks to make sure we are the specified class and method are invoked from unit tests. |
static int |
compare(boolean first,
boolean second)
Convenience function that calls compare(boolean,boolean,boolean)
with falseLessThanTrue == true. |
static int |
compare(boolean first,
boolean second,
boolean falseLessThanTrue)
Compares first and second and returns the
result. |
static int |
compare(Comparable first,
Comparable second)
Compares first to second and returns a
negative, zero or postive integer as first is
less than, equal to or greater than second,
respectively. |
static int |
compare(Comparable first,
Comparable second,
boolean nullComparesGreaterThanNonNull)
Compares first to second and returns a
negative, zero or postive integer as first is
less than, equal to or greater than second,
respectively. |
static int |
compare(Object first,
Object second,
Comparator comparator)
Compares first to second using the supplied
comparator and returns a negative, zero or postive integer
as first is less than, equal to or greater than
second, respectively. |
static int |
compare(Object first,
Object second,
Comparator comparator,
boolean nullComparesGreaterThanNonNull)
Compares first to second using the supplied
comparator and returns a negative, zero or postive integer
as first is less than, equal to or greater than
second, respectively. |
static void |
consumeException(String reason,
Throwable t)
Prevent a compiler warning when you don't want to do something in a catch block. |
static void |
consumeInterruptedException(InterruptedException e)
Provide proper handling of InterruptedException from wait() and sleep() methods. |
static boolean |
equal(Object one,
Object two)
Check if two objects are equal in a null safe manner. |
static PrintWriter |
err()
Get a Writer version of System.err |
static void |
exit(int code)
Terminate the java process. |
static String |
fixRelativePath(String path)
Modify a relative file path to use custom config and directory locations |
static void |
flushOutput()
Flush system out and system error. |
static String |
getArchitecture()
Return the OS architecture of this VM |
static String |
getBootClassPath()
Returns the boot classpath of this VM. |
static String |
getClassPath()
Return the class path of this VM. |
static String |
getCompleteClassPath()
Returns the complete classpath used by this VM. |
static File |
getConfigDirectory()
Returns the config directory. |
static String |
getConfigDirectoryString()
|
static URL |
getConfigURL()
Returns the config URL. |
static String |
getCwd()
Get the current working directory as a String. |
static File |
getCwdFile()
Get the current working directory as a File |
static Map |
getenv()
For internal use only |
static String |
getenv(String envVar)
For internal use only |
static boolean |
getExitException()
Used for unit tests to check if an exception will be thrown when SystemUtil.exit() is calld. |
static String |
getFileEncoding()
Return the default file encoding of this VM |
static InetAddress |
getHost()
Get the InetAddress for this machine. |
static String |
getHostname()
Get the hostname of this machine. |
static File |
getInstallDirectory()
Returns the installation directory. |
static File |
getInternalDirectory()
Returns the internal directory. |
static String |
getJavaVendor()
Return this VM's vendor |
static File |
getLocalTempDirectory()
Returns the temporary directory for the local server This directory can be used to store temporary files which do not need to be shared accross multiple processes |
static String |
getOperatingSystem()
Return the OS name of this VM |
static String |
getOperatingSystemType()
Return the OS type of this VM. |
static String |
getPathSeparator()
Return the path separator of this VM. |
static char |
getPathSeparatorChar()
Return the path separator of this VM. |
static String |
getPwd()
Find the current working directory. |
static Throwable |
getRootCause(Throwable t)
Returns the root cause that cause that causes this exception. |
static File |
getSharedTempDirectory()
Returns the temporary directory which can be shared accross multiple processes This directory can be used to store temporary files which require to be accessible by different nodes |
static File |
getSystemDirectory()
Returns the sytem directory. |
static String |
getUserName()
Return the current user name |
static int |
hashCode(Object object)
Convenience method that returns the hashCode() of
object. |
static int |
hostAsInt()
helper function to convert hostname into int for database storage |
static BufferedReader |
in()
Get a Reader version of System.in |
static boolean |
isAIX()
Determine if the system is a AIX based system. |
static boolean |
isDevelopment()
Are we in development, not production mode? This is a low level check needed for internal testing. |
static boolean |
isHP()
Determine if the system is a HP based system. |
static boolean |
isLinux()
Determine if the system is a Linux based system. |
static boolean |
isSunOS()
Determine if the system is a Sun based system. |
static boolean |
isWin32()
Determine if the system is a Windows based system. |
static boolean |
memoryCompare(byte[] a,
int aIndex,
byte[] b,
int bIndex,
int len)
Compares len bytes in array a starting with byte aIndex with len bytes in array b starting with byte bIndex. |
static PrintWriter |
out()
Get a Writer version of System.out |
static void |
setConfigDirectory(String configDir)
Defines the location of the config directory. |
static void |
setErr(PrintWriter pw)
Set the output stream returned by SystemUtil.out(); |
static void |
setExitException(boolean value)
Used for unit tests to cause SystemUtil.exit() to thrown an exception rather than bring down the process. |
static void |
setJ2EEServerInUse()
|
static void |
setJ2EEServerInUse(boolean flag)
|
static void |
setLocalTempDirectory(String tempDir)
Defines the location of the local temporary directory. |
static void |
setOut(PrintWriter pw)
Set the output stream returned by SystemUtil.out(); |
static void |
setSharedTempDirectory(String tempDir)
Defines the location of the shared temporary directory. |
static void |
setSystemDirectory(String systemDir)
Defines the location of the system directory. |
static void |
sleep(long sleepTime)
|
static String |
stackTrace()
Get a string which represents the current call stack. |
static String |
stackTrace(Throwable t)
Get a string which represents the Throwable's call stack. |
static boolean |
usingJ2EEServer()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void sleep(long sleepTime)
public static boolean equal(Object one,
Object two)
one - the first of two objects to comparetwo - the second of two objects to compare
public static int hashCode(Object object)
hashCode() of
object. The case of a null
object is handled; zero is returned.
This method is complementary to the method equal(java.lang.Object, java.lang.Object) which tests two
objects for equality in a null safe manner.
object - the object for which to return the hashcode
0 if object is
null
public static int compare(Comparable first,
Comparable second)
first to second and returns a
negative, zero or postive integer as first is
less than, equal to or greater than second,
respectively.
first and second may be null.
A null object is always considered to be less than
any non-null object.
first - the first Comparable to compare,
may be nullsecond - the first Comparable to compare,
may be null
first
and second
public static int compare(Comparable first,
Comparable second,
boolean nullComparesGreaterThanNonNull)
first to second and returns a
negative, zero or postive integer as first is
less than, equal to or greater than second,
respectively.
first and second may be null.
A null object is always considered to be less than
any non-null object.
first - the first Comparable to compare,
may be nullsecond - the first Comparable to compare,
may be null
first
and second
public static int compare(Object first,
Object second,
Comparator comparator)
first to second using the supplied
comparator and returns a negative, zero or postive integer
as first is less than, equal to or greater than
second, respectively.
first and second may be null.
A null object is always considered to be less than
any non-null object.
first - the first Comparable to compare,
may be nullsecond - the first Comparable to compare,
may be nullcomparator - the Comparator to use when comparing, may
not be null
first
and second
public static int compare(Object first,
Object second,
Comparator comparator,
boolean nullComparesGreaterThanNonNull)
first to second using the supplied
comparator and returns a negative, zero or postive integer
as first is less than, equal to or greater than
second, respectively.
first and second may be null.
A null object is always considered to be less than
any non-null object.
first - the first Comparable to compare,
may be nullsecond - the first Comparable to compare,
may be nullcomparator - the Comparator to use when comparing
first
and second
public static int compare(boolean first,
boolean second,
boolean falseLessThanTrue)
first and second and returns the
result.
If falseLessThanTrue == true then -1 is
returned if !first && second and +1 is
returned if first && !second and 0
when first == second.
If falseLessThanTrue == false the result is the opposite.
first - the first of the two values to comparesecond - the second of the two values to comparefalseLessThanTrue - whether or not false should be
considered less than true
public static int compare(boolean first,
boolean second)
compare(boolean,boolean,boolean)
with falseLessThanTrue == true.
public static void setExitException(boolean value)
public static boolean getExitException()
public static final void checkCalledFromUnitTest(String className,
String methodName)
className - the class namemethodName - the method namepublic static void exit(int code)
code - the exit code to pass to System.exit()
public static boolean memoryCompare(byte[] a,
int aIndex,
byte[] b,
int bIndex,
int len)
a - array of memory to compare with baIndex - where to start compare in array ab - array of memory to compare with abIndex - where to start compare in array blen - the number of bytes to compare.
public static String getHostname()
ariba.rpc.server.Server#hostname()public static InetAddress getHost()
public static int hostAsInt()
public static String getPwd()
public static String getCwd()
public static File getCwdFile()
public static String getFileEncoding()
public static String getClassPath()
public static String getBootClassPath()
public static String getCompleteClassPath()
public static String getPathSeparator()
public static char getPathSeparatorChar()
public static String getArchitecture()
public static String getOperatingSystem()
public static String getOperatingSystemType()
public static String getJavaVendor()
public static String getUserName()
public static final boolean isWin32()
public static final boolean isSunOS()
public static final boolean isHP()
public static final boolean isAIX()
public static final boolean isLinux()
public static BufferedReader in()
public static PrintWriter out()
public static PrintWriter err()
public static void setOut(PrintWriter pw)
public static void setErr(PrintWriter pw)
public static void flushOutput()
public static final void consumeException(String reason,
Throwable t)
reason - text reason for why you don't want to do anything.t - throwable (usally exception) that was thrown.public static final void consumeInterruptedException(InterruptedException e)
e - exception that was thrown.public static String stackTrace()
public static String stackTrace(Throwable t)
t - the Throwable to get the stack trace from
public static Throwable getRootCause(Throwable t)
t - the Throwable instance whose root cause is to be returned. If this is null, then null is returned.
nullpublic static Map getenv()
public static String getenv(String envVar)
envVar - the name of the requested environment variable. Must not be null.
public static void setJ2EEServerInUse()
public static void setJ2EEServerInUse(boolean flag)
public static boolean usingJ2EEServer()
public static final void setSystemDirectory(String systemDir)
systemDir - path of the system directory. Cannot be null.getSystemDirectory()public static final void setConfigDirectory(String configDir)
configDir - path of the config directory. Cannot be null.getConfigDirectory()public static final void setLocalTempDirectory(String tempDir)
tempDir - path of the temp directory. Cannot be null.getLocalTempDirectory()public static final void setSharedTempDirectory(String tempDir)
tempDir - path of the temp directory. Cannot be null.getSharedTempDirectory()public static File getSystemDirectory()
public static File getConfigDirectory()
public static String getConfigDirectoryString()
public static URL getConfigURL()
public static File getLocalTempDirectory()
public static File getSharedTempDirectory()
public static String fixRelativePath(String path)
public static File getInstallDirectory()
public static boolean isDevelopment()
ServerInterface.isProduction()public static File getInternalDirectory()
null if the internal directory
does not exist.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||