KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsif > compiler > schema > tools > Schema2Java


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "WSIF" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.apache.wsif.compiler.schema.tools;
59
60 import java.io.File JavaDoc;
61 import java.io.IOException JavaDoc;
62 import java.io.OutputStream JavaDoc;
63 import java.io.OutputStreamWriter JavaDoc;
64 import java.io.Writer JavaDoc;
65 import java.util.Enumeration JavaDoc;
66 import java.util.HashMap JavaDoc;
67 import java.util.Iterator JavaDoc;
68 import java.util.Map JavaDoc;
69 import java.util.Vector JavaDoc;
70 import java.security.AccessController JavaDoc;
71 import java.security.PrivilegedAction JavaDoc;
72
73 import javax.xml.namespace.QName JavaDoc;
74
75 import com.ibm.wsdl.util.xml.DOMUtils;
76 import org.apache.wsif.WSIFConstants;
77 import org.apache.wsif.compiler.schema.SchemaException;
78 import org.apache.wsif.compiler.util.StreamFactory;
79 import org.apache.wsif.compiler.util.TypeMapping;
80 import org.apache.wsif.logging.Trc;
81 import org.w3c.dom.Element JavaDoc;
82 import org.w3c.dom.Node JavaDoc;
83
84 /**
85  * Convert XML schema file into Java class files.
86  * @author: Tian Zhao (tzhao@cs.purdue.edu)
87  * @author Owen Burroughs <owenb@apache.org>
88  */

89 public class Schema2Java {
90
91     private HashMap JavaDoc registry = new HashMap JavaDoc();
92     private String JavaDoc workingDirectory;
93     private HashMap JavaDoc namespaceRegistry = new HashMap JavaDoc();
94
95     private HashMap JavaDoc undefinedRegistry = new HashMap JavaDoc();
96     private Vector JavaDoc schemaElementList = new Vector JavaDoc();
97
98     private String JavaDoc packageName = "";
99     private boolean verbose = true;
100     private boolean overwrite = false;
101     private boolean javac = true;
102
103     /**
104      * Insert the method's description here.
105      * Creation date: (6/22/00 10:08:16 AM)
106      */

107     public Schema2Java(String JavaDoc schemaURI) {
108         registry.put(new QName JavaDoc(schemaURI, "string"), "java.lang.String");
109         registry.put(new QName JavaDoc(schemaURI, "integer"), "java.math.BigInteger");
110         registry.put(new QName JavaDoc(schemaURI, "boolean"), "boolean");
111         registry.put(new QName JavaDoc(schemaURI, "float"), "float");
112         registry.put(new QName JavaDoc(schemaURI, "double"), "double");
113         registry.put(new QName JavaDoc(schemaURI, "binary"), "byte[]");
114         registry.put(new QName JavaDoc(schemaURI, "base64Binary"), "byte[]");
115         registry.put(new QName JavaDoc(schemaURI, "hexBinary"), "byte[]");
116         registry.put(new QName JavaDoc(schemaURI, "long"), "long");
117         registry.put(new QName JavaDoc(schemaURI, "int"), "int");
118         registry.put(new QName JavaDoc(schemaURI, "short"), "short");
119         registry.put(new QName JavaDoc(schemaURI, "decimal"), "java.math.BigDecimal");
120         registry.put(
121             new QName JavaDoc(schemaURI, "QName"),
122             "javax.xml.namespace.QName");
123         // Register dateTime or timeInstant depending on schema
124
if (schemaURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD)) {
125             registry.put(
126                 new QName JavaDoc(schemaURI, "dateTime"),
127                 "java.util.Calendar");
128         } else {
129             registry.put(
130                 new QName JavaDoc(schemaURI, "timeInstant"),
131                 "java.util.Calendar");
132         }
133         registry.put(new QName JavaDoc(schemaURI, "byte"), "byte");
134         registry.put(new QName JavaDoc(schemaURI, "void"), "void");
135         registry.put(new QName JavaDoc(schemaURI, "ur-type"), "java.lang.Object");
136
137         // SOAP encoding simple types
138
registry.put(
139             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "string"),
140             "java.lang.String");
141         registry.put(
142             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "boolean"),
143             "java.lang.Boolean");
144         registry.put(
145             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "float"),
146             "java.lang.Float");
147         registry.put(
148             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "double"),
149             "java.lang.Double");
150         registry.put(
151             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "decimal"),
152             "java.math.BigDecimal");
153         registry.put(
154             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "int"),
155             "java.lang.Integer");
156         registry.put(
157             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "short"),
158             "java.lang.Short");
159         registry.put(
160             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "byte"),
161             "java.lang.Byte");
162         registry.put(
163             new QName JavaDoc(WSIFConstants.NS_URI_SOAP_ENC, "base64"),
164             "byte[]");
165     }
166
167     /**
168      * Insert the method's description here.
169      * Creation date: (6/24/00 3:02:14 PM)
170      * @return org.apache.wsif.compiler.schema.tools.ClassFile
171      * @param any org.apache.wsif.compiler.schema.tools.SchemaAny
172      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
173      */

174     private ClassFile any2Field(SchemaAny any, ClassFile file) {
175
176         if (any == null || file == null)
177             throw new IllegalArgumentException JavaDoc(
178                 "Argument to 'any2Field' cannot " + "be null.");
179
180         file.addField(
181             new ClassField(
182                 "byte[]",
183                 Conventions.schema2JavaName("any", null, false),
184                 any.isArray()));
185         return file;
186
187     }
188
189     /**
190      * Insert the method's description here.
191      * Creation date: (6/24/00 3:07:11 PM)
192      * @return org.apache.wsif.compiler.schema.tools.ClassFile
193      * @param anyAttr org.apache.wsif.compiler.schema.tools.SchemaAnyAttribute
194      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
195      */

