orbutility.java
来自「java jdk 1.4的源码」· Java 代码 · 共 663 行 · 第 1/2 页
JAVA
663 行
exceptionClassNames.put("IDL:omg.org/CORBA/NO_PERMISSION:1.0", "org.omg.CORBA.NO_PERMISSION"); exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESOURCES:1.0", "org.omg.CORBA.NO_RESOURCES"); exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESPONSE:1.0", "org.omg.CORBA.NO_RESPONSE"); exceptionClassNames.put("IDL:omg.org/CORBA/OBJ_ADAPTER:1.0", "org.omg.CORBA.OBJ_ADAPTER"); exceptionClassNames.put("IDL:omg.org/CORBA/INITIALIZE:1.0", "org.omg.CORBA.INITIALIZE"); exceptionClassNames.put("IDL:omg.org/CORBA/PERSIST_STORE:1.0", "org.omg.CORBA.PERSIST_STORE"); exceptionClassNames.put("IDL:omg.org/CORBA/TRANSIENT:1.0", "org.omg.CORBA.TRANSIENT"); exceptionClassNames.put("IDL:omg.org/CORBA/UNKNOWN:1.0", "org.omg.CORBA.UNKNOWN"); exceptionClassNames.put("IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0", "org.omg.CORBA.OBJECT_NOT_EXIST"); // SystemExceptions from OMG Transactions Service Spec exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0", "org.omg.CORBA.INVALID_TRANSACTION"); exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0", "org.omg.CORBA.TRANSACTION_REQUIRED"); exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0", "org.omg.CORBA.TRANSACTION_ROLLEDBACK"); // from portability RTF 98-07-01.txt exceptionClassNames.put("IDL:omg.org/CORBA/INV_POLICY:1.0", "org.omg.CORBA.INV_POLICY"); // from orbrev/00-09-01 (CORBA 2.4 Draft Specification) exceptionClassNames. put("IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0", "org.omg.CORBA.TRANSACTION_UNAVAILABLE"); exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_MODE:1.0", "org.omg.CORBA.TRANSACTION_MODE"); // // construct className -> repositoryId hashtable // Enumeration keys = exceptionClassNames.keys(); java.lang.Object s; String rId; String cName; try{ while (keys.hasMoreElements()) { s = keys.nextElement(); rId = (String) s; cName = (String) exceptionClassNames.get(rId); exceptionRepositoryIds.put (cName, rId); } } catch (NoSuchElementException e) { } } /** 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. */ public static int[] parseVersion(String version) { if (version == null) return new int[0]; char[] s = version.toCharArray(); //find the maximum span of the string "n.n.n..." where n is an integer int start = 0; for (; start < s.length && (s[start] < '0' || s[start] > '9'); ++start) if (start == s.length) //no digit found return new int[0]; int end = start + 1; int size = 1; for (; end < s.length; ++end) if (s[end] == '.') ++size; else if (s[end] < '0' || s[end] > '9') break; int[] val = new int[size]; for (int i = 0; i < size; ++i) { int dot = version.indexOf('.', start); if (dot == -1 || dot > end) dot = end; if (start >= dot) //cases like "n." or "n..m" val[i] = 0; //convert equivalent to "n.0" or "n.0.m" else val[i] = Integer.parseInt(version.substring(start, dot)); start = dot + 1; } return val; } /** Compare two version arrays. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2. */ public static int compareVersion(int[] v1, int[] v2) { if (v1 == null) v1 = new int[0]; if (v2 == null) v2 = new int[0]; for (int i = 0; i < v1.length; ++i) { if (i >= v2.length || v1[i] > v2[i]) //v1 is longer or greater than v2 return 1; if (v1[i] < v2[i]) return -1; } return v1.length == v2.length ? 0 : -1; } /** Compare two version strings. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2. */ public static int compareVersion(String v1, String v2) { return compareVersion(parseVersion(v1), parseVersion(v2)); } /** A smarter toString that uses the built-in toString. * If obj isA: * Object that supports toString() directly: call toString * array of objects: array[length]( toString results of non-null elements ) * other: print the contents of the object's public fields. * Note that this method is NOT SAFE FOR USE WITH CIRCULAR REFERENCES! * It will go into an infinite recursion if handed the top level * reference to a cyclic graph of objects. */ public static String objectToString(java.lang.Object obj) { if (obj==null) return "null" ; StringBuffer result = new StringBuffer() ; Class cls = obj.getClass() ; Class compClass = cls.getComponentType() ; if (obj instanceof java.util.Properties) { Properties props = (Properties)obj ; result.append( cls.getName() ) ; result.append( "(" ) ; Enumeration keys = props.propertyNames() ; while (keys.hasMoreElements()) { String key = (String)(keys.nextElement()) ; String value = props.getProperty( key ) ; result.append( " " ) ; result.append( key ) ; result.append( "=" ) ; result.append( value ) ; } result.append( " )" ) ; return result.toString() ; } try { // If class of obj directly declares toString(), use it. cls.getDeclaredMethod( "toString", null ) ; return obj.toString() ; } catch (Exception exc) { if (compClass == null) { // Must be some reference type, so use reflection to print fields Field[] fields ; try { fields = cls.getFields() ; } catch (SecurityException sexc) { // Can't get fields, so use default toString() return obj.toString() ; } result.append( cls.getName() ) ; result.append( "(" ) ; for (int ctr=0; ctr<fields.length; ctr++ ) { Field fld = fields[ctr] ; result.append( " " ) ; result.append( fld.getName() ) ; result.append( "=" ) ; try { java.lang.Object value = fld.get( obj ) ; result.append( objectToString( value ) ) ; } catch (Exception exc2) { result.append( "???" ) ; } } result.append( " )" ) ; return result.toString() ; } else // we have an array result.append( compClass.getName() ) ; result.append( "[" ) ; if (compClass == boolean.class) { boolean[] arr = (boolean[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == byte.class) { byte[] arr = (byte[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == short.class) { short[] arr = (short[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == int.class) { int[] arr = (int[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == long.class) { long[] arr = (long[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == char.class) { char[] arr = (char[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == float.class) { float[] arr = (float[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else if (compClass == double.class) { double[] arr = (double[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( arr[ctr] ) ; } } else { // array of object java.lang.Object[] arr = (java.lang.Object[])obj ; result.append( arr.length ) ; result.append( "](" ) ; for (int ctr=0; ctr<arr.length; ctr++) { result.append( " " ) ; result.append( objectToString( arr[ctr] ) ) ; } } result.append( " ]" ) ; return result.toString() ; } } // // Implements all dprint calls in this package. // public static void dprint(java.lang.Object obj, String msg) { System.out.println(obj.getClass().getName() + "(" + Thread.currentThread() + "): " + msg); } public static void dprint(String className, String msg) { System.out.println(className + "(" + Thread.currentThread() + "): " + msg); } public void dprint(String msg) { ORBUtility.dprint(this, msg); } public static void dprint(java.lang.Object caller, String msg, Throwable t) { System.out.println(caller.getClass().getName() + '(' + Thread.currentThread() + "): " + msg); if (t != null) t.printStackTrace(); } public static String[] concatenateStringArrays( String[] arr1, String[] arr2 ) { String[] result = new String[ arr1.length + arr2.length ] ; for (int ctr = 0; ctr<arr1.length; ctr++) result[ctr] = arr1[ctr] ; for (int ctr = 0; ctr<arr2.length; ctr++) result[ctr + arr1.length] = arr2[ctr] ; return result ; } /** * 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 orbutil.MinorCodes. * If we picked it up from util.MinorCodes, then it would have the * incorrect value when running the pure ORB on JDK 1.3.x. */ public static void throwNotSerializableForCorba(String className) { throw new BAD_PARAM(className, MinorCodes.NOT_SERIALIZABLE, CompletionStatus.COMPLETED_MAYBE); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?