001: /* *****************************************************************************
002: * LZObjectSerializer.java
003: * ****************************************************************************/
004:
005: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006: * Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
007: * Use is subject to license terms. *
008: * J_LZ_COPYRIGHT_END *********************************************************/
009:
010: /*
011: * The Apache Software License, Version 1.1
012: *
013: *
014: * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
015: * reserved.
016: *
017: * Redistribution and use in source and binary forms, with or without
018: * modification, are permitted provided that the following conditions
019: * are met:
020: *
021: * 1. Redistributions of source code must retain the above copyright
022: * notice, this list of conditions and the following disclaimer.
023: *
024: * 2. Redistributions in binary form must reproduce the above copyright
025: * notice, this list of conditions and the following disclaimer in
026: * the documentation and/or other materials provided with the
027: * distribution.
028: *
029: * 3. The end-user documentation included with the redistribution,
030: * if any, must include the following acknowledgment:
031: * "This product includes software developed by the
032: * Apache Software Foundation (http://www.apache.org/)."
033: * Alternately, this acknowledgment may appear in the software itself,
034: * if and wherever such third-party acknowledgments normally appear.
035: *
036: * 4. The names "Axis" and "Apache Software Foundation" must
037: * not be used to endorse or promote products derived from this
038: * software without prior written permission. For written
039: * permission, please contact apache@apache.org.
040: *
041: * 5. Products derived from this software may not be called "Apache",
042: * nor may "Apache" appear in their name, without prior written
043: * permission of the Apache Software Foundation.
044: *
045: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
046: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
047: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
048: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
049: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
050: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
051: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
052: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
053: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
054: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
055: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
056: * SUCH DAMAGE.
057: * ====================================================================
058: *
059: * This software consists of voluntary contributions made by many
060: * individuals on behalf of the Apache Software Foundation. For more
061: * information on the Apache Software Foundation, please see
062: * <http://www.apache.org/>.
063: */
064:
065: package org.openlaszlo.remote.swf.soap.encoding;
066:
067: import javax.xml.namespace.QName;
068: import java.io.IOException;
069: import org.apache.axis.encoding.SerializationContext;
070: import org.apache.axis.encoding.Serializer;
071: import org.apache.axis.wsdl.fromJava.Types;
072: import org.w3c.dom.Element;
073: import org.w3c.dom.Node;
074: import org.w3c.dom.NodeList;
075: import org.xml.sax.Attributes;
076: import org.apache.log4j.Logger;
077: import org.openlaszlo.remote.swf.soap.ObjectWrapper;
078:
079: public class LZObjectSerializer implements Serializer {
080:
081: private static Logger mLogger = Logger
082: .getLogger(LZObjectSerializer.class);
083:
084: public static String MECHANISM_TYPE = "LZObjectMechanism";
085:
086: public String getMechanismType() {
087: return MECHANISM_TYPE;
088: }
089:
090: /**
091: *
092: */
093: public void serialize(QName name, Attributes attributes,
094: Object value, SerializationContext context)
095: throws IOException {
096: mLogger.debug(
097: /* (non-Javadoc)
098: * @i18n.test
099: * @org-mes="serialize(" + p[0] + "," + p[1] + "," + p[2] + "," + p[3] + ")"
100: */
101: org.openlaszlo.i18n.LaszloMessages.getMessage(
102: LZObjectSerializer.class.getName(), "051018-100",
103: new Object[] { name, attributes, value, context }));
104: context.startElement(name, attributes);
105: NodeList list = ((ObjectWrapper) value).getElement()
106: .getChildNodes();
107: for (int i = 0; i < list.getLength(); i++) {
108: Node node = (Node) list.item(i);
109: if (node.getNodeType() == Node.ELEMENT_NODE) {
110: context.writeDOMElement((Element) node);
111: }
112: }
113: context.endElement();
114: }
115:
116: /**
117: * Unimplemented. I think it's used by AXIS for WSDL2Java.
118: */
119: public Element writeSchema(Class javaType, Types types)
120: throws Exception {
121: throw new Exception(
122: /* (non-Javadoc)
123: * @i18n.test
124: * @org-mes="unimplemented"
125: */
126: org.openlaszlo.i18n.LaszloMessages.getMessage(
127: LZObjectSerializer.class.getName(), "051018-124"));
128: }
129: }
|