196     private ClassFile anyAttribute2Field(
197         SchemaAnyAttribute anyAttr,
198         ClassFile file) {
199
200         if (anyAttr == null || file == null)
201             throw new IllegalArgumentException JavaDoc(
202                 "Argument to 'anyAttribute2Field' " + "cannot be null.");
203
204         file.addField(
205             new ClassField(
206                 "byte[]",
207                 Conventions.schema2JavaName("anyAttribute", null, false),
208                 false));
209         return file;
210     }
211
212     /**
213      * Insert the method's description here.
214      * Creation date: (6/23/00 11:48:17 AM)
215      * @return org.apache.wsif.compiler.schema.tools.ClassFile
216      * @param attr org.apache.wsif.compiler.schema.tools.SchemaAttribute
217      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
218      */

219     private ClassFile attribute2Field(SchemaAttribute attr, ClassFile file)
220         throws SchemaException {
221
222         if (attr == null || file == null)
223             throw new IllegalArgumentException JavaDoc(
224                 "Argument to 'attribute2Field' " + "cannot be null.");
225
226         QName JavaDoc type = attr.getType();
227         QName JavaDoc ref = attr.getRef();
228         SchemaSimpleType simp = attr.getChild();
229         String JavaDoc targetURI = attr.getTargetURI();
230
231         ClassField field;
232         if (ref != null) {
233             field =
234                 new ClassField(
235                     getJavaType(ref, targetURI, "attribute"),
236                     Conventions.schema2JavaName(
237                         "attribute",
238                         ref.getLocalPart(),
239                         false),
240                     false);
241             file.addField(field);
242         } else if (type != null) {
243             field =
244                 new ClassField(
245                     getJavaType(type, targetURI, "simpleType"),
246                     Conventions.schema2JavaName(
247                         "attribute",
248                         attr.getName(),
249                         false),
250                     false);
251             file.addField(field);
252         } else if (simp != null) {
253             String JavaDoc name =
254                 Conventions.schema2JavaName("attribute", attr.getName(), false);
255             file = simpleType2Field(name, false, simp, file);
256         }
257
258         return file;
259     }
260
261     /**
262      * Insert the method's description here.
263      * Creation date: (6/23/00 10:01:42 AM)
264      * @return org.apache.wsif.compiler.schema.tools.ClassFile
265      * @param registry java.util.HashMap
266      * @param elm org.apache.wsif.compiler.schema.tools.SchemaComplexType
267      * @param targetURI java.lang.String
268      */

269     private ClassFile attributeGroup2Class(SchemaAttributeGroup attrGp)
270         throws SchemaException {
271
272         if (attrGp == null)
273             throw new IllegalArgumentException JavaDoc(
274                 "Argument to 'attributeGroup2Class' " + "cannot be null.");
275
276         String JavaDoc className =
277             Conventions.schema2JavaName(
278                 "attributeGroup",
279                 attrGp.getName(),
280                 true);
281         ClassFile file = new ClassFile(className);
282
283         Vector JavaDoc children = attrGp.getChildren();
284         for (int i = 0; i < children.size(); i++) {
285             SchemaType child = (SchemaType) children.elementAt(i);
286             switch (child.getElementType()) {
287                 case SchemaType.ATTRIBUTEGROUP :
288                     file =
289                         attributeGroup2Field(
290                             (SchemaAttributeGroup) child,
291                             file);
292                     break;
293                 case SchemaType.ATTRIBUTE :
294                     file = attribute2Field((SchemaAttribute) child, file);
295                     break;
296                 case SchemaType.ANYATTRIBUTE :
297                     }
298         }
299
300         return file;
301     }
302
303     /**
304      * Insert the method's description here.
305      * Creation date: (6/23/00 11:31:18 AM)
306      * @return org.apache.wsif.compiler.schema.tools.ClassField
307      * @param attrGp org.apache.wsif.compiler.schema.tools.SchemaAttributeGroup
308      */

309     private ClassFile attributeGroup2Field(
310         SchemaAttributeGroup attrGp,
311         ClassFile file)
312         throws SchemaException {
313
314         if (attrGp == null || file == null)
315             throw new IllegalArgumentException JavaDoc(
316                 "Argument to 'attributeGroup2Field' " + "cannot be null.");
317
318         ClassField field;
319
320         QName JavaDoc ref = attrGp.getRef();
321         if (ref != null)
322             field =
323                 new ClassField(
324                     getJavaType(ref, attrGp.getTargetURI(), "attributeGroup"),
325                     Conventions.schema2JavaName(
326                         "attributeGroup",
327                         ref.getLocalPart(),
328                         false),
329                     false);
330         else {
331             throw new SchemaException(
332                 "Attribute group can only be defined at " + "the top level.");
333         }
334         file.addField(field);
335
336         return file;
337
338     }
339
340     /**
341      * Insert the method's description here.
342      * Creation date: (6/23/00 10:01:42 AM)
343      * @return org.apache.wsif.compiler.schema.tools.ClassFile
344      * @param registry java.util.HashMap
345      * @param elm org.apache.wsif.compiler.schema.tools.SchemaComplexType
346      */

