/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* Handy class full of static functions.
*/
public final class Utility {
new LocalStringManagerImpl(Utility.class);
public static void checkJVMVersion()
{
// do not perform any JVM version checking
}
throws IOException
{
return config;
} else {
return config;
}
}
/**
* Return the hostname of the local machine.
*/
try {
} catch(UnknownHostException e) {
return "localhost";
}
return hostname;
}
/**
* Return the hostname of the local machine.
*/
try {
} catch(UnknownHostException e) {
return "127.0.0.1";
}
return address;
}
/**
* This is a convenience method to lookup a remote object by name within
* the naming context.
* @exception javax.naming.NamingException if the object with that
* name could not be found.
*/
}
/** Unmarshal a byte array to an integer.
Assume the bytes are in BIGENDIAN order.
i.e. array[offset] is the most-significant-byte
and array[offset+3] is the least-significant-byte.
@param array The array of bytes.
@param offset The offset from which to start unmarshalling.
*/
{
}
/** Marshal an integer to a byte array.
The bytes are in BIGENDIAN order.
i.e. array[offset] is the most-significant-byte
and array[offset+3] is the least-significant-byte.
@param array The array of bytes.
@param offset The offset from which to start marshalling.
*/
{
}
/** Unmarshal a byte array to an long.
Assume the bytes are in BIGENDIAN order.
i.e. array[offset] is the most-significant-byte
and array[offset+7] is the least-significant-byte.
@param array The array of bytes.
@param offset The offset from which to start unmarshalling.
*/
{
}
/** Marshal an long to a byte array.
The bytes are in BIGENDIAN order.
i.e. array[offset] is the most-significant-byte
and array[offset+7] is the least-significant-byte.
@param array The array of bytes.
@param offset The offset from which to start marshalling.
*/
{
}
/**
* Verify and invoke main if present in the specified class.
*/
{
// determine the main method using reflection
// verify that it is public static void and takes
// String[] as the only argument
try {
} catch(NoSuchMethodException msme) {
throw new ClassNotFoundException(err);
}
// check modifiers: public static
"utility.main.notpublicorstatic",
"The main method is either not public or not static");
throw new ClassNotFoundException(err);
}
// check return type and exceptions
"utility.main.notvoid",
"The main method's return type is not void ");
throw new ClassNotFoundException(err);
}
// build args to the main and call it
}
{
// change first letter to uppercase
// try string method
try {
return;
} catch (NoSuchMethodException ex) {
try {
// try int method
return;
} catch(NoSuchMethodException nsmex) {
// try boolean method
return;
}
}
}
{
boolean methodFound = false;
int i=0;
{
{
{
{
methodFound = true;
break;
}
else
}
}
}
if(methodFound == true)
{
return;
}
if(alternateMethodName != null)
{
try
{
// try int method
return;
}
catch(NoSuchMethodException nsmex)
{
// try boolean method
return;
}
}
else
throw new NoSuchMethodException(setMeth);
}
// Ports are marshalled as shorts on the wire. The IDL
// type is unsigned short, which lacks a convenient representation
// in Java in the 32768-65536 range. So, we treat ports as
// ints throught this code, except that marshalling requires a
// scaling conversion. intToShort and shortToInt are provided
// for this purpose.
{
if (value > 32767)
return (short)(value - 65536) ;
return (short)value ;
}
{
if (value < 0)
return value + 65536 ;
return value ;
}
/**
* Get the current thread's context class loader which is set to
* the CommonClassLoader by ApplicationServer
* @return the thread's context classloader if it exists;
* else the system class loader.
*/
} else {
return ClassLoader.getSystemClassLoader();
}
}
/**
* Loads the class with the common class loader.
* @param className the class name
* @return the loaded class
* @exception if the class is not found.
*/
}
/**
* Utility routine for setting the context class loader.
* Returns previous class loader.
*/
// Can only reference final local variables from dopriveleged block
if (classLoaderToSet != originalClassLoader) {
} else {
return null;
}
}
);
}
}
return originalClassLoader;
}
public static void setEnvironment() {
}
/**
* Return the value for a given name from the System Properties or the
* Environmental Variables. The former overrides the latter.
* @param name - the name of the System Property or Environmental Variable
* @return the value of the variable or null if it was not found
*/
// System properties override env. variables
if(sysPropVal != null)
return sysPropVal;
return envVal;
}
/**
* Convert the byte array to char array with respect to given charset.
*
* @param byteArray
* @param charset null or "" means default charset
* @exception CharacterCodingException
*/
throws CharacterCodingException {
return null;
}
} else {
CharacterCodingException e = new CharacterCodingException();
throw e;
}
try {
} catch(CharacterCodingException cce) {
throw cce;
} catch(Throwable t) {
CharacterCodingException e = new CharacterCodingException();
e.initCause(t);
throw e;
}
return result;
}
/**
* Convert the char array to byte array with respect to given charset.
*
* @param charArray
* @param strCharset null or "" means default charset
* @exception CharacterCodingException
*/
throws CharacterCodingException {
return null;
}
} else {
CharacterCodingException e = new CharacterCodingException();
throw e;
}
try {
} catch(CharacterCodingException cce) {
throw cce;
} catch(Throwable t) {
CharacterCodingException e = new CharacterCodingException();
e.initCause(t);
throw e;
}
}
bytes[i] = 0;
}
}
chars[i] = '0';
}
}
}