KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > remote > soap > encoding > LZObjectSerializer


1 /* *****************************************************************************
2  * LZObjectSerializer.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10
11 /*
12  * The Apache Software License, Version 1.1
13  *
14  *
15  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
16  * reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  *
22  * 1. Redistributions of source code must retain the above copyright
23  * notice, this list of conditions and the following disclaimer.
24  *
25  * 2. Redistributions in binary form must reproduce the above copyright
26  * notice, this list of conditions and the following disclaimer in
27  * the documentation and/or other materials provided with the
28  * distribution.
29  *
30  * 3. The end-user documentation included with the redistribution,
31  * if any, must include the following acknowledgment:
32  * "This product includes software developed by the
33  * Apache Software Foundation (http://www.apache.org/)."
34  * Alternately, this acknowledgment may appear in the software itself,
35  * if and wherever such third-party acknowledgments normally appear.
36  *
37  * 4. The names "Axis" and "Apache Software Foundation" must
38  * not be used to endorse or promote products derived from this
39  * software without prior written permission. For written
40  * permission, please contact apache@apache.org.
41  *
42  * 5. Products derived from this software may not be called "Apache",
43  * nor may "Apache" appear in their name, without prior written
44  * permission of the Apache Software Foundation.
45  *
46  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
47  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
50  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57  * SUCH DAMAGE.
58  * ====================================================================
59  *
60  * This software consists of voluntary contributions made by many
61  * individuals on behalf of the Apache Software Foundation. For more
62  * information on the Apache Software Foundation, please see
63  * <http://www.apache.org/>.
64  */

65
66 package org.openlaszlo.remote.soap.encoding;
67
68 import javax.xml.namespace.QName JavaDoc;
69 import java.io.IOException JavaDoc;
70 import org.apache.axis.encoding.SerializationContext;
71 import org.apache.axis.encoding.Serializer;
72 import org.apache.axis.wsdl.fromJava.Types;
73 import org.w3c.dom.Element JavaDoc;
74 import org.w3c.dom.Node JavaDoc;
75 import org.w3c.dom.NodeList JavaDoc;
76 import org.xml.sax.Attributes JavaDoc;
77 import org.apache.log4j.Logger;
78 import org.openlaszlo.remote.soap.ObjectWrapper;
79
80 public class LZObjectSerializer implements Serializer {
81
82     private static Logger mLogger = Logger.getLogger(LZObjectSerializer.class);
83
84     public static String JavaDoc MECHANISM_TYPE = "LZObjectMechanism";
85
86     public String JavaDoc getMechanismType() { return MECHANISM_TYPE; }
87
88     /**
89      *
90      */

91     public void serialize(QName JavaDoc name, Attributes JavaDoc attributes,
92                           Object JavaDoc value, SerializationContext context)
93         throws IOException JavaDoc
94     {
95         mLogger.debug("serialize(" + name + "," + attributes +
96                       "," + value + "," + context + ")");
97
98         context.startElement(name, attributes);
99         NodeList JavaDoc list = ((ObjectWrapper)value).getElement().getChildNodes();
100         for (int i=0; i < list.getLength(); i++) {
101             Node JavaDoc node = (Node JavaDoc)list.item(i);
102             if ( node.getNodeType() == Node.ELEMENT_NODE) {
103                 context.writeDOMElement((Element JavaDoc)node);
104             }
105         }
106         context.endElement();
107     }
108
109
110     /**
111      * Unimplemented. I think it's used by AXIS for WSDL2Java.
112      */

113     public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc {
114         throw new Exception JavaDoc("unimplemented");
115     }
116 }
117
Popular Tags