347     private ClassFile complexType2Class(
348         String JavaDoc className,
349         SchemaComplexType elm)
350         throws SchemaException {
351
352         if (className == null || elm == null)
353             throw new IllegalArgumentException JavaDoc(
354                 "Argument to 'complexType2Class' " + "cannot be null.");
355
356         QName JavaDoc base = elm.getBase();
357         ClassFile file = new ClassFile(className);
358
359         if (base != null)
360             file.superClassName =
361                 getJavaType(base, elm.getTargetURI(), "complexType");
362         // This just covers the case when the base is a undefined complexType.
363
// If it is a undefined simpleType, there is nothing we can do anyway.
364

365         Vector JavaDoc children = elm.getChildren();
366         for (int i = 0; i < children.size(); i++) {
367             SchemaType child = (SchemaType) children.elementAt(i);
368             String JavaDoc name = child.getName();
369             switch (child.getElementType()) {
370                 case SchemaType.ELEMENT :
371                     file = element2Field((SchemaElement) child, file);
372                     break;
373                 case SchemaType.GROUP :
374                     file = group2Field((SchemaGroup) child, file);
375                     break;
376                 case SchemaType.ATTRIBUTE :
377                     file = attribute2Field((SchemaAttribute) child, file);
378                     break;
379                 case SchemaType.ATTRIBUTEGROUP :
380                     file =
381                         attributeGroup2Field(
382                             (SchemaAttributeGroup) child,
383                             file);
384                     break;
385                 case SchemaType.ANY :
386                     file = any2Field((SchemaAny) child, file);
387                     break;
388                 case SchemaType.ANYATTRIBUTE :
389                     file = anyAttribute2Field((SchemaAnyAttribute) child, file);
390                     break;
391                 case SchemaType.ALL :
392                 case SchemaType.CHOICE :
393                 case SchemaType.SEQUENCE :
394                     file = mgs2Field((SchemaMGS) child, file);
395                     break;
396             }
397         }
398
399         return file;
400     }
401
402     /**
403      * This method takes inputs of an Schema Element, a HashMap and returns the same HashMap filled with
404      * the mappings from schema QNames to Java class names or primitive types.
405      * Repeatedly call this method on the same object will have cumulative effect. That is, the registry
406      * returned will have all the mappings for every DOM elements processed.
407      *
408      * To output the java class files, call the public method: outputJavaMapping () once all the schema elements
409      * have been processed.
410      *
411      * Creation date: (6/22/00 6:04:35 PM)
412      * @return java.util.HashMap
413      * @param root org.w3c.dom.Element
414      * @param registry java.util.HashMap
415      */

416     public Map JavaDoc createJavaMapping(Element JavaDoc root, Map JavaDoc reg)
417         throws SchemaException {
418
419         if (root == null || reg == null)
420             throw new IllegalArgumentException JavaDoc(
421                 "Argument to 'createJavaMapping' " + "cannot be null.");
422
423         String JavaDoc targetURI = root.getAttribute("targetNamespace");
424         // set target namespace uri for the schema model
425
Vector JavaDoc elements = parseSchemaRoot(root, targetURI);
426
427         for (int i = 0; i < elements.size(); i++) {
428             schemaElementList.addElement(elements.elementAt(i));
429         }
430
431         // First reset the registry to builtin types only.
432
updateRegistry(schemaElementList);
433
434         return getRegistry(reg);
435
436     }
437
438     /**
439      * Insert the method's description here.
440      * Creation date: (6/23/00 6:09:47 PM)
441      * @return org.apache.wsif.compiler.schema.tools.ClassFile
442      * @param elm org.apache.wsif.compiler.schema.tools.SchemaElement
443      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
444      */

445     private ClassFile element2Field(SchemaElement elm, ClassFile file)
446         throws SchemaException {
447
448         if (elm == null || file == null)
449             throw new IllegalArgumentException JavaDoc(
450                 "Argument to 'element2Field' " + "cannot be null.");
451
452         String JavaDoc name = elm.getName();
453         QName JavaDoc ref = elm.getRef();
454         QName JavaDoc type = elm.getType();
455         SchemaType child = elm.getChild();
456         String JavaDoc targetURI = elm.getTargetURI();
457
458         if (name != null)
459             name = Conventions.schema2JavaName("element", name, false);
460
461         if (ref != null) {
462             String JavaDoc javaType = getJavaType(ref, targetURI, "element");
463             file.addField(
464                 new ClassField(
465                     javaType,
466                     Conventions.schema2JavaName(
467                         "element",
468                         ref.getLocalPart(),
469                         false),
470                     elm.isArray()));
471         } else if (type != null) {
472             // I just guess arbitrarily that the type attribute refers to a complexType and
473
// in case this type is not defined yet, I generate a generic Java Class name for it.
474
// However, it could also be a simpleType in which case we are screwed.
475

476             String JavaDoc javaType = getJavaType(type, targetURI, "complexType");
477             file.addField(new ClassField(javaType, name, elm.isArray()));
478         } else if (child == null) {
479             throw new SchemaException(
480                 "The type of this element is unknown: '" + name + "'.");
481         } else if (child.getElementType() == SchemaType.SIMPLETYPE) {
482             file =
483                 simpleType2Field(
484                     name,
485                     elm.isArray(),
486                     (SchemaSimpleType) child,
487                     file);
488         } else if (child.getElementType() == SchemaType.COMPLEXTYPE) {
489             throw new SchemaException(
490                 "Inner complex-types are not supported: '" + name + "'.");
491
492             // String cname = Conventions.schema2JavaName ("element", name, true);
493
// file.addField (new ClassField (cname, name, elm.isArray ()));
494
// file.addInnerClass (complexType2Class (cname, (SchemaComplexType) child));
495
}
496
497         return file;
498     }
499
500     /**
501      * Insert the method's description here.
502      * Creation date: (6/22/00 12:07:49 AM)
503      * @return org.apache.soap.util.xml.QName
504      * @param elment org.w3c.dom.Element
505      * @param name java.lang.String
506      */

507     private QName JavaDoc getAttributeQName(Element JavaDoc element, String JavaDoc attr) {
508
509         if (element == null || attr == null)
510             throw new IllegalArgumentException JavaDoc(
511                 "Argument to 'getAttrQName' " + "cannot be null.");
512
513         String JavaDoc name = DOMUtils.getAttribute(element, attr);
514
515         if (name == null)
516             return null;
517
518         int index = name.lastIndexOf(":");
519         String JavaDoc prefix = null;
520
521         if (index != -1) {
522             prefix = name.substring(0, index);
523             name = name.substring(index + 1);
524         }
525         String JavaDoc uri = DOMUtils.getNamespaceURIFromPrefix(element, prefix);
526
527         return new QName JavaDoc(uri, name);
528
529     }
530
531     /**
532      * Insert the method's description here.
533      * Creation date: (6/22/00 4:56:42 PM)
534      * @return java.lang.String
535      * @param QName java.lang.String
536      */

