public final class Utility extends Object
Constructor and Description |
---|
Utility() |
Modifier and Type | Method and Description |
---|---|
static int |
bytesToInt(byte[] array,
int offset)
Unmarshal a byte array to an integer.
|
static long |
bytesToLong(byte[] array,
int offset)
Unmarshal a byte array to an long.
|
static void |
checkJVMVersion() |
static char[] |
convertByteArrayToCharArray(byte[] byteArray,
String charset)
Convert the byte array to char array with respect to given charset.
|
static byte[] |
convertCharArrayToByteArray(char[] charArray,
String strCharset)
Convert the char array to byte array with respect to given charset.
|
static ClassLoader |
getClassLoader()
Get the current thread's context class loader which is set to
the CommonClassLoader by ApplicationServer
|
static String |
getEnvOrProp(String name)
Return the value for a given name from the System Properties or the
Environmental Variables.
|
static String |
getLocalAddress()
Return the hostname of the local machine.
|
static String |
getLocalHost()
Return the hostname of the local machine.
|
static Properties |
getPropertiesFromFile(String file) |
static void |
intToBytes(int value,
byte[] array,
int offset)
Marshal an integer to a byte array.
|
static short |
intToShort(int value) |
static void |
invokeApplicationMain(Class mainClass,
String[] args)
Verify and invoke main if present in the specified class.
|
static void |
invokeSetMethod(Object obj,
String prop,
String value) |
static void |
invokeSetMethodCaseInsensitive(Object obj,
String prop,
String value) |
static Class |
loadClass(String className)
Loads the class with the common class loader.
|
static void |
longToBytes(long value,
byte[] array,
int offset)
Marshal an long to a byte array.
|
static Remote |
lookupObject(String publishedName,
Class anInterface)
This is a convenience method to lookup a remote object by name within
the naming context.
|
static ClassLoader |
setContextClassLoader(ClassLoader newClassLoader)
Utility routine for setting the context class loader.
|
static void |
setEnvironment() |
static int |
shortToInt(short value) |
static byte[] |
toByteArray(ByteBuffer bb)
Returns a byte array for the valid bytes in a ByteBuffer.
|
static char[] |
toCharArray(CharBuffer cb)
Returns a character array for the valid characters in a CharBuffer.
|
public static void checkJVMVersion()
public static Properties getPropertiesFromFile(String file) throws IOException
IOException
public static String getLocalHost()
public static String getLocalAddress()
public static Remote lookupObject(String publishedName, Class anInterface) throws NamingException
NamingException
- if the object with that
name could not be found.public static char[] toCharArray(CharBuffer cb)
cb
- public static byte[] toByteArray(ByteBuffer bb)
bb
- public static int bytesToInt(byte[] array, int offset)
array
- The array of bytes.offset
- The offset from which to start unmarshalling.public static void intToBytes(int value, byte[] array, int offset)
array
- The array of bytes.offset
- The offset from which to start marshalling.public static long bytesToLong(byte[] array, int offset)
array
- The array of bytes.offset
- The offset from which to start unmarshalling.public static void longToBytes(long value, byte[] array, int offset)
array
- The array of bytes.offset
- The offset from which to start marshalling.public static void invokeApplicationMain(Class mainClass, String[] args) throws InvocationTargetException, IllegalAccessException, ClassNotFoundException
public static void invokeSetMethod(Object obj, String prop, String value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
public static void invokeSetMethodCaseInsensitive(Object obj, String prop, String value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
public static short intToShort(int value)
public static int shortToInt(short value)
public static ClassLoader getClassLoader()
public static Class loadClass(String className) throws ClassNotFoundException
className
- the class nameif
- the class is not found.ClassNotFoundException
public static ClassLoader setContextClassLoader(ClassLoader newClassLoader)
public static void setEnvironment()
public static String getEnvOrProp(String name)
name
- - the name of the System Property or Environmental Variablepublic static char[] convertByteArrayToCharArray(byte[] byteArray, String charset) throws CharacterCodingException
byteArray
- charset
- null or "" means default charsetCharacterCodingException
public static byte[] convertCharArrayToByteArray(char[] charArray, String strCharset) throws CharacterCodingException
charArray
- strCharset
- null or "" means default charsetCharacterCodingException
Copyright © 2021. All rights reserved.