Class ORBUtility


  • public final class ORBUtility
    extends java.lang.Object
    Handy class full of static functions that don't belong in util.Utility for pure ORB reasons.
    • Field Detail

      • encVersionThreadLocal

        private static final java.lang.ThreadLocal<java.util.LinkedList<java.lang.Byte>> encVersionThreadLocal
      • exceptionClassNames

        private static final java.util.Hashtable<java.lang.String,​java.lang.String> exceptionClassNames
      • exceptionRepositoryIds

        private static final java.util.Hashtable exceptionRepositoryIds
    • Constructor Detail

      • ORBUtility

        private ORBUtility()
    • Method Detail

      • openSocketChannel

        public static java.nio.channels.SocketChannel openSocketChannel​(java.net.SocketAddress sa)
                                                                 throws java.io.IOException
        Utility method for working around leak in SocketChannel.open( SocketAddress ) method.
        Parameters:
        sa - address to connect to
        Returns:
        The opened channel
        Throws:
        java.io.IOException - If an I/O error occurs
        See Also:
        SocketChannel.connect(java.net.SocketAddress)
      • pushEncVersionToThreadLocalState

        public static void pushEncVersionToThreadLocalState​(byte value)
      • popEncVersionFromThreadLocalState

        public static void popEncVersionFromThreadLocalState()
      • getEncodingVersion

        public static byte getEncodingVersion()
      • getByteBufferArray

        public static byte[] getByteBufferArray​(java.nio.ByteBuffer byteBuffer)
      • chooseEncodingVersion

        public static byte chooseEncodingVersion​(ORB orb,
                                                 IOR ior,
                                                 GIOPVersion gv)
        Parameters:
        orb - The ORB
        ior - Interoperable object reference
        gv - The maximum GIOP version supported
        Returns:
        the Java serialization encoding version.
      • systemExceptionMembers

        private static StructMember[] systemExceptionMembers​(ORB orb)
      • getSystemExceptionTypeCode

        private static TypeCode getSystemExceptionTypeCode​(ORB orb,
                                                           java.lang.String repID,
                                                           java.lang.String name)
      • isSystemExceptionTypeCode

        private static boolean isSystemExceptionTypeCode​(TypeCode type,
                                                         ORB orb)
      • insertSystemException

        public static void insertSystemException​(SystemException ex,
                                                 Any any)
        Static method for writing a CORBA standard exception to an Any.
        Parameters:
        ex - Exception to write
        any - The Any to write the SystemException into.
      • extractSystemException

        public static SystemException extractSystemException​(Any any)
      • createValueHandler

        public static ValueHandler createValueHandler()
        Gets the ValueHandler from Util.createValueHandler.
        Returns:
        gets the ValueHandler
      • createValueHandler

        public static ValueHandler createValueHandler​(ORB orb)
        Creates the correct ValueHandler. The parameter is ignored
        Parameters:
        orb - ignored
        Returns:
        The correct ValueHandler
        See Also:
        createValueHandler()
      • isForeignORB

        public static boolean isForeignORB​(ORB orb)
        Returns true if it was accurately determined that the remote ORB is a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this will return false.
        Parameters:
        orb - ORB to test
        Returns:
        If the ORB is foreign
      • bytesToInt

        public static int bytesToInt​(byte[] array,
                                     int offset)
        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.
        Parameters:
        array - The array of bytes.
        offset - The offset from which to start unmarshalling.
        Returns:
        Unmarshalled integer
      • intToBytes

        public static void intToBytes​(int value,
                                      byte[] array,
                                      int offset)
        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.
        Parameters:
        value - Integer to marshal
        array - The array of bytes.
        offset - The offset from which to start marshalling.
      • hexOf

        public static int hexOf​(char x)
        Converts an Ascii Character into Hexadecimal digit
        Parameters:
        x - ASCII character to convert
        Returns:
        Hexadecimal digit
      • writeSystemException

        public static void writeSystemException​(SystemException ex,
                                                OutputStream strm)
        Static method for writing a CORBA standard exception to a stream.
        Parameters:
        ex - Exception to write to stream
        strm - The OutputStream to use for marshaling.
      • readSystemException

        public static SystemException readSystemException​(InputStream strm)
        Static method for reading a CORBA standard exception from a stream.
        Parameters:
        strm - The InputStream to use for unmarshalling.
        Returns:
        Exception in stream
      • classNameOf

        public static java.lang.String classNameOf​(java.lang.String repositoryId)
        Get the class name corresponding to a particular repository Id. This is used by the system to unmarshal (instantiate) the appropriate exception class for an marshaled as the value of its repository Id.
        Parameters:
        repositoryId - The repository Id for which we want a class name.
        Returns:
        Corresponding class name
      • isSystemException

        public static boolean isSystemException​(java.lang.String repositoryId)
        Return true if this repositoryId is a SystemException.
        Parameters:
        repositoryId - The repository Id to check.
        Returns:
        if ID is a SystemException
      • repositoryIdOf

        public static java.lang.String repositoryIdOf​(java.lang.String name)
        Get the repository id corresponding to a particular class. This is used by the system to write the appropriate repository id for a system exception.
        Parameters:
        name - The class name of the system exception.
        Returns:
        Repository ID
      • parseVersion

        public static int[] parseVersion​(java.lang.String version)
        Parse a version string such as "1.1.6" or "jdk1.2fcs" into a version array of integers {1, 1, 6} or {1, 2}. A string of "n." or "n..m" is equivalent to "n.0" or "n.0.m" respectively.
        Parameters:
        version - Java version
        Returns:
        Array of version parts
      • compareVersion

        public static int compareVersion​(int[] v1,
                                         int[] v2)
        Compare two version arrays. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
        Parameters:
        v1 - first version
        v2 - second version
        Returns:
        1, 0 or -1 if v1 is greater than, equal to, or less than v2.
      • compareVersion

        public static int compareVersion​(java.lang.String v1,
                                         java.lang.String v2)
        Compare two version strings. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
        Parameters:
        v1 - first version string
        v2 - second version string
        Returns:
        1, 0 or -1 if v1 is greater than, equal to, or less than v2.
        See Also:
        compareVersion(int[], int[])
      • compressClassName

        private static java.lang.String compressClassName​(java.lang.String name)
      • getThreadName

        public static java.lang.String getThreadName​(java.lang.Thread thr)
      • formatStackTraceElement

        private static java.lang.String formatStackTraceElement​(java.lang.StackTraceElement ste)
      • printStackTrace

        private static void printStackTrace​(java.lang.StackTraceElement[] trace)
      • dprint

        public static void dprint​(java.lang.Object obj,
                                  java.lang.String msg)
      • dprint

        public static void dprint​(java.lang.String className,
                                  java.lang.String msg)
      • dprint

        public void dprint​(java.lang.String msg)
      • dprintTrace

        public static void dprintTrace​(java.lang.Object obj,
                                       java.lang.String msg)
      • dprint

        public static void dprint​(java.lang.Object caller,
                                  java.lang.String msg,
                                  java.lang.Throwable t)
      • concatenateStringArrays

        public static java.lang.String[] concatenateStringArrays​(java.lang.String[] arr1,
                                                                 java.lang.String[] arr2)
      • throwNotSerializableForCorba

        public static void throwNotSerializableForCorba​(java.lang.String className)
        Throws the CORBA equivalent of a java.io.NotSerializableException Duplicated from util/Utility for Pure ORB reasons. There are two reasons for this: 1) We can't introduce dependencies on the util version from outside of the io/util packages since it will not exist in the pure ORB build running on JDK 1.3.x. 2) We need to pick up the correct minor code from OMGSystemException.
        Parameters:
        className - Class that is not Serializable
      • getMaxStreamFormatVersion

        public static byte getMaxStreamFormatVersion()
        Returns the maximum stream format version supported by our ValueHandler.
        Returns:
        he maximum stream format version
      • makeObjectReference

        public static Object makeObjectReference​(IOR ior)
        This method is used to create untyped object references.
        Parameters:
        ior - object to make reference of
        Returns:
        Object pointing to the IOR
      • setDaemon

        public static void setDaemon​(java.lang.Thread thread)
      • operationNameAndRequestId

        public static java.lang.String operationNameAndRequestId​(MessageMediator m)
      • isPrintable

        public static boolean isPrintable​(char c)
      • getBuffer

        public static byte[] getBuffer​(java.lang.String[] data)
        Given some hex data, extract it and put it into a byte buffer. The data must follow the following structure:
        1. All characters in a line after a "#" are ignored.
        2. All non-whitespace characters before a "#" are treated as hex data.
        3. All whitespace is ignored.
        4. Only whitespace and 0-9a-fA-F may occur before a "#" in any line.
        5. Each data line must contain an even number of non-whitespace characters.
        Parameters:
        data - data to extract
        Returns:
        byte array containing the data
      • dumpBinary

        public static java.lang.String dumpBinary​(byte[] data)
      • dumpBinary

        private static void dumpBinary​(java.lang.StringBuffer sbuf,
                                       java.nio.ByteBuffer buffer)
      • printBuffer

        public static void printBuffer​(java.lang.String msg,
                                       java.nio.ByteBuffer buffer,
                                       java.io.PrintStream ps)
        Print the contents of the buffer out to the PrintStream in hex and ASCII.
        Parameters:
        msg - The message to use as the header for this display
        buffer - The ByteBuffer containing the data. The contents from 0 to buffer.position() are printed out. Remember to set position!
        ps - The PrintStream to use for the display.
      • getClassSecurityInfo

        public static java.lang.String getClassSecurityInfo​(java.lang.Class cl)
      • formatStringArray

        public static java.lang.String formatStringArray​(java.lang.String[] a)