KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > deployment > wsdd > WSDDArrayMapping


1 /*
2  * Copyright 2001-2005 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 package org.apache.axis.deployment.wsdd;
17
18 import java.io.IOException JavaDoc;
19 import javax.xml.namespace.QName JavaDoc;
20 import org.w3c.dom.Attr JavaDoc;
21 import org.w3c.dom.Element JavaDoc;
22 import org.xml.sax.helpers.AttributesImpl JavaDoc;
23 import org.apache.axis.encoding.SerializationContext;
24 import org.apache.axis.utils.XMLUtils;
25
26
27 /**
28  * A <code>WSDDArrayMapping</code> is simply a <code>WSDDTypeMapping</code>
29  * which has preset values for the serializer and deserializer attributes.
30  *
31  * This enables the following slightly simplified syntax when expressing
32  * an array mapping:
33  *
34  * &lt;arrayMapping qname="prefix:local" languageSpecificType="java:class" innerType="prefix:local"/&gt;
35  *
36  */

37 public class WSDDArrayMapping extends WSDDTypeMapping {
38
39     /** array item type */
40     private QName JavaDoc innerType = null;
41
42     /**
43      * Default constructor
44      */

45     public WSDDArrayMapping() {
46     }
47
48     public WSDDArrayMapping(Element JavaDoc e) throws WSDDException {
49         super(e);
50         Attr JavaDoc innerTypeAttr = e.getAttributeNode(ATTR_INNER_TYPE);
51         if (innerTypeAttr != null) {
52             String JavaDoc qnameStr = innerTypeAttr.getValue();
53             innerType = XMLUtils.getQNameFromString(qnameStr, e);
54         }
55         serializer = ARRAY_SERIALIZER_FACTORY;
56         deserializer = ARRAY_DESERIALIZER_FACTORY;
57     }
58
59     protected QName JavaDoc getElementName() {
60         return QNAME_ARRAYMAPPING;
61     }
62
63     /**
64      * @return Returns the innerType.
65      */

66     public QName JavaDoc getInnerType() {
67         return innerType;
68     }
69
70     public void writeToContext(SerializationContext context) throws IOException JavaDoc {
71         AttributesImpl JavaDoc attrs = new AttributesImpl JavaDoc();
72
73         String JavaDoc typeStr = context.qName2String(typeQName);
74         attrs.addAttribute("", ATTR_LANG_SPEC_TYPE, ATTR_LANG_SPEC_TYPE, "CDATA", typeStr);
75
76         String JavaDoc qnameStr = context.qName2String(qname);
77         attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, "CDATA", qnameStr);
78
79         String JavaDoc innerTypeStr = context.qName2String(innerType);
80         attrs.addAttribute("", ATTR_INNER_TYPE, ATTR_INNER_TYPE, "CDATA", innerTypeStr);
81
82         context.startElement(QNAME_ARRAYMAPPING, attrs);
83         context.endElement();
84     }
85 }
86
87
88
89
Popular Tags