KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > encoding > ser > DocumentSerializer


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.encoding.ser;
18
19 import org.apache.axis.Constants;
20 import org.apache.axis.encoding.SerializationContext;
21 import org.apache.axis.encoding.Serializer;
22 import org.apache.axis.utils.Messages;
23 import org.apache.axis.wsdl.fromJava.Types;
24 import org.w3c.dom.Element JavaDoc;
25 import org.w3c.dom.Document JavaDoc;
26 import org.xml.sax.Attributes JavaDoc;
27
28 import javax.xml.namespace.QName JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 /**
32  * Serializer for DOM Document
33  *
34  * @author Davanum Srinivas <dims@yahoo.com>
35  */

36
37 public class DocumentSerializer implements Serializer {
38     /**
39      * Serialize a DOM Document
40      */

41     public void serialize(QName JavaDoc name, Attributes JavaDoc attributes,
42                           Object JavaDoc value, SerializationContext context)
43         throws IOException JavaDoc
44     {
45         if (!(value instanceof Document JavaDoc))
46             throw new IOException JavaDoc(Messages.getMessage("cantSerialize01"));
47
48         context.startElement(name, attributes);
49         Document JavaDoc document = (Document JavaDoc)value;
50         context.writeDOMElement(document.getDocumentElement());
51         context.endElement();
52     }
53
54     public String JavaDoc getMechanismType() { return Constants.AXIS_SAX; }
55
56     /**
57      * Return XML schema for the specified type, suitable for insertion into
58      * the &lt;types&gt; element of a WSDL document, or underneath an
59      * &lt;element&gt; or &lt;attribute&gt; declaration.
60      *
61      * @param javaType the Java Class we're writing out schema for
62      * @param types the Java2WSDL Types object which holds the context
63      * for the WSDL being generated.
64      * @return a type element containing a schema simpleType/complexType
65      * @see Types
66      */

67     public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc {
68         return null;
69     }
70 }
71
Popular Tags