geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiam...@apache.org
Subject svn commit: r1365466 - in /geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi: impl/ValueDescriptor.java util/StringUtil.java
Date Wed, 25 Jul 2012 06:40:05 GMT
Author: xiaming
Date: Wed Jul 25 06:40:05 2012
New Revision: 1365466

URL: http://svn.apache.org/viewvc?rev=1365466&view=rev
Log:
GERONIMOTCK-142 Transform repository ID names to valid ones

Modified:
    geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
    geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/util/StringUtil.java

Modified: geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java?rev=1365466&r1=1365465&r2=1365466&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
(original)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
Wed Jul 25 06:40:05 2012
@@ -37,6 +37,7 @@ import java.util.Set;
 import java.util.logging.Logger;
 import java.util.logging.Level;
 
+import org.apache.yoko.rmi.util.StringUtil;
 import org.omg.CORBA.MARSHAL;
 import org.omg.CORBA.TypeCode;
 import org.omg.CORBA.ValueMember;
@@ -101,7 +102,7 @@ public class ValueDescriptor extends Typ
     public String getRepositoryID() {
         if (_repid == null) {
             StringBuffer buf = new StringBuffer("RMI:");
-            buf.append(getJavaClass().getName());
+            buf.append(StringUtil.convertToValidIDLNames(getJavaClass().getName()));
             buf.append(":");
 
             String hashCode = Long.toHexString(_hash_code).toUpperCase();
@@ -823,6 +824,8 @@ public class ValueDescriptor extends Typ
             // read custom marshalling value header
             byte streamFormatVersion = reader.readByte();
             boolean writeDefaultStateCalled = reader.readBoolean();
+            logger.log(Level.FINE, "Reading value in streamFormatVersion=" + streamFormatVersion

+                    + " IsCalleddefaultWriteObject=" + writeDefaultStateCalled);
         }
 
         if (_read_object_method != null) {

Modified: geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/util/StringUtil.java?rev=1365466&r1=1365465&r2=1365466&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/util/StringUtil.java
(original)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/util/StringUtil.java
Wed Jul 25 06:40:05 2012
@@ -73,4 +73,71 @@ public class StringUtil {
 
         return result.toString();
     }
+    
+    public static final byte[] HEX_CHARS = {
+        (byte)'0',
+        (byte)'1',
+        (byte)'2',
+        (byte)'3',
+        (byte)'4',
+        (byte)'5',
+        (byte)'6',
+        (byte)'7',
+        (byte)'8',
+        (byte)'9',
+        (byte)'A',
+        (byte)'B',
+        (byte)'C',
+        (byte)'D',
+        (byte)'E',
+        (byte)'F',
+    };
+
+    public static final byte[] VALID_IDL_CHARS = {
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0,
+        1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0,
+        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
+        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1,
+        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
+        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
+        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
+        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1,
+        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
+        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1,
+    };
+
+    public static String convertToValidIDLNames(String str) {
+
+        int length = str.length();
+        if (length == 0) {
+            return str;
+        }
+        
+        StringBuilder builder = new StringBuilder();
+        
+        for (char c : str.toCharArray()) {
+            if (c > 255 || VALID_IDL_CHARS[c] == 0) {
+                builder.append("\\U" +
+                        (char)HEX_CHARS[(c & 0xF000) >>> 12] +
+                        (char)HEX_CHARS[(c & 0x0F00) >>> 8] +
+                        (char)HEX_CHARS[(c & 0x00F0) >>> 4] +
+                        (char)HEX_CHARS[(c & 0x000F)] );
+            } else {
+                builder.append(c);
+            }
+        }
+        
+        if (builder.length() > 0) {
+            str = builder.toString();
+        }
+        
+        return str;
+    }
+    
 }



Mime
View raw message