Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/axis/deployment/wsdd/WSDDArrayMapping.java


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;
19  import javax.xml.namespace.QName;
20  import org.w3c.dom.Attr;
21  import org.w3c.dom.Element;
22  import org.xml.sax.helpers.AttributesImpl;
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 innerType = null;
41  
42      /**
43       * Default constructor
44       */
45      public WSDDArrayMapping() {
46      }
47  
48      public WSDDArrayMapping(Element e) throws WSDDException {
49          super(e);
50          Attr innerTypeAttr = e.getAttributeNode(ATTR_INNER_TYPE);
51          if (innerTypeAttr != null) {
52              String 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 getElementName() {
60          return QNAME_ARRAYMAPPING;
61      }
62  
63      /**
64       * @return Returns the innerType.
65       */
66      public QName getInnerType() {
67          return innerType;
68      }
69  
70      public void writeToContext(SerializationContext context) throws IOException {
71          AttributesImpl attrs = new AttributesImpl();
72  
73          String typeStr = context.qName2String(typeQName);
74          attrs.addAttribute("", ATTR_LANG_SPEC_TYPE, ATTR_LANG_SPEC_TYPE, "CDATA", typeStr);
75  
76          String qnameStr = context.qName2String(qname);
77          attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, "CDATA", qnameStr);
78  
79          String 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