axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r417141 [2/2] - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/ adb-codegen/src/org/apache/axis2/schema/template/ adb-codegen/src/org/apache/axis2/schema/writer/ adb-codegen/test/org/apache/axis2/schema/po...
Date Mon, 26 Jun 2006 08:30:20 GMT
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=417141&r1=417140&r2=417141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Mon Jun 26 01:30:19 2006
@@ -1,5 +1,22 @@
 package org.apache.axis2.schema.writer;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
 import org.apache.axis2.schema.BeanWriterMetaInfoHolder;
 import org.apache.axis2.schema.CompilerOptions;
 import org.apache.axis2.schema.SchemaCompilationException;
@@ -9,32 +26,16 @@
 import org.apache.axis2.schema.util.PrimitiveTypeFinder;
 import org.apache.axis2.schema.util.SchemaPropertyLoader;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.PrettyPrinter;
 import org.apache.axis2.util.URLProcessor;
 import org.apache.axis2.util.XSLTTemplateProcessor;
 import org.apache.axis2.util.XSLTUtils;
-import org.apache.axis2.util.PrettyPrinter;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Templates;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamSource;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -59,26 +60,35 @@
     public static final String WRAPPED_DATABINDING_CLASS_NAME = "WrappedDatabinder";
 
     private String javaBeanTemplateName = null;
+
     private boolean templateLoaded = false;
+
     private Templates templateCache;
 
     private List namesList;
+
     private static int count = 0;
+
     private boolean wrapClasses = false;
-    private boolean writeClasses=false;
+
+    private boolean writeClasses = false;
 
     private String packageName = null;
+
     private File rootDir;
 
     private Document globalWrappedDocument;
 
     private Map modelMap = new HashMap();
+
     private static final String DEFAULT_PACKAGE = "adb";
 
     private Map baseTypeMap = new JavaTypeMap().getTypeMap();
 
     private Map ns2packageNameMap = new HashMap();
 
+    private boolean isHelperMode = false;
+
     /**
      * Default constructor
      */
@@ -86,15 +96,15 @@
     }
 
     /**
-     * This returns a map of Qnames vs DOMDocument models. One can use this method to
-     * obtain the raw DOMmodels used to write the classes.
-     * This has no meaning when the classes are supposed to be wrapped  so the
-     *
+     * This returns a map of Qnames vs DOMDocument models. One can use this
+     * method to obtain the raw DOMmodels used to write the classes. This has no
+     * meaning when the classes are supposed to be wrapped so the
+     * 
      * @see org.apache.axis2.schema.writer.BeanWriter#getModelMap()
      * @return Returns Map.
      * @throws SchemaCompilationException
      */
