KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > databinding > TypeMappingAdapter


1 package org.apache.axis2.wsdl.databinding;
2
3 import javax.xml.namespace.QName JavaDoc;
4 import java.util.HashMap JavaDoc;
5
6 /*
7 * Copyright 2004,2005 The Apache Software Foundation.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 * Default abstract implementation of the type mapper
22 */

23 public abstract class TypeMappingAdapter implements TypeMapper{
24     protected static final String JavaDoc XSD_SCHEMA_URL = "http://www.w3.org/2001/XMLSchema";
25     //hashmap that contains the type mappings
26
protected HashMap JavaDoc map = new HashMap JavaDoc();
27     //counter variable to generate unique parameter ID's
28
protected int counter=0;
29     //Upper limit for the paramete count
30
protected static final int UPPER_PARAM_LIMIT = 1000;
31
32     /**
33      *
34      * @see TypeMapper#getTypeMapping(javax.xml.namespace.QName)
35      */

36     public String JavaDoc getTypeMapping(QName JavaDoc qname) {
37         if ((qname!=null)){
38             Object JavaDoc o = map.get(qname);
39             if (o!=null){
40                return (String JavaDoc)o;
41             }else{
42                 return "org.apache.axis2.om.OMElement";
43             }
44         }
45
46         return null;
47     }
48
49     /**
50      * @see TypeMapper#getParameterName(javax.xml.namespace.QName)
51      */

52     public String JavaDoc getParameterName(QName JavaDoc qname) {
53         if (counter==UPPER_PARAM_LIMIT){
54             counter=0;
55         }
56         return "param" + counter++;
57     }
58
59     /**
60      * @see TypeMapper#addTypeMapping(javax.xml.namespace.QName, Object)
61      */

62     public void addTypeMapping(QName JavaDoc qname, Object JavaDoc value) {
63         map.put(qname,value);
64     }
65 }
66
Popular Tags