Class ORBUtility

java.lang.Object
com.sun.corba.ee.impl.misc.ORBUtility

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

  • Constructor Details

    • ORBUtility

      private ORBUtility()
  • Method Details

    • openSocketChannel

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

      public static void pushEncVersionToThreadLocalState(byte value)
    • popEncVersionFromThreadLocalState

      public static void popEncVersionFromThreadLocalState()
    • getEncodingVersion

      public static byte getEncodingVersion()
    • getByteBufferArray

      public static byte[] getByteBufferArray(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, String repID, 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:
    • 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 String classNameOf(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(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 String repositoryIdOf(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(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(String v1, 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:
    • compressClassName

      private static String compressClassName(String name)
    • getThreadName

      public static String getThreadName(Thread thr)
    • formatStackTraceElement

      private static String formatStackTraceElement(StackTraceElement ste)
    • printStackTrace

      private static void printStackTrace(StackTraceElement[] trace)
    • dprint

      public static void dprint(Object obj, String msg)
    • dprint

      public static void dprint(String className, String msg)
    • dprint

      public void dprint(String msg)
    • dprintTrace

      public static void dprintTrace(Object obj, String msg)
    • dprint

      public static void dprint(Object caller, String msg, Throwable t)
    • concatenateStringArrays

      public static String[] concatenateStringArrays(String[] arr1, String[] arr2)
    • throwNotSerializableForCorba

      public static void throwNotSerializableForCorba(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
      invalid reference
      Serializable
    • getMaxStreamFormatVersion

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

      public static ClientDelegate makeClientDelegate(IOR ior)
    • 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(Thread thread)
    • operationNameAndRequestId

      public static String operationNameAndRequestId(MessageMediator m)
    • isPrintable

      public static boolean isPrintable(char c)
    • getBuffer

      public static byte[] getBuffer(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 String dumpBinary(byte[] data)
    • dumpBinary

      private static void dumpBinary(StringBuffer sbuf, ByteBuffer buffer)
    • printBuffer

      public static void printBuffer(String msg, ByteBuffer buffer, 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 String getClassSecurityInfo(Class cl)
    • formatStringArray

      public static String formatStringArray(String[] a)