incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmidd...@apache.org
Subject svn commit: r545607 - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba: runtime/CorbaObjectWriter.java types/CorbaAnyEventProducer.java types/CorbaStructEventProducer.java utils/CorbaAnyHelper.java
Date Fri, 08 Jun 2007 20:03:48 GMT
Author: dmiddlem
Date: Fri Jun  8 13:03:47 2007
New Revision: 545607

URL: http://svn.apache.org/viewvc?view=rev&rev=545607
Log:
Commit for YOKO-380:
* Updating way primitive are handled in the any support

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaStructEventProducer.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaAnyHelper.java

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java?view=diff&rev=545607&r1=545606&r2=545607
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
Fri Jun  8 13:03:47 2007
@@ -38,6 +38,7 @@
 import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
 import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
 import org.apache.yoko.bindings.corba.types.CorbaUnionHandler;
+import org.apache.yoko.bindings.corba.utils.CorbaAnyHelper;
 
 import org.omg.CORBA.Any;
 import org.omg.CORBA.TCKind;
@@ -252,10 +253,15 @@
 
         // This is true if we have an empty any
         if (containedType != null) {
-            OutputStream os = a.create_output_stream();
-            CorbaObjectWriter writer = new CorbaObjectWriter(os);
-            writer.write(containedType);
-            a.read_value(os.create_input_stream(), containedType.getTypeCode());
+            if (containedType instanceof CorbaPrimitiveHandler) {
+                CorbaAnyHelper.insertPrimitiveIntoAny(a, (CorbaPrimitiveHandler)containedType);
+            } else {
+                OutputStream os = a.create_output_stream();
+                CorbaObjectWriter writer = new CorbaObjectWriter(os);
+                writer.write(containedType);
+                org.omg.CORBA.portable.InputStream instream = os.create_input_stream();
+                a.read_value(os.create_input_stream(), containedType.getTypeCode());
+            }
         }
         stream.write_any(a);
     }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java?view=diff&rev=545607&r1=545606&r2=545607
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
Fri Jun  8 13:03:47 2007
@@ -24,6 +24,7 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLEventFactory;
+//import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.Namespace;
 
@@ -85,12 +86,19 @@
         // anys contained type in the XML output.  So we'll check for the current name and
if it
         // equals our contained type, we'll skip over the start element for that type.
         int result = super.next();
+        
+        //if (result == XMLStreamReader.END_ELEMENT 
+        //    && !(super.getName().equals(containedType.getName()))) {
+        //    result = super.next();
+        //}
+        
         if (super.getName().equals(containedType.getName())) {
             result = super.next();
         }
+    
         return result;
     }