537     private String JavaDoc getGenericJavaName(QName JavaDoc qName, String JavaDoc elementType) {
538
539         if (qName == null)
540             throw new IllegalArgumentException JavaDoc(
541                 "Argument to 'getGenericJavaName' " + "cannot be null.");
542
543         String JavaDoc javaName = (String JavaDoc) undefinedRegistry.get(qName);
544         if (javaName != null)
545             return javaName;
546
547         String JavaDoc javaPath = getNamespaceURIMapping(qName.getNamespaceURI());
548
549         String JavaDoc name = qName.getLocalPart();
550         name = Conventions.schema2JavaName(elementType, name, true);
551
552         if (javaPath.compareTo("") != 0)
553             javaName = javaPath + "." + name;
554         else
555             javaName = name;
556
557         undefinedRegistry.put(qName, javaName);
558
559         Trc.event(
560             this,
561             "Schema name ",
562             qName,
563             " is undefined, and so generic Java name ",
564             javaName,
565             " is used instead.");
566         return javaName;
567     }
568
569     /**
570      * Insert the method's description here.
571      * Creation date: (6/23/00 9:42:50 AM)
572      * @return java.lang.String
573      * @param Registry java.util.HashMap
574      * @param name org.apache.soap.util.xml.QName
575      */

576     private String JavaDoc getJavaType(
577         QName JavaDoc name,
578         String JavaDoc targetURI,
579         String JavaDoc elementType)
580         throws SchemaException {
581
582         if (name == null)
583             throw new IllegalArgumentException JavaDoc(
584                 "Argument to 'getJavaType' " + "cannot be null.");
585
586         String JavaDoc type = (String JavaDoc) registry.get(name);
587
588         if (type == null) {
589             throw new SchemaException(
590                 "Basic type '" + name + "' not supported.");
591
592             // type = getGenericJavaName (name, elementType);
593
}
594
595         String JavaDoc targetNS = getNamespaceURIMapping(targetURI);
596
597         if (type.startsWith(targetNS)
598             /* || type.startsWith (baseTypeDefinitionNS)*/
599             )
600             type = type.substring(type.lastIndexOf(".") + 1);
601
602         return type;
603     }
604
605     /**
606      * Set the Java package into which the generated code should be placed.
607      * Defaults to unnamed package.
608      */

609     public void setPackageName(String JavaDoc packageName) {
610         this.packageName = packageName;
611     }
612
613     /**
614      * Insert the method's description here.
615      * Creation date: (6/22/00 12:23:44 PM)
616      * @return java.lang.String
617      * @param namespaceURI java.lang.String
618      */

619     public String JavaDoc getNamespaceURIMapping(String JavaDoc namespaceURI) {
620
621         if (namespaceURI == null)
622             throw new IllegalArgumentException JavaDoc(
623                 "Argument to "
624                     + "'getNamespaceURIMapping' "
625                     + "cannot be null.");
626
627         if (namespaceURI.compareTo("") == 0)
628             return "";
629
630         // MJD - debug
631
if (packageName != null && !packageName.equals("")) {
632             return packageName;
633         }
634         // MJD - debug
635

636         String JavaDoc javaPath = (String JavaDoc) namespaceRegistry.get(namespaceURI);
637         if (javaPath == null) {
638             javaPath = Conventions.namespaceURI2JavaPath(namespaceURI);
639             namespaceRegistry.put(namespaceURI, javaPath);
640         }
641         return javaPath;
642
643     }
644
645     /**
646      * Insert the method's description here.
647      * Creation date: (7/2/00 4:06:35 PM)
648      * @return java.util.HashMap
649      * @param reg java.util.HashMap
650      */

651     public Map JavaDoc getRegistry(Map JavaDoc reg) {
652
653         for (Iterator JavaDoc i = registry.keySet().iterator(); i.hasNext();) {
654             QName JavaDoc key = (QName JavaDoc) i.next();
655             reg.put(key, new TypeMapping(key, (String JavaDoc) registry.get(key)));
656         }
657         return reg;
658
659     }
660
661     /**
662      * Gets the current working directory for generated Java files.
663      * @return dir java.lang.String defaults to the "user.dir"
664      * system property
665      * @see #setWorkingDirectory
666      */

667     public String JavaDoc getWorkingDirectory() {
668         if (workingDirectory == null) {
669             workingDirectory =
670                 (String JavaDoc) AccessController.doPrivileged(new PrivilegedAction JavaDoc() {
671                 public Object JavaDoc run() {
672                     return System.getProperty("user.dir");
673                 }
674             });
675         }
676         return workingDirectory;
677     }
678
679     private ClassFile group2Class(SchemaGroup gp) throws SchemaException {
680
681         if (gp == null)
682             throw new IllegalArgumentException JavaDoc(
683                 "Argument to 'group2Class' " + "cannot be null.");
684
685         SchemaMGS child = gp.getChild();
686         String JavaDoc className =
687             Conventions.schema2JavaName("group", gp.getName(), true);
688         ClassFile file = new ClassFile(className);
689         file = mgs2Field(child, file);
690
691         return file;
692     }
693
694     /**
695      * Insert the method's description here.
696      * Creation date: (6/23/00 6:46:55 PM)
697      * @return org.apache.wsif.compiler.schema.tools.ClassFile
698      * @param gp org.apache.wsif.compiler.schema.tools.SchemaGroup
699      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
700      */

