1 26 27 package org.objectweb.jonas_ws.deployment.api; 28 29 import java.util.Hashtable ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Map ; 33 34 import javax.xml.namespace.QName ; 35 36 import org.objectweb.jonas_lib.deployment.xml.Qname; 37 38 import org.objectweb.jonas_ws.deployment.xml.JavaWsdlMapping; 39 import org.objectweb.jonas_ws.deployment.xml.JavaXmlTypeMapping; 40 import org.objectweb.jonas_ws.deployment.xml.PackageMapping; 41 42 43 54 public class MappingFile { 55 56 57 private Map namespacePackageMapping; 58 59 60 private Map xmlType2javaClassname; 61 62 63 private JavaWsdlMapping javaWSDLMapping; 64 65 70 public MappingFile(JavaWsdlMapping jwMapping) { 71 72 javaWSDLMapping = jwMapping; 73 74 namespacePackageMapping = new Hashtable (); 76 xmlType2javaClassname = new Hashtable (); 77 78 fillPackageMapping(jwMapping); 79 fillXmlTypeMapping(jwMapping); 80 81 } 82 83 84 89 private void fillPackageMapping(JavaWsdlMapping mapping) { 90 List pml = mapping.getPackageMappingList(); 91 92 for (Iterator i = pml.iterator(); i.hasNext();) { 93 PackageMapping pm = (PackageMapping) i.next(); 95 96 String pt = pm.getPackageType(); 97 String nuri = pm.getNamespaceURI(); 98 99 namespacePackageMapping.put(nuri, pt); 101 } 102 } 103 104 109 private void fillXmlTypeMapping(JavaWsdlMapping mapping) { 110 111 List jxml = mapping.getJavaXmlTypeMappingList(); 112 for (Iterator i = jxml.iterator(); i.hasNext();) { 113 JavaXmlTypeMapping jxtm = (JavaXmlTypeMapping) i.next(); 115 116 QName xmlName = null; 117 String javaName = jxtm.getJavaType(); 118 Qname rootType = jxtm.getRootTypeQname(); 119 if (rootType != null) { 120 xmlName = rootType.getQName(); 121 } else { 122 xmlName = jxtm.getAnonymousTypeQname().getQName(); 123 } 124 125 xmlType2javaClassname.put(xmlName, javaName); 126 } 127 } 128 129 132 public JavaWsdlMapping getXmlJavaWsdlMapping() { 133 return javaWSDLMapping; 134 } 135 136 142 public Map getMappings() { 143 return namespacePackageMapping; 144 } 145 146 155 public String getMapping(String namespaceURI) { 156 return (String ) namespacePackageMapping.get(namespaceURI); 157 } 158 159 166 public String getClassname(QName xmlType) { 167 return (String ) xmlType2javaClassname.get(xmlType); 168 } 169 170 175 public Iterator getXmlTypeMappings() { 176 return xmlType2javaClassname.keySet().iterator(); 177 } 178 179 184 public String toString() { 185 StringBuffer ret = new StringBuffer (); 186 187 ret.append("\n" + getClass().getName()); ret.append("\ngetMappings()=" + namespacePackageMapping); ret.append("\ngetXmlTypeMappings()=" + xmlType2javaClassname); 191 return ret.toString(); 192 } 193 194 197 public int hashCode() { 198 return this.namespacePackageMapping.hashCode() + this.xmlType2javaClassname.hashCode(); 199 } 200 201 208 public boolean equals(Object other) { 209 if (this == other) { 210 return true; 211 } 212 if (other == null) { 213 return false; 214 } 215 if (!(other instanceof MappingFile)) { 216 return false; 217 } 218 MappingFile ref = (MappingFile) other; 219 if (!namespacePackageMapping.equals(ref.getMappings())) { 220 return false; 221 } 222 return true; 224 } 225 226 } 227 | Popular Tags |