-    public Map getModelMap(){
+    public Map getModelMap() {
         return modelMap;
     }
 
@@ -103,37 +113,46 @@
             initWithFile(options.getOutputLocation());
             packageName = options.getPackageName();
             writeClasses = options.isWriteOutput();
-            if (!writeClasses){
+            if (!writeClasses) {
                 wrapClasses = false;
-            }else{
+            } else {
                 wrapClasses = options.isWrapClasses();
             }
 
-            //if the wrap mode is set then create a global document to keep the wrapped
-            //element models
+            // if the wrap mode is set then create a global document to keep the
+            // wrapped
+            // element models
             if (options.isWrapClasses()) {
                 globalWrappedDocument = XSLTUtils.getDocument();
-                Element rootElement = XSLTUtils.getElement(globalWrappedDocument, "beans");
+                Element rootElement = XSLTUtils.getElement(
+                        globalWrappedDocument, "beans");
                 globalWrappedDocument.appendChild(rootElement);
-                XSLTUtils.addAttribute(globalWrappedDocument, "name", WRAPPED_DATABINDING_CLASS_NAME,
rootElement);
+                XSLTUtils.addAttribute(globalWrappedDocument, "name",
+                        WRAPPED_DATABINDING_CLASS_NAME, rootElement);
                 String tempPackageName;
 
-                if (packageName !=null && packageName.endsWith(".")) {
-                    tempPackageName = this.packageName.substring(0, this.packageName.lastIndexOf("."));
-                }else{
+                if (packageName != null && packageName.endsWith(".")) {
+                    tempPackageName = this.packageName.substring(0,
+                            this.packageName.lastIndexOf("."));
+                } else {
                     tempPackageName = DEFAULT_PACKAGE;
                 }
 
-                XSLTUtils.addAttribute(globalWrappedDocument, "package", tempPackageName,
rootElement);
+                XSLTUtils.addAttribute(globalWrappedDocument, "package",
+                        tempPackageName, rootElement);
             }
 
-            //add the ns mappings
+            // add the ns mappings
             this.ns2packageNameMap = options.getNs2PackageMap();
 
+            this.isHelperMode = options.isHelperMode();
+
         } catch (IOException e) {
             throw new SchemaCompilationException(e);
         } catch (ParserConfigurationException e) {
-            throw new SchemaCompilationException(e); //todo need to put correct error messages
+            throw new SchemaCompilationException(e); // todo need to put
+                                                        // correct error
+                                                        // messages
         }
     }
 
@@ -144,7 +163,8 @@
      * @return Returns String.
      * @throws SchemaCompilationException
      */
-    public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf)
throws SchemaCompilationException {
+    public String write(XmlSchemaElement element, Map typeMap,
+            BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
 
         try {
             QName qName = element.getQName();
@@ -154,25 +174,29 @@
             throw new SchemaCompilationException(e);
         }
 
-
     }
 
     /**
      * @param complexType
      * @param typeMap
      * @param metainf
-     * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName()
or null if it wasn't called
+     * @param fullyQualifiedClassName
+     *            the name returned by makeFullyQualifiedClassName() or null if
+     *            it wasn't called
      * @throws org.apache.axis2.schema.SchemaCompilationException
-     *
-     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaComplexType, java.util.Map,
org.apache.axis2.schema.BeanWriterMetaInfoHolder)
+     * 
+     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaComplexType,
+     *      java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
      */
-    public String write(XmlSchemaComplexType complexType, Map typeMap, BeanWriterMetaInfoHolder
metainf, String fullyQualifiedClassName)
+    public String write(XmlSchemaComplexType complexType, Map typeMap,
+            BeanWriterMetaInfoHolder metainf, String fullyQualifiedClassName)
             throws SchemaCompilationException {
 
         try {
-            //determine the package for this type.
+            // determine the package for this type.
             QName qName = complexType.getQName();
-            return process(qName, metainf, typeMap, false, fullyQualifiedClassName);
+            return process(qName, metainf, typeMap, false,
+                    fullyQualifiedClassName);
 
         } catch (SchemaCompilationException e) {
             throw e;
@@ -180,7 +204,6 @@
             throw new SchemaCompilationException(e);
         }
 
-
     }
 
     /**
@@ -190,14 +213,16 @@
     public void writeBatch() throws SchemaCompilationException {
         try {
             if (wrapClasses) {
-                String tempPackage ;
-                if (packageName==null){
+                String tempPackage;
+                if (packageName == null) {
                     tempPackage = DEFAULT_PACKAGE;
-                }else{
+                } else {
                     tempPackage = packageName;
                 }
-                File out = createOutFile(tempPackage, WRAPPED_DATABINDING_CLASS_NAME);
-                //parse with the template and create the files
+                File out = createOutFile(tempPackage,
+                        WRAPPED_DATABINDING_CLASS_NAME);
+                // parse with the template and create the files
+
                 parse(globalWrappedDocument, out);
             }
         } catch (Exception e) {
@@ -211,10 +236,13 @@
      * @param metainf
      * @return Returns String.
      * @throws SchemaCompilationException
-     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map,
org.apache.axis2.schema.BeanWriterMetaInfoHolder)
+     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType,
+     *      java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
      */
-    public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder
metainf) throws SchemaCompilationException {
-        throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.notimplementedxception"));
+    public String write(XmlSchemaSimpleType simpleType, Map typeMap,
+            BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
+        throw new SchemaCompilationException(SchemaCompilerMessages
+                .getMessage("schema.notimplementedxception"));
     }
 
     /**
@@ -226,7 +254,8 @@
         if (rootDir == null) {
             this.rootDir = new File(".");
         } else if (!rootDir.isDirectory()) {
-            throw new IOException(SchemaCompilerMessages.getMessage("schema.rootnotfolderexception"));
+            throw new IOException(SchemaCompilerMessages
+                    .getMessage("schema.rootnotfolderexception"));
         } else {
             this.rootDir = rootDir;
         }
@@ -235,25 +264,27 @@
         javaBeanTemplateName = SchemaPropertyLoader.getBeanTemplate();
     }
 
-
-    /** Make the fully qualified class name for an element or named type
-     * @param qName the qualified Name for this element or type in the schema
-     * @return the appropriate fully qualified class name to use in generated code
+    /**
+     * Make the fully qualified class name for an element or named type
+     * 
+     * @param qName
+     *            the qualified Name for this element or type in the schema
+     * @return the appropriate fully qualified class name to use in generated
+     *         code
      */
     public String makeFullyQualifiedClassName(QName qName) {
 
         String namespaceURI = qName.getNamespaceURI();
         String basePackageName;
 
-        if (ns2packageNameMap.containsKey(namespaceURI)){
-            basePackageName = (String)ns2packageNameMap.get(namespaceURI);
-        }else{
+        if (ns2packageNameMap.containsKey(namespaceURI)) {
+            basePackageName = (String) ns2packageNameMap.get(namespaceURI);
+        } else {
             basePackageName = URLProcessor.makePackageName(namespaceURI);
         }
 
-        String packageName = this.packageName == null ?
-                basePackageName :
-                this.packageName + basePackageName;
+        String packageName = this.packageName == null ? basePackageName
+                : this.packageName + basePackageName;
 
         String originalName = qName.getLocalPart();
         String className = makeUniqueJavaClassName(this.namesList, originalName);
@@ -263,40 +294,50 @@
         String fullyqualifiedClassName;
 
         if (wrapClasses)
-            packagePrefix =  (this.packageName == null ? DEFAULT_PACKAGE+"." : this.packageName)
+ WRAPPED_DATABINDING_CLASS_NAME;
+            packagePrefix = (this.packageName == null ? DEFAULT_PACKAGE + "."
+                    : this.packageName)
+                    + WRAPPED_DATABINDING_CLASS_NAME;
         else if (writeClasses)
             packagePrefix = packageName;
-        if (packagePrefix!=null)
-            fullyqualifiedClassName = packagePrefix + (packagePrefix.endsWith(".")?"":".")
+ className;
+        if (packagePrefix != null)
+            fullyqualifiedClassName = packagePrefix
+                    + (packagePrefix.endsWith(".") ? "" : ".") + className;
         else
             fullyqualifiedClassName = className;
-        //return the fully qualified class name
+        // return the fully qualified class name
         return fullyqualifiedClassName;
     }
 
     /**
-     * A util method that holds common code
-     * for the complete schema that the generated XML complies to
-     * look under other/beanGenerationSchema.xsd
-     *
+     * A util method that holds common code for the complete schema that the
+     * generated XML complies to look under other/beanGenerationSchema.xsd
+     * 
      * @param qName
      * @param metainf
      * @param typeMap
      * @param isElement
-     * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName()
or null if it wasn't called
+     * @param fullyQualifiedClassName
+     *            the name returned by makeFullyQualifiedClassName() or null if
+     *            it wasn't called
      * @return Returns String.
      * @throws Exception
      */
-    private String process(QName qName, BeanWriterMetaInfoHolder metainf, Map typeMap, boolean
isElement, String fullyQualifiedClassName) throws Exception {
+    private String process(QName qName, BeanWriterMetaInfoHolder metainf,
+            Map typeMap, boolean isElement, String fullyQualifiedClassName)
+            throws Exception {
 
         if (fullyQualifiedClassName == null)
             fullyQualifiedClassName = makeFullyQualifiedClassName(qName);
-        String className = fullyQualifiedClassName.substring(1+fullyQualifiedClassName.lastIndexOf('.'));
+        String className = fullyQualifiedClassName
+                .substring(1 + fullyQualifiedClassName.lastIndexOf('.'));
         String basePackageName;
-        if (fullyQualifiedClassName.lastIndexOf('.')==-1){// no 'dots' so the package is
not there
-             basePackageName = "";
-        }else{
-            basePackageName = fullyQualifiedClassName.substring(0,fullyQualifiedClassName.lastIndexOf('.'));
+        if (fullyQualifiedClassName.lastIndexOf('.') == -1) {// no 'dots' so
+                                                                // the package
+                                                                // is not there
+            basePackageName = "";
+        } else {
+            basePackageName = fullyQualifiedClassName.substring(0,
+                    fullyQualifiedClassName.lastIndexOf('.'));
         }
 
         String originalName = qName.getLocalPart();
@@ -306,40 +347,57 @@
             loadTemplate();
         }
 
-        //if wrapped then do not write the classes now but add the models to a global document.
However in order to write the
-        //global class that is generated, one needs to call the writeBatch() method
+        // if wrapped then do not write the classes now but add the models to a
+        // global document. However in order to write the
+        // global class that is generated, one needs to call the writeBatch()
+        // method
         if (wrapClasses) {
             globalWrappedDocument.getDocumentElement().appendChild(
-                    getBeanElement(globalWrappedDocument, className, originalName, basePackageName,
qName, isElement, metainf, propertyNames, typeMap)
-            );
+                    getBeanElement(globalWrappedDocument, className,
+                            originalName, basePackageName, qName, isElement,
+                            metainf, propertyNames, typeMap));
 
         } else {
-            //create the model
+            // create the model
             Document model = XSLTUtils.getDocument();
-            //make the XML
-            model.appendChild(getBeanElement(model, className, originalName, basePackageName,
qName, isElement, metainf, propertyNames, typeMap));
+            // make the XML
+            model.appendChild(getBeanElement(model, className, originalName,
+                    basePackageName, qName, isElement, metainf, propertyNames,
+                    typeMap));
 
-            if (writeClasses){
-                //create the file
+            if (writeClasses) {
+                // create the file
                 File out = createOutFile(basePackageName, className);
-                //parse with the template and create the files
-                parse(model, out);
-            }
+                // parse with the template and create the files
+
+                if (isHelperMode) {
 
-            //add the model to the model map
-            modelMap.put(
-                    new QName(qName.getNamespaceURI(),className)
-                    ,model);
+                    XSLTUtils.addAttribute(model, "helperMode", "yes", model.getDocumentElement());
+                    
+                    // Generate bean classes
+                    parse(model, out);
+
+                    // Generating the helper classes
+                    out = createOutFile(basePackageName, className + "Helper");
+                    XSLTUtils.addAttribute(model, "helper", "yes", model
+                            .getDocumentElement());
+                    parse(model, out);
 
+                } else {
+                    parse(model, out);
+                }
+            }
+
+            // add the model to the model map
+            modelMap.put(new QName(qName.getNamespaceURI(), className), model);
 
         }
 
-        //return the fully qualified class name
+        // return the fully qualified class name
         return fullyQualifiedClassName;
 
     }
 
-
     /**
      * @param model
      * @param className
@@ -353,24 +411,26 @@
      * @return Returns Element.
      * @throws SchemaCompilationException
      */
-    private Element getBeanElement(
-            Document model, String className, String originalName,
-            String packageName, QName qName, boolean isElement,
-            BeanWriterMetaInfoHolder metainf, ArrayList propertyNames, Map typeMap
-    ) throws SchemaCompilationException {
+    private Element getBeanElement(Document model, String className,
+            String originalName, String packageName, QName qName,
+            boolean isElement, BeanWriterMetaInfoHolder metainf,
+            ArrayList propertyNames, Map typeMap)
+            throws SchemaCompilationException {
 
         Element rootElt = XSLTUtils.getElement(model, "bean");
         XSLTUtils.addAttribute(model, "name", className, rootElt);
         XSLTUtils.addAttribute(model, "originalName", originalName, rootElt);
         XSLTUtils.addAttribute(model, "package", packageName, rootElt);
-        XSLTUtils.addAttribute(model, "nsuri", qName.getNamespaceURI(), rootElt);
-        XSLTUtils.addAttribute(model, "nsprefix", getPrefixForURI(qName.getNamespaceURI(),
qName.getPrefix()), rootElt);
+        XSLTUtils
+                .addAttribute(model, "nsuri", qName.getNamespaceURI(), rootElt);
+        XSLTUtils.addAttribute(model, "nsprefix", getPrefixForURI(qName
+                .getNamespaceURI(), qName.getPrefix()), rootElt);
 
         if (!wrapClasses) {
             XSLTUtils.addAttribute(model, "unwrapped", "yes", rootElt);
         }
 
-        if (!writeClasses){
+        if (!writeClasses) {
             XSLTUtils.addAttribute(model, "skip-write", "yes", rootElt);
         }
 
@@ -383,10 +443,10 @@
         }
 
         if (metainf.isExtension()) {
-            XSLTUtils.addAttribute(model, "extension", metainf.getExtensionClassName(), rootElt);
+            XSLTUtils.addAttribute(model, "extension", metainf
+                    .getExtensionClassName(), rootElt);
         }
 
-
         if (metainf.isChoice()) {
             XSLTUtils.addAttribute(model, "choice", "yes", rootElt);
         }
@@ -399,15 +459,14 @@
             XSLTUtils.addAttribute(model, "nillable", "yes", rootElt);
         }
 
-        //populate all the information
-        populateInfo(metainf, model, rootElt, propertyNames, typeMap,false);
-
+        // populate all the information
+        populateInfo(metainf, model, rootElt, propertyNames, typeMap, false);
 
         return rootElt;
     }
 
     /**
-     *
+     * 
      * @param metainf
      * @param model
      * @param rootElt
@@ -415,20 +474,20 @@
      * @param typeMap
      * @throws SchemaCompilationException
      */
-    private void populateInfo(BeanWriterMetaInfoHolder metainf,
-                              Document model,
-                              Element rootElt,
-                              ArrayList propertyNames,
-                              Map typeMap,boolean isInherited)throws SchemaCompilationException{
-        if (metainf.getParent()!=null){
-            populateInfo(metainf.getParent(),model,rootElt,propertyNames,typeMap,true);
+    private void populateInfo(BeanWriterMetaInfoHolder metainf, Document model,
+            Element rootElt, ArrayList propertyNames, Map typeMap,
+            boolean isInherited) throws SchemaCompilationException {
+        if (metainf.getParent() != null) {
+            populateInfo(metainf.getParent(), model, rootElt, propertyNames,
+                    typeMap, true);
         }
-        addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap,isInherited);
+        addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap,
+                isInherited);
 
     }
 
     /**
-     *
+     * 
      * @param metainf
      * @param model
      * @param rootElt
@@ -436,9 +495,9 @@
      * @param typeMap
      * @throws SchemaCompilationException
      */
-    private void addPropertyEntries(BeanWriterMetaInfoHolder metainf, Document model, Element
rootElt, ArrayList propertyNames,
-                                    Map typeMap,
-                                    boolean isInherited) throws SchemaCompilationException
{
+    private void addPropertyEntries(BeanWriterMetaInfoHolder metainf,
+            Document model, Element rootElt, ArrayList propertyNames,
+            Map typeMap, boolean isInherited) throws SchemaCompilationException {
         // go in the loop and add the part elements
         QName[] qNames;
         if (metainf.isOrdered()) {
@@ -449,28 +508,31 @@
 
         QName name;
         for (int i = 0; i < qNames.length; i++) {
-            Element property = XSLTUtils.addChildElement(model, "property", rootElt);
+            Element property = XSLTUtils.addChildElement(model, "property",
+                    rootElt);
             name = qNames[i];
             String xmlName = name.getLocalPart();
             XSLTUtils.addAttribute(model, "name", xmlName, property);
-            XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property);
+            XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(),
+                    property);
             String javaName = makeUniqueJavaClassName(propertyNames, xmlName);
             XSLTUtils.addAttribute(model, "javaname", javaName, property);
 
             String javaClassNameForElement = metainf.getClassNameForQName(name);
 
-
             if (javaClassNameForElement == null) {
-                throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.typeMissing"));
+                throw new SchemaCompilationException(SchemaCompilerMessages
+                        .getMessage("schema.typeMissing"));
             }
 
-            XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);
+            XSLTUtils.addAttribute(model, "type", javaClassNameForElement,
+                    property);
 
-            if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)){
+            if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {
                 XSLTUtils.addAttribute(model, "primitive", "yes", property);
             }
-            //add an attribute that says the type is default
-            if (isDefault(javaClassNameForElement)){
+            // add an attribute that says the type is default
+            if (isDefault(javaClassNameForElement)) {
                 XSLTUtils.addAttribute(model, "default", "yes", property);
             }
 
@@ -482,24 +544,27 @@
                 XSLTUtils.addAttribute(model, "attribute", "yes", property);
             }
 
-            if (metainf.isNillable(name)){
+            if (metainf.isNillable(name)) {
                 XSLTUtils.addAttribute(model, "nillable", "yes", property);
             }
 
             String shortTypeName;
             if (metainf.getSchemaQNameForQName(name) != null) {
-                //see whether the QName is a basetype
-                if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))){
-                    shortTypeName= metainf.getSchemaQNameForQName(name).getLocalPart();
-                }else{
-                    shortTypeName =  getShortTypeName(javaClassNameForElement);
+                // see whether the QName is a basetype
+                if (baseTypeMap.containsKey(metainf
+                        .getSchemaQNameForQName(name))) {
+                    shortTypeName = metainf.getSchemaQNameForQName(name)
+                            .getLocalPart();
+                } else {
+                    shortTypeName = getShortTypeName(javaClassNameForElement);
                 }
-            }else{
-                shortTypeName =  getShortTypeName(javaClassNameForElement);
+            } else {
+                shortTypeName = getShortTypeName(javaClassNameForElement);
             }
-            XSLTUtils.addAttribute(model, "shorttypename", shortTypeName, property);
+            XSLTUtils.addAttribute(model, "shorttypename", shortTypeName,
+                    property);
 
-            if (isInherited){
+            if (isInherited) {
                 XSLTUtils.addAttribute(model, "inherited", "yes", property);
             }
 
@@ -510,25 +575,27 @@
             if (metainf.getBinaryStatusForQName(name)) {
                 XSLTUtils.addAttribute(model, "binary", "yes", property);
             }
-            //put the min occurs count irrespective of whether it's an array or not
+            // put the min occurs count irrespective of whether it's an array or
+            // not
             long minOccurs = metainf.getMinOccurs(name);
-            XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property);
-
+            XSLTUtils
+                    .addAttribute(model, "minOccurs", minOccurs + "", property);
 
             if (metainf.getArrayStatusForQName(name)) {
 
                 XSLTUtils.addAttribute(model, "array", "yes", property);
-                XSLTUtils.addAttribute(
-                        model,
-                        "arrayBaseType",
-                        javaClassNameForElement.substring(0, javaClassNameForElement.indexOf("[")),
-                        property);
+                XSLTUtils
+                        .addAttribute(model, "arrayBaseType",
+                                javaClassNameForElement.substring(0,
+                                        javaClassNameForElement.indexOf("[")),
+                                property);
 
                 long maxOccurs = metainf.getMaxOccurs(name);
                 if (maxOccurs == Long.MAX_VALUE) {
                     XSLTUtils.addAttribute(model, "unbound", "yes", property);
                 } else {
-                    XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "", property);
+                    XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "",
+                            property);
                 }
             }
         }
