001: /**
002: * Copyright 2003 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.providers.simplewebservice.rpc;
013:
014: import com.sun.xml.rpc.encoding.*;
015: import com.sun.xml.rpc.encoding.literal.*;
016:
017: import java.util.*;
018: import java.lang.reflect.Field;
019: import java.lang.reflect.Modifier;
020: import javax.xml.namespace.QName;
021:
022: import com.sun.xml.rpc.processor.modeler.rmi.LiteralSimpleTypeCreator;
023: import com.sun.xml.rpc.streaming.*;
024: import com.sun.xml.rpc.util.exception.LocalizableExceptionAdapter;
025: import com.sun.xml.rpc.soap.SOAPVersion;
026: import com.sun.xml.rpc.soap.SOAPConstantsFactory;
027: import com.sun.xml.rpc.encoding.*;
028: import com.sun.xml.rpc.util.*;
029: import com.sun.xml.rpc.wsdl.document.soap.SOAPConstants;
030: import com.sun.portal.providers.simplewebservice.ParameterDescriptor;
031: import com.sun.portal.providers.simplewebservice.rpc.XMapSerializer;
032: import com.sun.portal.providers.simplewebservice.util.XList;
033:
034: public class LiteralStructureSerializer extends
035: LiteralObjectSerializerBase implements Initializable {
036:
037: /**
038: *
039: */
040: private com.sun.xml.rpc.soap.SOAPEncodingConstants soapEncodingConstants = null;
041: protected InternalTypeMappingRegistry registry;
042: private ParameterDescriptor paramDesc = null;
043:
044: private void init(SOAPVersion ver) {
045: soapEncodingConstants = SOAPConstantsFactory
046: .getSOAPEncodingConstants(ver);
047: }
048:
049: public LiteralStructureSerializer(QName type, boolean encodeType,
050: boolean isNullable, String encodingStyle, SOAPVersion ver) {
051: super (type, isNullable, encodingStyle, encodeType);
052: init(ver); // Initialize SOAP constants
053:
054: // TODO Auto-generated constructor stub
055: }
056:
057: public void setParameterDescriptor(ParameterDescriptor paramDesc) {
058: this .paramDesc = paramDesc;
059: }
060:
061: public void initialize(InternalTypeMappingRegistry registry)
062: throws Exception {
063: this .registry = registry;
064:
065: }
066:
067: public static void main(String[] args) {
068: }
069:
070: protected void doSerializeAttributes(Object obj, XMLWriter writer,
071: SOAPSerializationContext context) throws Exception {
072: }
073:
074: protected void doSerialize(Object instance, XMLWriter writer,
075: SOAPSerializationContext context) throws Exception {
076: StructMap struct = (StructMap) instance;
077: Iterator eachKey = struct.keys().iterator();
078: Iterator eachValue = struct.values().iterator();
079:
080: while (eachKey.hasNext()) {
081: Object value = eachValue.next();
082: QName key = (QName) eachKey.next();
083:
084: if (value != null) {
085: JAXRPCSerializer serializer = (JAXRPCSerializer) registry
086: .getSerializer(encodingStyle, value.getClass());
087: serializer.serialize(value, key, null, writer, context);
088: } else {
089:
090: writer
091: .writeAttributeUnquoted(
092: com.sun.xml.rpc.encoding.xsd.XSDConstants.QNAME_XSI_NIL,
093: "1");
094: }
095: }
096:
097: }
098:
099: /**
100: * This cannot be used as a Deserializer
101: * see LiteralFragmentSerializer for Deserialization
102: *
103: */
104: protected Object doDeserialize(XMLReader reader,
105: SOAPDeserializationContext context) throws Exception {
106:
107: return null;
108: }
109:
110: }
|