You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/02/01 15:17:36 UTC

svn commit: r374072 [3/3] - in /webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed: ./ rpc/ src/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/databinding/ src/org/apache/axis2/databinding/beans/ src/org/apache/axis2/databin...

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCResponseElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCResponseElement.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCResponseElement.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCResponseElement.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.rpc;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.OMElementImpl;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.Iterator;
+
+/**
+ * RPCResponseElement
+ */
+public class RPCResponseElement extends OMElementImpl {
+    RPCMethod method;
+    RPCValues values;
+
+    public RPCResponseElement(RPCMethod method,
+                              RPCValues values,
+                              OMElement parent) {
+        super(method.getResponseQName(), parent);
+        this.method = method;
+        this.values = values;
+    }
+
+    protected void serialize(OMOutputImpl omOutput, boolean cache)
+            throws XMLStreamException {
+        XMLStreamWriter writer = omOutput.getXmlStreamWriter();
+        SerializationContext context = new SerializationContext(writer);
+
+        // Write wrapper element
+        if (ns == null) {
+            writer.writeStartElement(localName);
+        } else {
+            writer.writeStartElement(localName, ns.getName(), ns.getPrefix());
+        }
+        Iterator outParams = method.getOutParams();
+        while (outParams.hasNext()) {
+            RPCParameter parameter = (RPCParameter) outParams.next();
+            try {
+                parameter.serialize(context,
+                        values.getValue(parameter.getQName()));
+            } catch (Exception e) {
+                throw new XMLStreamException("Couldn't serialize RPCParameter",
+                        e);
+            }
+        }
+        writer.writeEndElement();
+
+        try {
+            context.finish();
+        } catch (Exception e) {
+            throw new XMLStreamException(e);
+        }
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCValues.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCValues.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCValues.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCValues.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,53 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.rpc;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * RPCValues
+ */
+public class RPCValues {
+    Map values = new HashMap();
+
+    public Object getValue(QName paramName) {
+        return values.get(paramName);
+    }
+
+    public void setValue(QName paramName, Object value) {
+        values.put(paramName, value);
+    }
+
+    public void setIndexedValue(QName paramName, int index, Object value) {
+        ArrayList coll = (ArrayList) values.get(paramName);
+        if (coll == null) {
+            coll = new ArrayList();
+            values.put(paramName, coll);
+        }
+        if (coll.size() == index) {
+            coll.add(value);
+            return;
+        }
+
+        while (index + 1 > coll.size()) {
+            coll.add(null);
+        }
+        coll.set(index, value);
+    }
+}