@@ -536,19 +603,22 @@
 
     /**
      * Test whether the given class name matches the default
+     * 
      * @param javaClassNameForElement
      * @return
      */
     private boolean isDefault(String javaClassNameForElement) {
-        return SchemaCompiler.DEFAULT_CLASS_NAME.equals(javaClassNameForElement)||
-                SchemaCompiler.DEFAULT_CLASS_ARRAY_NAME.equals(javaClassNameForElement);
+        return SchemaCompiler.DEFAULT_CLASS_NAME
+                .equals(javaClassNameForElement)
+                || SchemaCompiler.DEFAULT_CLASS_ARRAY_NAME
+                        .equals(javaClassNameForElement);
     }
 
-
     /**
-     * Given the xml name, make a unique class name taking into account that some
-     * file systems are case sensitive and some are not.
-     * -Consider the Jax-WS spec for this
+     * Given the xml name, make a unique class name taking into account that
+     * some file systems are case sensitive and some are not. -Consider the
+     * Jax-WS spec for this
+     * 
      * @param listOfNames
      * @param xmlName
      * @return Returns String.
@@ -558,7 +628,8 @@
         if (JavaUtils.isJavaKeyword(xmlName)) {
             javaName = JavaUtils.makeNonJavaKeyword(xmlName);
         } else {
-            javaName = JavaUtils.capitalizeFirstChar(JavaUtils.xmlNameToJava(xmlName));
+            javaName = JavaUtils.capitalizeFirstChar(JavaUtils
+                    .xmlNameToJava(xmlName));
         }
 
         while (listOfNames.contains(javaName.toLowerCase())) {
@@ -569,58 +640,58 @@
         return javaName;
     }
 
-
     /**
-     * A bit of code from the old code generator. We are better off using the template
-     * engines and such stuff that's already there. But the class writers are hard to be
-     * reused so some code needs to be repeated (atleast a bit)
+     * A bit of code from the old code generator. We are better off using the
+     * template engines and such stuff that's already there. But the class
+     * writers are hard to be reused so some code needs to be repeated (atleast
+     * a bit)
      */
     private void loadTemplate() throws SchemaCompilationException {
 
-        //first get the language specific property map
+        // first get the language specific property map
         Class clazz = this.getClass();
         InputStream xslStream;
         String templateName = javaBeanTemplateName;
         if (templateName != null) {
             try {
                 xslStream = clazz.getResourceAsStream(templateName);
-                templateCache = TransformerFactory.newInstance().newTemplates(new StreamSource(xslStream));
+                templateCache = TransformerFactory.newInstance().newTemplates(
+                        new StreamSource(xslStream));
                 templateLoaded = true;
             } catch (TransformerConfigurationException e) {
-                throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.templateLoadException"),
e);
+                throw new SchemaCompilationException(SchemaCompilerMessages
+                        .getMessage("schema.templateLoadException"), e);
             }
         } else {
-            throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.templateNotFoundException"));
+            throw new SchemaCompilationException(SchemaCompilerMessages
+                    .getMessage("schema.templateNotFoundException"));
         }
     }
 