701     private ClassFile group2Field(SchemaGroup gp, ClassFile file)
702         throws SchemaException {
703
704         if (gp == null || file == null)
705             throw new IllegalArgumentException JavaDoc(
706                 "Argument to 'group2Field' " + "cannot be null.");
707
708         QName JavaDoc ref = gp.getRef();
709
710         if (ref != null) {
711             String JavaDoc javaType = getJavaType(ref, gp.getTargetURI(), "group");
712             file.addField(
713                 new ClassField(
714                     javaType,
715                     Conventions.schema2JavaName(
716                         "group",
717                         ref.getLocalPart(),
718                         false),
719                     gp.isArray()));
720         }
721
722         return file;
723     }
724
725     private ClassFile mgs2Class(String JavaDoc className, SchemaMGS elm)
726         throws SchemaException {
727
728         if (className == null || elm == null)
729             throw new IllegalArgumentException JavaDoc(
730                 "Argument to 'mgs2Class' " + "cannot be null.");
731
732         ClassFile file = new ClassFile(className);
733
734         Vector JavaDoc children = elm.getChildren();
735         for (int i = 0; i < children.size(); i++) {
736             SchemaType child = (SchemaType) children.elementAt(i);
737
738             switch (child.getElementType()) {
739                 case SchemaType.ELEMENT :
740                     element2Field((SchemaElement) child, file);
741                     break;
742                 case SchemaType.GROUP :
743                     group2Field((SchemaGroup) child, file);
744                     break;
745                 case SchemaType.ANY :
746                 case SchemaType.CHOICE :
747                 case SchemaType.SEQUENCE :
748                     mgs2Field((SchemaMGS) child, file);
749             }
750         }
751
752         return file;
753     }
754
755     /**
756      * Insert the method's description here.
757      * Creation date: (6/24/00 2:24:48 PM)
758      * @return org.apache.wsif.compiler.schema.tools.ClassFile
759      * @param mgs org.apache.wsif.compiler.schema.tools.SchemaMGS
760      * @param file org.apache.wsif.compiler.schema.tools.ClassFile
761      */

762     private ClassFile mgs2Field(SchemaMGS mgs, ClassFile file)
763         throws SchemaException {
764
765         if (mgs == null || file == null)
766             throw new IllegalArgumentException JavaDoc(
767                 "Argument to 'mgs2Field' " + "cannot be null.");
768
769         String JavaDoc mgsType;
770         switch (mgs.getElementType()) {
771             case SchemaType.ALL :
772                 mgsType = "all";
773                 break;
774             case SchemaType.CHOICE :
775                 mgsType = "choice";
776                 break;
777             case SchemaType.SEQUENCE :
778                 mgsType = "sequence";
779                 break;
780             default :
781                 return file;
782         }
783
784         String JavaDoc cname = Conventions.schema2JavaName(mgsType, null, true);
785         String JavaDoc fname = Conventions.schema2JavaName(mgsType, null, false);
786         file.addField(new ClassField(cname, fname, mgs.isArray()));
787         file.addInnerClass(mgs2Class(cname, mgs));
788         return file;
789
790     }
791
792     /**
793      * Output the Java class files created from XML Schema models to the working directory.
794      * Call public method: setWorkingDirectory (String directory) to set the output directory.
795      *
796      * Creation date: (5/28/00 2:56:06 PM)
797      *
798      */

799     public void outputJavaMapping() throws SchemaException, IOException JavaDoc {
800
801         Vector JavaDoc classFileList = new Vector JavaDoc();
802
803         for (int i = 0; i < schemaElementList.size(); i++) {
804             SchemaType element = (SchemaType) schemaElementList.elementAt(i);
805             ClassFile file = null;
806
807             switch (element.getElementType()) {
808                 case SchemaType.COMPLEXTYPE :
809                     SchemaComplexType cmp = (SchemaComplexType) element;
810                     String JavaDoc className =
811                         Conventions.schema2JavaName(
812                             "complexType",
813                             cmp.getName(),
814                             true);
815                     file = complexType2Class(className, cmp);
816                     break;
817                 case SchemaType.GROUP :
818                     file = group2Class((SchemaGroup) element);
819                     break;
820                 case SchemaType.ATTRIBUTEGROUP :
821                     file = attributeGroup2Class((SchemaAttributeGroup) element);
822                     break;
823                 case SchemaType.ELEMENT :
824                     SchemaElement el = (SchemaElement) element;
825                     SchemaType child = el.getChild();
826                     if (child != null
827                         && child.getElementType() == SchemaType.COMPLEXTYPE) {
828                         className =
829                             Conventions.schema2JavaName(
830                                 "element",
831                                 el.getName(),
832                                 true);
833                         file =
834                             complexType2Class(
835                                 className,
836                                 (SchemaComplexType) el.getChild());
837                     }
838                     break;
839             }
840             if (file != null) {
841                 file.packageName =
842                     getNamespaceURIMapping(element.getTargetURI());
843                 classFileList.addElement(file);
844             }
845         }
846
847         int classCount = classFileList.size();
848         String JavaDoc[] fileNames = new String JavaDoc[classCount];
849         StreamFactory streamFactory = new StreamFactory();
850
851         for (int classIndex = 0; classIndex < classCount; classIndex++) {
852             ClassFile classFile =
853                 (ClassFile) classFileList.elementAt(classIndex);
854             String JavaDoc javaPathName =
855                 Conventions.getJavaPathName(
856                     getWorkingDirectory(),
857                     classFile.packageName);
858             String JavaDoc javaFileName = classFile.className + ".java";
859             OutputStream JavaDoc os =
860                 streamFactory.getOutputStream(
861                     javaPathName,
862                     javaFileName,
863                     overwrite);
864             Writer JavaDoc classWriter = new OutputStreamWriter JavaDoc(os);
865
866             classWriter.write(
867                 "/*\n *This class is automatically generated by schema to Java program.\n");
868             classWriter.write(
869                 " *Only a subset of schema is handled and some of the schema information\n");
870             classWriter.write(" *may be lost during translation\n */\n\n");
871
872             if (classFile.packageName != null)
873                 classWriter.write("package " + classFile.packageName + ";\n\n");
874             // classWriter.write ("import " + baseTypeDefinitionNS + ".*;\n\n");
875
printJavaFile(classWriter, classFile, null);
876
877             classWriter.flush();
878             classWriter.close();
879
880             fileNames[classIndex] =
881                 new File JavaDoc(javaPathName, javaFileName).getAbsolutePath();
882         }
883
884         if (javac) {
885             for (int i = 0; i < classCount; i++) {
886                 if (Conventions.JDKcompile(fileNames[i], getWorkingDirectory())
887                     && verbose) {
888                     System.out.println("Compiled file '" + fileNames[i] + "'.");
889                 }
890             }
891         }
892     }
893
894     /**
895      * Insert the method's description here.
896      * Creation date: (6/21/00 6:51:57 PM)
897      * @param root org.w3c.dom.Element
898      */

