📄 repositoryid_1_3_1.java
字号:
* org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type. **/ public static String createForJavaType(java.io.Serializable ser) throws com.sun.corba.se.internal.io.TypeMismatchException { synchronized (classToRepStr) { String repid = createForSpecialCase(ser); if (repid != null) return repid; Class clazz = ser.getClass(); repid = (String)classToRepStr.get(clazz); if (repid != null) return repid; repid = kValuePrefix + convertToISOLatin1(clazz.getName()) + createHashString(clazz); classToRepStr.put(clazz, repid); repStrToClass.put(repid, clazz); return repid; } } /** * Creates a repository ID for a normal Java Type. * @param clz The Java class to create a repository ID for * @exception com.sun.corba.se.internal.io.TypeMismatchException if ser implements the * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type. **/ public static String createForJavaType(Class clz) throws com.sun.corba.se.internal.io.TypeMismatchException { synchronized (classToRepStr){ String repid = createForSpecialCase(clz); if (repid != null) return repid; repid = (String)classToRepStr.get(clz); if (repid != null) return repid; repid = kValuePrefix + convertToISOLatin1(clz.getName()) + createHashString(clz); classToRepStr.put(clz, repid); repStrToClass.put(repid, clz); return repid; } } /** * Creates a repository ID for an IDL Java Type. * @param ser The IDL Value object to create a repository ID for * @param major The major version number * @param minor The minor version number * @exception com.sun.corba.se.internal.io.TypeMismatchException if ser does not implement the * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type. **/ public static String createForIDLType(Class ser, int major, int minor) throws com.sun.corba.se.internal.io.TypeMismatchException { synchronized (classIDLToRepStr){ String repid = (String)classIDLToRepStr.get(ser); if (repid != null) return repid; repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') + ":" + major + "." + minor; classIDLToRepStr.put(ser, repid); return repid; } } private static String getIdFromHelper(Class clazz){ try { Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null, clazz.getClassLoader(), clazz, clazz.getClassLoader()); Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes); return (String)idMethod.invoke(null, kNoArgs); } catch(java.lang.ClassNotFoundException cnfe) { throw new org.omg.CORBA.MARSHAL(cnfe.toString()); } catch(java.lang.NoSuchMethodException nsme) { throw new org.omg.CORBA.MARSHAL(nsme.toString()); } catch(java.lang.reflect.InvocationTargetException ite) { throw new org.omg.CORBA.MARSHAL(ite.toString()); } catch(java.lang.IllegalAccessException iae) { throw new org.omg.CORBA.MARSHAL(iae.toString()); } } /** * Createa a repository ID for the type if it is either a java type * or an IDL type. * @param type The type to create rep. id for * @return The rep. id. **/ public static String createForAnyType(Class type) { try{ if (type.isArray()) return createSequenceRepID(type); else if (IDLEntity.class.isAssignableFrom(type)) { try{ return getIdFromHelper(type); } catch(Throwable t) { return createForIDLType(type, 1, 0); } } else return createForJavaType(type); } catch(com.sun.corba.se.internal.io.TypeMismatchException e){ return null; } } public static boolean isAbstractBase(Class clazz) { return (clazz.isInterface() && IDLEntity.class.isAssignableFrom(clazz) && (!ValueBase.class.isAssignableFrom(clazz)) && (!org.omg.CORBA.Object.class.isAssignableFrom(clazz))); } public static boolean isAnyRequired(Class clazz) { return ((clazz == java.lang.Object.class) || (clazz == java.io.Serializable.class) || (clazz == java.io.Externalizable.class)); } public static long fromHex(String hexNumber) { if (hexNumber.startsWith("0x")) return Long.valueOf(hexNumber.substring(2), 16).longValue(); else return Long.valueOf(hexNumber, 16).longValue(); } /** * Convert strings with illegal IDL identifier characters. * <p> * Section 5.5.7 of OBV spec. */ private static String convertToISOLatin1 (String name) { int length = name.length(); if (length == 0) { return name; } StringBuffer buffer = null; for (int i = 0; i < length; i++) { char c = name.charAt(i); if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) { // We gotta convert. Have we already started? if (buffer == null) { // No, so get set up... buffer = new StringBuffer(name.substring(0,i)); } // Convert the character into the IDL escape syntax... buffer.append( "\\U" + (char)ASCII_HEX[(c & 0xF000) >>> 12] + (char)ASCII_HEX[(c & 0x0F00) >>> 8] + (char)ASCII_HEX[(c & 0x00F0) >>> 4] + (char)ASCII_HEX[(c & 0x000F)]); } else { if (buffer != null) { buffer.append(c); } } } if (buffer != null) { name = buffer.toString(); } return name; } /** * Convert strings with ISO Latin 1 escape sequences back to original strings. * <p> * Section 5.5.7 of OBV spec. */ private static String convertFromISOLatin1 (String name) { int index = -1; StringBuffer buf = new StringBuffer(name); while ((index = buf.toString().indexOf("\\U")) != -1){ String str = "0000" + buf.toString().substring(index+2, index+6); // Convert Hexadecimal byte[] buffer = new byte[(str.length() - 4) / 2]; for (int i=4, j=0; i < str.length(); i +=2, j++) { buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0); buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F); } buf = new StringBuffer(delete(buf.toString(), index, index+6)); buf.insert(index, (char)buffer[1]); } return buf.toString(); } private static String delete(String str, int from, int to) { return str.substring(0, from) + str.substring(to, str.length()); } private static String replace(String target, String arg, String source) { int i = 0; i = target.indexOf(arg); while(i != -1) { String left = target.substring(0, i); String right = target.substring(i+arg.length()); target = new String(left+source+right); i = target.indexOf(arg); } return target; } public static int computeValueTag(boolean codeBasePresent, int typeInfo, boolean chunkedEncoding){ int value_tag = kInitialValueTag; if (codeBasePresent) value_tag = value_tag | 0x00000001; value_tag = value_tag | typeInfo; if (chunkedEncoding) value_tag = value_tag | kChunkedMask; return value_tag; } public static boolean isCodeBasePresent(int value_tag){ return ((value_tag & 0x00000001) == 1); } public static int getTypeInfo(int value_tag){ return (value_tag & 0x00000006); } public static boolean isChunkedEncoding(int value_tag){ return ((value_tag & kChunkedMask) != 0); } public static String getServerURL(){ return defaultServerURL; } /* * Load a class and check that it is assignable to a given type. * @param className the class name. * @param remoteCodebase the codebase to use. May be null. * @param loader the class loader of last resort. May be null. * @param expectedType the expected type. May be null. * @return the loaded class. */ private Class loadClassOfType (String className, String remoteCodebase, ClassLoader loader, Class expectedType, ClassLoader expectedTypeClassLoader) throws ClassNotFoundException { Class loadedClass = null; try { //Sequence finding of the stubs according to spec try{ //If-else is put here for speed up of J2EE. //According to the OMG spec, the if clause is not dead code. //It can occur if some compiler has allowed generation //into org.omg.stub hierarchy for non-offending //classes. This will encourage people to //produce non-offending class stubs in their own hierarchy. if(!PackagePrefixChecker .hasOffendingPrefix(PackagePrefixChecker .withoutPackagePrefix(className))){ loadedClass = Util.loadClass (PackagePrefixChecker.withoutPackagePrefix(className), remoteCodebase, loader); } else { loadedClass = Util.loadClass (className, remoteCodebase, loader); } } catch (ClassNotFoundException cnfe) { loadedClass = Util.loadClass (className, remoteCodebase, loader); } if (expectedType == null) return loadedClass; } catch (ClassNotFoundException cnfe) { if (expectedType == null) throw cnfe; } // If no class was not loaded, or if the loaded class is not of the // correct type, make a further attempt to load the correct class // using the classloader of the expected type. // _REVISIT_ Is this step necessary, or should the Util,loadClass // algorithm always produce a valid class if the setup is correct? // Does the OMG standard algorithm need to be changed to include // this step? if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) { if (expectedType.getClassLoader() != expectedTypeClassLoader) throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType."); if (expectedTypeClassLoader != null) loadedClass = expectedTypeClassLoader.loadClass(className); else loadedClass = Class.forName(className); } return loadedClass; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -