KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > JaxrpcMappingDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment;
24
25 import java.util.Iterator JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.HashSet JavaDoc;
30
31 /**
32  * Holds namespace-to-package mapping information from a
33  * "non-exhaustive" jaxrpc mapping file.
34  *
35  * @author Kenneth Saks
36  */

37  
38 public class JaxrpcMappingDescriptor extends Descriptor {
39
40     private Map JavaDoc packageToNamespaceUriMap = new HashMap JavaDoc();
41     private Map JavaDoc namespaceUriToPackageMap = new HashMap JavaDoc();
42
43     private boolean simpleMapping = true;
44
45     public JaxrpcMappingDescriptor() {
46     }
47
48     public void setSpecVersion(String JavaDoc version) {
49         // ignore
50
}
51
52     public void setIsSimpleMapping(boolean flag) {
53         simpleMapping = flag;
54     }
55
56     /**
57      * @return true if only mapping info only contains package->namespace
58      * mapping.
59      */

60     public boolean isSimpleMapping() {
61         return simpleMapping;
62     }
63
64     public void addMapping(String JavaDoc javaPackage, String JavaDoc namespaceUri) {
65         packageToNamespaceUriMap.put(javaPackage, namespaceUri);
66         namespaceUriToPackageMap.put(namespaceUri, javaPackage);
67     }
68
69     /**
70      * @return Collection of Mapping elements
71      */

72     public Collection JavaDoc getMappings() {
73         Collection JavaDoc mappings = new HashSet JavaDoc();
74         for(Iterator JavaDoc nIter = namespaceUriToPackageMap.keySet().iterator();
75             nIter.hasNext();) {
76             String JavaDoc namespaceUri = (String JavaDoc) nIter.next();
77             String JavaDoc javaPackage = (String JavaDoc)
78                 namespaceUriToPackageMap.get(namespaceUri);
79             Mapping mapping = new Mapping(namespaceUri, javaPackage);
80             mappings.add(mapping);
81         }
82         return mappings;
83     }
84
85     public static class Mapping {
86         private String JavaDoc namespaceUri;
87         private String JavaDoc javaPackage;
88         
89         public Mapping(String JavaDoc namespace, String JavaDoc thePackage) {
90             namespaceUri = namespace;
91             javaPackage = thePackage;
92         }
93
94         public String JavaDoc getNamespaceUri() {
95             return namespaceUri;
96         }
97
98         public String JavaDoc getPackage() {
99             return javaPackage;
100         }
101     }
102     
103 }
104
Popular Tags