899     private Vector JavaDoc parseSchemaRoot(Element JavaDoc root, String JavaDoc targetURI)
900         throws SchemaException {
901         if (root == null)
902             throw new IllegalArgumentException JavaDoc(
903                 "Argument to 'parseSchemaRoot' " + "cannot be null.");
904
905         Node JavaDoc child = root.getFirstChild();
906         Vector JavaDoc elements = new Vector JavaDoc();
907
908         while (child != null) {
909             if (child.getNodeType() == Node.ELEMENT_NODE) {
910                 Element JavaDoc element = (Element JavaDoc) child;
911
912                 String JavaDoc elementType = element.getLocalName();
913
914                 if (elementType == null) {
915                     return null;
916                 }
917
918                 String JavaDoc name = DOMUtils.getAttribute(element, "name");
919                 QName JavaDoc type = getAttributeQName(element, "type");
920                 boolean isArray = false;
921
922                 if (elementType.equals("complexType")) {
923                     boolean isFinal = false;
924                     boolean isAbstract = false;
925                     QName JavaDoc base = null;
926                     Vector JavaDoc children = parseSchemaRoot(element, targetURI);
927                     elements.addElement(
928                         new SchemaComplexType(
929                             name,
930                             base,
931                             isAbstract,
932                             isFinal,
933                             children,
934                             targetURI));
935                 } else if (elementType.equals("simpleType")) {
936                     QName JavaDoc base = null;
937                     boolean isList = false;
938                     elements.addElement(
939                         new SchemaSimpleType(
940                             name,
941                             base,
942                             isList,
943                             targetURI));
944                 } else if (elementType.equals("element")) {
945                     QName JavaDoc ref = null;
946                     elements.addElement(
947                         new SchemaElement(
948                             name,
949                             ref,
950                             type,
951                             isArray,
952                             null,
953                             targetURI));
954                 } else {
955                     // Ignore any other element types
956
}
957             }
958
959             child = child.getNextSibling();
960         }
961
962         return elements;
963     }
964
965     /**
966      * Insert the method's description here.
967      * Creation date: (5/30/00 4:14:39 PM)
968      * @param classWriter java.io.FileWriter
969      * @param classFile schema2JavaVersion2.ClassFile
970      * @param tab java.lang.String
971      * @exception java.io.IOException The exception description.
972      */

973     private void printJavaFile(
974         Writer JavaDoc classWriter,
975         ClassFile classFile,
976         String JavaDoc tab)
977         throws java.io.IOException JavaDoc {
978
979         String JavaDoc className = classFile.className;
980         String JavaDoc superClassName = classFile.superClassName;
981
982         // classWriter.write("import java.lang.*;\n");
983

984         if (tab == null) {
985             tab = "";
986             classWriter.write("public ");
987         } else
988             classWriter.write(tab);
989         if (classFile.isAbstract)
990             classWriter.write("abstract ");
991         else if (classFile.isFinal)
992             classWriter.write("final");
993         if (superClassName != null)
994             classWriter.write(
995                 "class " + className + " extends " + superClassName + "{\n");
996         else
997             classWriter.write("class " + className + "{\n");
998
999         classWriter.write("\n" + tab + "\t//instance variables\n");
1000
1001        int fieldLength = classFile.getFieldCount();
1002        for (int fieldIndex = 0; fieldIndex < fieldLength; fieldIndex++) {
1003            ClassField classField = classFile.getField(fieldIndex);
1004            classWriter.write(tab + "\tprivate " + classField.fieldType);
1005            if (classField.isArray)
1006                classWriter.write("[]");
1007            classWriter.write("\t" + classField.fieldName + ";\n");
1008        }
1009
1010        classWriter.write("\n" + tab + "\t//constructors\n");
1011        if (fieldLength > 0)
1012            classWriter.write(tab + "\tpublic " + className + " () { }\n");
1013
1014        classWriter.write("\n" + tab + "\tpublic " + className + " (");
1015        for (int fieldIndex = 0; fieldIndex < fieldLength; fieldIndex++) {
1016            ClassField classField = classFile.getField(fieldIndex);
1017            classWriter.write(classField.fieldType);
1018            if (classField.isArray)
1019                classWriter.write("[]");
1020            classWriter.write(" " + classField.fieldName);
1021            if (fieldIndex < fieldLength - 1)
1022                classWriter.write(", ");
1023        }
1024        classWriter.write(") {\n");
1025
1026        for (int fieldIndex = 0; fieldIndex < fieldLength; fieldIndex++) {
1027            ClassField classField = classFile.getField(fieldIndex);
1028            classWriter.write(
1029                tab
1030                    + "\t\tthis."
1031                    + classField.fieldName
1032                    + "\t= "
1033                    + classField.fieldName
1034                    + ";\n");
1035        }
1036        classWriter.write(tab + "\t}\n");
1037
1038        // code added by NKM
1039
// let's have a setter and getter for each field
1040
// this will make the generated code a bean which will let us use it in nice ways
1041
for (int fieldIndex = 0; fieldIndex < fieldLength; fieldIndex++) {
1042            ClassField classField = classFile.getField(fieldIndex);
1043            String JavaDoc propertyName =
1044                Character.toUpperCase(classField.fieldName.charAt(0))
1045                    + classField.fieldName.substring(1);
1046            classWriter.write("\n" + tab + "\tpublic ");
1047            if (classField.isArray)
1048                classWriter.write("[]");
1049            classWriter.write(
1050                classField.fieldType + " get" + propertyName + "() {\n");
1051            classWriter.write(
1052                tab + "\t\treturn " + classField.fieldName + ";\n");
1053            classWriter.write(tab + "\t}\n");
1054            classWriter.write("\n" + tab + "\tpublic ");
1055            classWriter.write(
1056                " void set" + propertyName + "(" + classField.fieldType);
1057            if (classField.isArray)
1058                classWriter.write("[]");
1059            classWriter.write(" " + classField.fieldName + ") {\n");
1060            classWriter.write(
1061                tab
1062                    + "\t\tthis."
1063                    + classField.fieldName
1064                    + "\t= "
1065                    + classField.fieldName
1066                    + ";\n");
1067            classWriter.write(tab + "\t}\n");
1068        }
1069        // end of code added by NKM
1070

1071        classWriter.write("\n\tpublic String toString() {\n");
1072        classWriter.write("\t\treturn ");
1073
1074        for (int fieldIndex = 0; fieldIndex < fieldLength; fieldIndex++) {
1075            ClassField classField = classFile.getField(fieldIndex);
1076
1077            if (fieldIndex > 0) {
1078                classWriter.write(" + \"\\n\" + \n\t\t\t");
1079            }
1080
1081            classWriter.write(
1082                "\"" + classField.fieldName + "=\" + " + classField.fieldName);
1083        }
1084
1085        classWriter.write(";\n\t}\n");
1086
1087        int innerClassCount = classFile.getInnerClassCount();
1088        if (innerClassCount > 0) {
1089            classWriter.write("\n" + tab + "\t//Inner classes\n");
1090            for (int innerClassIndex = 0;
1091                innerClassIndex < innerClassCount;
1092                innerClassIndex++) {
1093                ClassFile innerClassFile =
1094                    classFile.getInnerClass(innerClassIndex);
1095                printJavaFile(classWriter, innerClassFile, tab + "\t");
1096            }
1097        }
1098        classWriter.write("\n" + tab + "}");
1099
1100    }
1101
1102    /**
1103     * Set the mapping between namespace URI and the java package name used in the generated class files.
1104     * Creation date: (6/22/00 12:20:21 PM)
1105     * @param namespaceURI java.lang.String
1106     * @param javaPath java.lang.String
1107     */