-    
+
     public List<Attribute> getAttributes() {
         return attributes;
     }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaStructEventProducer.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaStructEventProducer.java?view=diff&rev=545607&r1=545606&r2=545607
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaStructEventProducer.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaStructEventProducer.java
Fri Jun  8 13:03:47 2007
@@ -36,7 +36,7 @@
 
     public int next() { 
         int event = states[state];
-        if (event != 0) {      
+        if (event != 0) {
             state++;
         } else if (currentEventProducer != null && currentEventProducer.hasNext())
{
             event = currentEventProducer.next();

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaAnyHelper.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaAnyHelper.java?view=diff&rev=545607&r1=545606&r2=545607
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaAnyHelper.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaAnyHelper.java
Fri Jun  8 13:03:47 2007
@@ -19,14 +19,18 @@
 
 package org.apache.yoko.bindings.corba.utils;
 
+import java.math.BigInteger;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
 
+import org.apache.yoko.bindings.corba.CorbaBindingException;
+import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
 import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.W3CConstants;
 
+import org.omg.CORBA.Any;
 import org.omg.CORBA.TCKind;
 import org.omg.CORBA.TypeCode;
 
@@ -103,6 +107,109 @@
         }
 
         return result;
+    }
+
+    public static void insertPrimitiveIntoAny(Any a, CorbaPrimitiveHandler primitive)
+        throws CorbaBindingException {
+        assert primitive != null;
+        switch (primitive.getTypeCode().kind().value()) {
+        case TCKind._tk_boolean:
+            a.insert_boolean((Boolean)primitive.getValue());
+            break;
+        case TCKind._tk_char:
+            a.insert_char((Character)primitive.getValue());
+            break;
+        case TCKind._tk_wchar:
+            a.insert_wchar((Character)primitive.getValue());
+            break;
+        case TCKind._tk_octet:
+            a.insert_octet((Byte)primitive.getValue());
+            break;
+        case TCKind._tk_short:
+            a.insert_short((Short)primitive.getValue());
+            break;
+        case TCKind._tk_ushort:
+            a.insert_ushort(((Integer)primitive.getValue()).shortValue());
+            break;
+        case TCKind._tk_long:
+            a.insert_long((Integer)primitive.getValue());
+            break;
+        case TCKind._tk_ulong:
+            a.insert_ulong(((BigInteger)primitive.getValue()).intValue());
+            break;
+        case TCKind._tk_longlong:
+            a.insert_longlong((Long)primitive.getValue());
+            break;
+        case TCKind._tk_ulonglong:
+            a.insert_ulonglong(((BigInteger)primitive.getValue()).intValue());
+            break;
+        case TCKind._tk_float:
+            a.insert_float((Float)primitive.getValue());
+            break;
+        case TCKind._tk_double:
+            a.insert_double((Double)primitive.getValue());
+            break;
+        case TCKind._tk_string:
+            a.insert_string((String)primitive.getValue());
+            break;
+        case TCKind._tk_wstring:
+            a.insert_wstring((String)primitive.getValue());
+            break;
+        default:
+            throw new CorbaBindingException("Unable to insert type into any.  Kind = " 
+                                            + primitive.getTypeCode().kind().value());
+        }
+    }
+
+    public static void extractPrimitiveFromAny(Any a, CorbaPrimitiveHandler primitive) {
+        assert primitive != null;
+        switch (primitive.getTypeCode().kind().value()) {
+        case TCKind._tk_boolean:
+            primitive.setValue(Boolean.valueOf(a.extract_boolean()));
+            break;
+        case TCKind._tk_char:
+            primitive.setValue(Character.valueOf(a.extract_char()));
+            break;
+        case TCKind._tk_wchar:
+            primitive.setValue(Character.valueOf(a.extract_wchar()));
+            break;
+        case TCKind._tk_octet:
+            primitive.setValue(Byte.valueOf(a.extract_octet()));
+            break;
+        case TCKind._tk_short:
+            primitive.setValue(Short.valueOf(a.extract_short()));
+            break;
+        case TCKind._tk_ushort:
+            primitive.setValue(Integer.valueOf((int)a.extract_ushort()));
+            break;
+        case TCKind._tk_long:
+            primitive.setValue(Integer.valueOf(a.extract_long()));
+            break;
+        case TCKind._tk_ulong:
+            primitive.setValue(BigInteger.valueOf((long)a.extract_ulong()));
+            break;
+        case TCKind._tk_longlong:
+            primitive.setValue(Long.valueOf(a.extract_longlong()));
+            break;
+        case TCKind._tk_ulonglong:
+            primitive.setValue(BigInteger.valueOf((long)a.extract_ulonglong()));
+            break;
+        case TCKind._tk_float:
+            primitive.setValue(Float.valueOf(a.extract_float()));
+            break;
+        case TCKind._tk_double:
+            primitive.setValue(Double.valueOf(a.extract_double()));
+            break;
+        case TCKind._tk_string:
+            primitive.setValue(a.extract_string());
+            break;
+        case TCKind._tk_wstring:
+            primitive.setValue(a.extract_wstring());
+            break;
+        default:
+            throw new CorbaBindingException("Unable to extract type from any.  Kind = " 
+                                            + primitive.getTypeCode().kind().value());
+        }
     }
 
     // NOTE: We have an issue when we get a schema type of String.  We don't know whether
this means



Mime
View raw message