-
     /**
      * Creates the output file
-     *
+     * 
      * @param packageName
      * @param fileName
      * @throws Exception
      */
-    private File createOutFile(String packageName, String fileName) throws Exception {
+    private File createOutFile(String packageName, String fileName)
+            throws Exception {
         return org.apache.axis2.util.FileWriter.createClassFile(this.rootDir,
-                packageName,
-                fileName,
-                ".java");
+                packageName, fileName, ".java");
     }
 
     /**
      * Writes the output file
-     *
+     * 
      * @param doc
      * @param outputFile
      * @throws Exception
      */
     private void parse(Document doc, File outputFile) throws Exception {
         OutputStream outStream = new FileOutputStream(outputFile);
-        XSLTTemplateProcessor.parse(outStream,
-                doc,
-                this.templateCache.newTransformer());
+        XSLTTemplateProcessor.parse(outStream, doc, this.templateCache
+                .newTransformer());
         outStream.flush();
         outStream.close();
 
@@ -628,13 +699,13 @@
     }
 
     /**
-     * Get a prefix for a namespace URI.  This method will ALWAYS
-     * return a valid prefix - if the given URI is already mapped in this
-     * serialization, we return the previous prefix.  If it is not mapped,
-     * we will add a new mapping and return a generated prefix of the form
-     * "ns<num>".
-     *
-     * @param uri is the namespace uri
+     * Get a prefix for a namespace URI. This method will ALWAYS return a valid
+     * prefix - if the given URI is already mapped in this serialization, we
+     * return the previous prefix. If it is not mapped, we will add a new
+     * mapping and return a generated prefix of the form "ns<num>".
+     * 
+     * @param uri
+     *            is the namespace uri
      * @return Returns prefix.
      */
     public String getPrefixForURI(String uri) {
@@ -650,13 +721,14 @@
      * Map of namespaces URI to prefix(es)
      */
     HashMap mapURItoPrefix = new HashMap();
+
     HashMap mapPrefixtoURI = new HashMap();
 
     /**
-     * Get a prefix for the given namespace URI.  If one has already been
-     * defined in this serialization, use that.  Otherwise, map the passed
-     * default prefix to the URI, and return that.  If a null default prefix
-     * is passed, use one of the form "ns<num>"
+     * Get a prefix for the given namespace URI. If one has already been defined
+     * in this serialization, use that. Otherwise, map the passed default prefix
+     * to the URI, and return that. If a null default prefix is passed, use one
+     * of the form "ns<num>"
      */
     public String getPrefixForURI(String uri, String defaultPrefix) {
         if ((uri == null) || (uri.length() == 0))
@@ -677,12 +749,14 @@
         return prefix;
     }
 
-    private String getShortTypeName(String typeClassName){
-        if (typeClassName.endsWith("[]")){
-            typeClassName = typeClassName.substring(0,typeClassName.lastIndexOf("["));
+    private String getShortTypeName(String typeClassName) {
+        if (typeClassName.endsWith("[]")) {
+            typeClassName = typeClassName.substring(0, typeClassName
+                    .lastIndexOf("["));
         }
 
-        return typeClassName.substring(typeClassName.lastIndexOf(".")+1, typeClassName.length());
+        return typeClassName.substring(typeClassName.lastIndexOf(".") + 1,
+                typeClassName.length());
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/derived/AbstractDerivedPopulater.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/derived/AbstractDerivedPopulater.java?rev=417141&r1=417140&r2=417141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/derived/AbstractDerivedPopulater.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/derived/AbstractDerivedPopulater.java
Mon Jun 26 01:30:19 2006
@@ -1,16 +1,16 @@
 package org.apache.axis2.schema.populate.derived;
 
-import junit.framework.TestCase;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.io.ByteArrayInputStream;
 import java.lang.reflect.Method;
 
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.util.StAXUtils;
+import org.custommonkey.xmlunit.XMLTestCase;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -27,7 +27,7 @@
  * limitations under the License.
  */
 
-public abstract class AbstractDerivedPopulater extends TestCase {
+public abstract class AbstractDerivedPopulater extends XMLTestCase {
 
     // force others to implement this method
     public abstract void testPopulate() throws Exception;
@@ -54,18 +54,38 @@
     protected void checkValue(String xmlToSet, String value) throws Exception {
         Object o = process(xmlToSet, className);
         Class beanClass = Class.forName(className);
+        
         BeanInfo info = Introspector.getBeanInfo(beanClass);
         PropertyDescriptor[] propDescs = info.getPropertyDescriptors();
         for (int i = 0; i < propDescs.length; i++) {
             PropertyDescriptor propDesc = propDescs[i];
+            
             if  (propDesc.getPropertyType().equals(propertyClass)){
                 String s = convertToString(propDesc.getReadMethod().invoke(o,
                         (Object[]) null));
                 compare(value,s);
             }
-
         }
-
+        
+//        OMElement element = getOMElement(o);
+//        
+//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
+//        element.serialize(writer);
+//        writer.flush();
+//        
+//        assertXMLEqual(baos.toString(),xmlToSet);
+  }
+    
+    protected OMElement getOMElement(Object bean) throws Exception {
+//        Method method = bean.getClass().getMethod("getOMElement", new Class[]{
+//                Class.forName("javax.xml.namespace.QName"), 
+//                Class.forName("org.apache.axiom.om.OMFactory")});
+//        
+//        OMElement result = (OMElement) method.invoke(bean, new Object[]{null, OMAbstractFactory.getOMFactory()});
+//        return result;
+        throw new UnsupportedOperationException();
+        
     }
 
     protected void compare(String val1,String val2){

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=417141&r1=417140&r2=417141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
Mon Jun 26 01:30:19 2006
@@ -1,5 +1,21 @@
 package org.apache.axis2.wsdl.codegen.emitter;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.URIResolver;
+
 import org.apache.axis2.description.AxisMessage;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
@@ -41,27 +57,6 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -1392,17 +1387,21 @@
     protected void debugLogDocument(String description, Document doc) {
         if (log.isDebugEnabled()) {
             try {
-                DOMSource source = new DOMSource(doc);
-                StringWriter swrite = new StringWriter();
-                swrite.write(description);
-                swrite.write("\n");
-                Transformer transformer =
-                        TransformerFactory.newInstance().newTransformer();
-                transformer.setOutputProperty("omit-xml-declaration", "yes");
-                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-                transformer.transform(source, new StreamResult(swrite));
-                log.debug(swrite.toString());
+//                System.err.println(DOM2Writer.nodeToString(doc.getDocumentElement()));
+//                DOMSource source = new DOMSource(doc);
+//                StringWriter swrite = new StringWriter();
+//                swrite.write(description);
+//                swrite.write("\n");
+//                Transformer transformer =
+//                        TransformerFactory.newInstance().newTransformer();
+//                transformer.setOutputProperty("omit-xml-declaration", "yes");
+//                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+//                transformer.transform(source, new StreamResult(swrite));
+//                
+//                log.debug(swrite.toString());
+                
             } catch (Exception e) {
+                
                 e.printStackTrace();
             }
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescription.java?rev=417141&r1=417140&r2=417141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescription.java
Mon Jun 26 01:30:19 2006
@@ -207,7 +207,7 @@
                 engageModule(module, configuration);
             } else {
                 // TODO needs to implement this method
-//                module.applyPolicy(effPolicy);
+//                module.applyPolicy(effPolicy, this);
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message