1108    public void setNamespaceURIMapping(String JavaDoc namespaceURI, String JavaDoc javaPath) {
1109
1110        if (namespaceURI == null || javaPath == null)
1111            throw new IllegalArgumentException JavaDoc(
1112                "Argument to "
1113                    + "'setNamespaceURIMapping' "
1114                    + "cannot be null.");
1115
1116        namespaceRegistry.put(namespaceURI, javaPath);
1117    }
1118
1119    /**
1120     * Set the working directory for generated Java files.
1121     * Creation date: (5/30/00 9:17:36 PM)
1122     * @param dir java.lang.String
1123     */

1124    public void setWorkingDirectory(String JavaDoc dir)
1125        throws IllegalArgumentException JavaDoc {
1126
1127        if (dir == null)
1128            throw new IllegalArgumentException JavaDoc(
1129                "Argument to " + "'setWorkingDirectory' " + "cannot be null.");
1130
1131        workingDirectory = dir;
1132    }
1133
1134    public void setVerbose(boolean verbose) {
1135        this.verbose = verbose;
1136    }
1137
1138    public boolean getVerbose() {
1139        return verbose;
1140    }
1141
1142    public void setOverwrite(boolean overwrite) {
1143        this.overwrite = overwrite;
1144    }
1145
1146    public boolean getOverwrite() {
1147        return overwrite;
1148    }
1149
1150    public void setJavac(boolean javac) {
1151        this.javac = javac;
1152    }
1153
1154    /**
1155     * Insert the method's description here.
1156     * Creation date: (6/23/00 5:45:54 PM)
1157     * @return org.apache.wsif.compiler.schema.tools.ClassFile
1158     * @param name java.lang.String
1159     * @param simp org.apache.wsif.compiler.schema.tools.SchemaSimpleType
1160     */

1161    private ClassFile simpleType2Field(
1162        String JavaDoc name,
1163        boolean isArray,
1164        SchemaSimpleType simp,
1165        ClassFile file)
1166        throws SchemaException {
1167
1168        if (name == null || simp == null || file == null)
1169            throw new IllegalArgumentException JavaDoc(
1170                "Argument to 'simpleType2Field' " + "cannot be null.");
1171
1172        QName JavaDoc base = simp.getBase();
1173        String JavaDoc type = getJavaType(base, simp.getTargetURI(), "simpleType");
1174
1175        if (simp.isList())
1176            type = type + "[]";
1177        file.addField(new ClassField(type, name, isArray));
1178
1179        return file;
1180    }
1181
1182    /**
1183     * This method takes a list of schema elements, target uri and update the registry content based on the
1184     * schema element list.
1185     *
1186     * Creation date: (6/22/00 10:15:25 AM)
1187     * @return java.util.HashMap
1188     * @param registry java.util.HashMap
1189     * @param elements java.util.Vector
1190     */

1191    private void updateRegistry(Vector JavaDoc elements) throws SchemaException {
1192
1193        if (elements == null)
1194            throw new IllegalArgumentException JavaDoc(
1195                "Argument to 'updateRegistry' " + "cannot be null.");
1196
1197        HashMap JavaDoc simpleTypeTable = new HashMap JavaDoc();
1198
1199        for (int i = 0; i < elements.size(); i++) {
1200            SchemaType element = (SchemaType) elements.elementAt(i);
1201            String JavaDoc name = element.getName();
1202            if (name == null)
1203                name = "";
1204            QName JavaDoc qName = new QName JavaDoc(element.getTargetURI(), name);
1205
1206            if (element.getElementType() == SchemaType.SIMPLETYPE) {
1207                simpleTypeTable.put(qName, element);
1208            }
1209        }
1210
1211        boolean changed = true;
1212
1213        while (changed) {
1214            changed = false;
1215            for (Iterator JavaDoc it = simpleTypeTable.keySet().iterator();
1216                it.hasNext();
1217                ) {
1218                QName JavaDoc qName = (QName JavaDoc) it.next();
1219
1220                SchemaSimpleType simpleType =
1221                    (SchemaSimpleType) simpleTypeTable.get(qName);
1222                QName JavaDoc base = simpleType.getBase();
1223                boolean isList = simpleType.isList();
1224
1225                if (base != null) {
1226                    String JavaDoc javaType = (String JavaDoc) registry.get(base);
1227                    if (javaType == null)
1228                        if (simpleTypeTable.containsKey(base))
1229                            continue;
1230                        else
1231                            javaType = getGenericJavaName(base, "simpleType");
1232
1233                    if (isList)
1234                        javaType = javaType + "[]";
1235                    registry.put(qName, javaType);
1236                    changed = true;
1237                    simpleTypeTable.remove(qName);
1238                } else {
1239                    String JavaDoc javaType = getGenericJavaName(qName, "simpleType");
1240                    registry.put(qName, javaType);
1241                    // ignore it
1242
//throw new SchemaException("'simpleType' must have 'base' attribute.");
1243
}
1244            }
1245        }
1246
1247        for (Iterator JavaDoc it2 = simpleTypeTable.keySet().iterator();
1248            it2.hasNext();
1249            ) {
1250            if (!registry.containsKey((QName JavaDoc) it2.next()))
1251                throw new SchemaException(
1252                    "'simpleType' definitions have cyclic " + "dependency.");
1253        }
1254
1255        for (int i = 0; i < elements.size(); i++) {
1256            SchemaType element = (SchemaType) elements.elementAt(i);
1257            String JavaDoc targetURI = element.getTargetURI();
1258            String JavaDoc targetNSPrefix = getNamespaceURIMapping(targetURI);
1259            if (targetNSPrefix.compareTo("") != 0)
1260                targetNSPrefix = targetNSPrefix + ".";
1261            String JavaDoc name = element.getName();
1262            if (name == null)
1263                name = "";
1264            QName JavaDoc qName = new QName JavaDoc(targetURI, name);
1265            switch (element.getElementType()) {
1266                case SchemaType.COMPLEXTYPE :
1267                    registry.put(
1268                        qName,
1269                        targetNSPrefix
1270                            + Conventions.schema2JavaName(
1271                                "complexType",
1272                                name,
1273                                true));
1274                    break;
1275                case SchemaType.GROUP :
1276                    registry.put(
1277                        qName,
1278                        targetNSPrefix
1279                            + Conventions.schema2JavaName("group", name, true));
1280                    break;
1281                case SchemaType.ATTRIBUTEGROUP :
1282                    registry.put(
1283                        qName,
1284                        targetNSPrefix
1285                            + Conventions.schema2JavaName(
1286                                "attributeGroup",
1287                                name,
1288                                true));
1289                    break;
1290            }
1291        }
1292
1293        for (int i = 0; i < elements.size(); i++) {
1294            SchemaType element = (SchemaType) elements.elementAt(i);
1295            String JavaDoc name = element.getName();
1296            String JavaDoc targetURI = element.getTargetURI();
1297            String JavaDoc targetNSPrefix = getNamespaceURIMapping(targetURI);
1298            if (targetNSPrefix.compareTo("") != 0)
1299                targetNSPrefix = targetNSPrefix + ".";
1300            if (name == null)
1301                name = "";
1302            QName JavaDoc qName = new QName JavaDoc(targetURI, name);
1303            switch (element.getElementType()) {
1304                case SchemaType.ELEMENT :
1305                    SchemaElement schemaElement = (SchemaElement) element;
1306                    QName JavaDoc type = schemaElement.getType();
1307                    SchemaType child = schemaElement.getChild();
1308                    if (type != null) {
1309                        String JavaDoc javaType = (String JavaDoc) registry.get(type);
1310                        if (javaType != null)
1311                            registry.put(qName, javaType);
1312                    } else if (child != null) {
1313                        if (child.getElementType() == SchemaType.SIMPLETYPE) {
1314                            QName JavaDoc base =
1315                                (QName JavaDoc) ((SchemaSimpleType) child).getBase();
1316                            String JavaDoc javaType = (String JavaDoc) registry.get(base);
1317                            if (javaType != null) {
1318                                if (((SchemaSimpleType) child).isList())
1319                                    javaType = javaType + "[]";
1320                                registry.put(qName, javaType);
1321                            }
1322                        } else if (
1323                            child.getElementType() == SchemaType.COMPLEXTYPE) {
1324                            registry.put(
1325                                qName,
1326                                targetNSPrefix
1327                                    + Conventions.schema2JavaName(
1328                                        "complexType",
1329                                        name,
1330                                        true));
1331                        }
1332                    }
1333                    break;
1334                case SchemaType.ATTRIBUTE :
1335                    SchemaAttribute schemaAttribute = (SchemaAttribute) element;
1336                    type = schemaAttribute.getType();
1337                    SchemaSimpleType simpleType = schemaAttribute.getChild();
1338                    if (type != null) {
1339                        String JavaDoc javaType = (String JavaDoc) registry.get(type);
1340                        if (javaType != null)
1341                            registry.put(qName, javaType);
1342                    } else if (simpleType != null) {
1343                        QName JavaDoc base = simpleType.getBase();
1344                        String JavaDoc javaType = (String JavaDoc) registry.get(base);
1345                        if (javaType != null) {
1346                            if (simpleType.isList())
1347                                javaType = javaType + "[]";
1348                            registry.put(qName, javaType);
1349                        }
1350                    }
1351                    break;
1352            }
1353        }
1354    }
1355}
Popular Tags