Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 92636 invoked from network); 1 Nov 2005 06:25:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Nov 2005 06:25:52 -0000 Received: (qmail 66491 invoked by uid 500); 1 Nov 2005 06:25:51 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 66462 invoked by uid 500); 1 Nov 2005 06:25:50 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 66451 invoked by uid 500); 1 Nov 2005 06:25:50 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 66448 invoked by uid 99); 1 Nov 2005 06:25:50 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 31 Oct 2005 22:25:49 -0800 Received: (qmail 92563 invoked by uid 65534); 1 Nov 2005 06:25:29 -0000 Message-ID: <20051101062529.92562.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r329991 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema: ./ typemap/ util/ writer/ Date: Tue, 01 Nov 2005 06:25:27 -0000 To: axis2-cvs@ws.apache.org From: ajith@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ajith Date: Mon Oct 31 22:25:05 2005 New Revision: 329991 URL: http://svn.apache.org/viewcvs?rev=329991&view=rev Log: Added comments in certain wanted places as the first step towrds building documentation for ADB Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/TypeMap.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/ConverterUtil.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/SchemaPropertyLoader.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java Mon Oct 31 22:25:05 2005 @@ -22,7 +22,8 @@ /** * This is a class used as a holder to pass on the meta information to the bean writer * This meta information will be used by the writer to write the databinding conversion code - * Note - Metainfholders are not meant to be reused!!!. They are per-class basis + * Note - Metainfholders are not meant to be reused!!!. They are per-class basis and are strictly + * not thread safe!!!! */ public class BeanWriterMetaInfoHolder { @@ -39,42 +40,91 @@ private Map qNameMinOccursCountMap = new HashMap(); private Map qNameOrderMap = new HashMap(); + /** + * get the anon status + * @return + */ public boolean isAnonymous() { return anonymous; } + /** + * Set the anonymous flag + * @param anonymous + */ public void setAnonymous(boolean anonymous) { this.anonymous = anonymous; } + /** + * set the extensions base class name. Valid only when the isExtension + * retruns true + * @param extensionClassName + * @return + */ public String getExtensionClassName() { return extensionClassName; } + /** + * set the extensions base class name. Valid only when the isExtension + * retruns true + * @param extensionClassName + */ public void setExtensionClassName(String extensionClassName) { this.extensionClassName = extensionClassName; } + /** + * get the extension status + * @return + */ public boolean isExtension() { return extension; } + /** + * set the extension status + * @param extension + */ public void setExtension(boolean extension) { this.extension = extension; } + /** + * ge the ordered statu + * @return + */ public boolean isOrdered() { return ordered; } + /** + * set the ordered flag. this marks whether the + * items are ordered or not + * @param ordered + */ public void setOrdered(boolean ordered) { this.ordered = ordered; } + /** + * Register a mapping + * @param qName + * @param schemaName + * @param javaClassName + */ public void registerMapping(QName qName,QName schemaName,String javaClassName){ registerMapping(qName,schemaName,javaClassName,SchemaConstants.ELEMENT_TYPE); } + /** + * Register a mapping + * @param qName + * @param schemaName + * @param javaClassName + * @param type + */ public void registerMapping(QName qName,QName schemaName,String javaClassName,Integer type){ this.elementToJavaClassMap.put(qName,javaClassName); this.elementToSchemaQNameMap.put(qName,schemaName); @@ -82,44 +132,79 @@ } + /** + * Get the schema name for the given QName + * @param eltQName + * @return + */ public QName getSchemaQNameForQName(QName eltQName){ return (QName)this.elementToSchemaQNameMap.get(eltQName); } - public String getJavaClassNameForQName(QName eltQName){ + /** + * get the class name for the QName + * @param eltQName + * @return + */ + public String getClassNameForQName(QName eltQName){ return (String)this.elementToJavaClassMap.get(eltQName); } + /** + * Get whether a given QName is an attribute + * @param qName + * @return + */ public boolean getAttributeStatusForQName(QName qName){ Integer attribState = (Integer) specialTypeFlagMap.get(qName); return attribState != null && attribState.equals(SchemaConstants.ATTRIBUTE_TYPE); } + /** + * Get whether a given QName represents a anyType + * @param qName + * @return + */ public boolean getAnyStatusForQName(QName qName){ Integer anyState = (Integer) specialTypeFlagMap.get(qName); return anyState != null && anyState.equals(SchemaConstants.ANY_TYPE); } + /** + * Get whether a given QName refers to an array + * @param qName + * @return + */ public boolean getArrayStatusForQName(QName qName){ Integer anyState = (Integer) specialTypeFlagMap.get(qName); return anyState != null && anyState.equals(SchemaConstants.ANY_ARRAY_TYPE); } - public boolean getAnyAttributeStatusForQName(QName qName){ + /** + * Get whether a given QName has the any attribute status + * @param qName + * @return + */ + public boolean getAnyAttributeStatusForQName(QName qName){ Integer anyState = (Integer) specialTypeFlagMap.get(qName); return anyState != null && anyState.equals(SchemaConstants.ANY_ATTRIBUTE_TYPE); } /** - * + * Clears the whole set of tables. */ public void clearTables(){ this.elementToJavaClassMap.clear(); this.elementToSchemaQNameMap.clear(); - + this.elementToSchemaQNameMap.clear(); + this.elementToJavaClassMap.clear(); + this.specialTypeFlagMap.clear(); + this.qNameMaxOccursCountMap.clear(); + this.qNameMinOccursCountMap.clear(); + this.qNameOrderMap.clear(); } /** - * + * add the maxOccurs associated with a QName * @param qName * @param minOccurs */ @@ -128,16 +213,16 @@ } /** - * - * @param qName - * @param index - */ - public void registerQNameIndex(QName qName, int index){ - this.qNameOrderMap.put(new Integer(index),qName); - } + * register a QName for the order + * @param qName + * @param index + */ + public void registerQNameIndex(QName qName, int index){ + this.qNameOrderMap.put(new Integer(index),qName); + } /** - * + * Add the minOccurs associated with a QName * @param qName * @return */ @@ -147,7 +232,7 @@ } /** - * + * get the maxOccurs associated with a QName * @param qName * @return */ @@ -157,7 +242,7 @@ } /** - * + * Add the maxOccurs associated with a QName * @param qName * @param maxOccurs */ @@ -166,7 +251,7 @@ } /** - * + * @deprecated Use #getQNameArray * @return */ public Iterator getElementQNameIterator(){ @@ -174,17 +259,21 @@ } /** - * - * @return - */ - public QName[] getQNameArray(){ - Set keySet =elementToJavaClassMap.keySet(); - return (QName[])keySet.toArray(new QName[keySet.size()]); - } - + * get the QName array - may not be ordered + * @return + */ + public QName[] getQNameArray(){ + Set keySet =elementToJavaClassMap.keySet(); + return (QName[])keySet.toArray(new QName[keySet.size()]); + } + /** + * Get the ordered QName array - useful in sequences where the order needs to be preserved + * Note - #registerQNameIndex needs to be called if this is to work properly! + * @return + */ public QName[] getOrderedQNameArray(){ - //get the keys of the order map + //get the keys of the order map Set set = qNameOrderMap.keySet(); int count = set.size(); Integer[] keys =(Integer[]) set.toArray(new Integer[count]); @@ -196,7 +285,7 @@ returnQNames[i] = (QName)qNameOrderMap.get(keys[i]); } - return returnQNames; + return returnQNames; } } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java Mon Oct 31 22:25:05 2005 @@ -18,10 +18,16 @@ */ /** - * This is a bean class that captures all the compiler ptions/parameterss + * This is a bean class that captures all the compiler options. + * Right now the compiler options consist of the following + * 1. output file location - A folder with necessary rights for the + * schema compiler to write the files */ public class CompilerOptions { + /** + * Generated output file + */ File outputLocation; public File getOutputLocation() { Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java Mon Oct 31 22:25:05 2005 @@ -15,6 +15,10 @@ * limitations under the License. */ +/** + * A simeple extension from the java.lang.exception to serve as the schema compilers + * Exception + */ public class SchemaCompilationException extends Exception{ public SchemaCompilationException() { Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java Mon Oct 31 22:25:05 2005 @@ -2,8 +2,6 @@ import org.apache.ws.commons.schema.*; import org.apache.axis2.om.OMElement; -import org.apache.axis2.databinding.schema.typemap.JavaTypeMap; -import org.apache.axis2.databinding.schema.writer.JavaBeanWriter; import org.apache.axis2.databinding.schema.writer.BeanWriter; import org.apache.axis2.databinding.schema.util.SchemaPropertyLoader; @@ -26,13 +24,16 @@ * limitations under the License. */ +/** + * Schema compiler for ADB. Based on WS-Commons schema object model. + */ public class SchemaCompiler { private CompilerOptions options; private HashMap processedTypemap; + //The processedElementMap and the processedElementList have a subtle difference //The writing to the processedElementList happens when an outer element is processed. - // private HashMap processedElementMap; private HashMap processedAnonymousComplexTypesMap; private ArrayList processedElementList; @@ -51,7 +52,7 @@ } /** - * + * Constructor - Accepts a options bean * @param options */ public SchemaCompiler(CompilerOptions options) throws SchemaCompilationException { @@ -131,7 +132,7 @@ } /** - * Writes the element + * Writes the element * @param xsElt * @throws SchemaCompilationException */ @@ -168,9 +169,10 @@ /** - * + * Process the element * @param xsElt - * @param isOuter + * @param isOuter - We need to know this since the treatment of outer elements is different that + * inner elements * @throws SchemaCompilationException */ private void processElement(XmlSchemaElement xsElt,boolean isOuter) throws SchemaCompilationException{ @@ -178,10 +180,11 @@ } /** - * + * Process and Element * @param xsElt - * @param isOuter - * @param isArray + * @param isOuter-We need to know this since the treatment of outer elements is different that + * inner elements + * @param isArray-flag saying whether the elements represents an array * @throws SchemaCompilationException */ private void processElement(XmlSchemaElement xsElt,boolean isOuter,boolean isArray) throws SchemaCompilationException{ @@ -212,7 +215,7 @@ } /** - * + * Finds a class name from the given Qname * @param schemaType * @return */ @@ -341,6 +344,10 @@ } + /** + * Handle any attribute + * @param metainf + */ private void processAnyAttribute(BeanWriterMetaInfoHolder metainf) { //The best thing we can do here is to add a set of OMAttributes metainf.registerMapping(new QName(EXTRA_ATTRIBUTE_FIELD_NAME), @@ -350,6 +357,11 @@ } + /** + * Process the attribute + * @param att + * @param metainf + */ public void processAttribute(XmlSchemaAttribute att,BeanWriterMetaInfoHolder metainf){ //for now we assume (!!!) that attributes refer to standard types only QName schemaTypeName = att.getSchemaTypeName(); @@ -364,7 +376,7 @@ } /** - * + * Process a particle- A particle may be a sequence,all or a choice * @param particle * @param metainfHolder * @throws SchemaCompilationException @@ -379,7 +391,7 @@ XmlSchemaObjectCollection items = ((XmlSchemaAll)particle).getItems(); process(items, metainfHolder,false); }else if (particle instanceof XmlSchemaChoice){ - //handle the choice! + //put the code here to handle the choice! } } @@ -460,7 +472,9 @@ } /** - * + * process the 'any' + * @param any + * @param metainf */ private void processAny(XmlSchemaAny any,BeanWriterMetaInfoHolder metainf) { //handle the minoccurs/maxoccurs here. @@ -483,6 +497,16 @@ } + /** + * Find whether a given particle is an array. The logic for deciding + * whether a given particle is an array is depending on their minOccurs + * and maxOccurs counts. If Maxoccurs is greater than one (1) then the + * content is an array. + * Also no higher level element will have the maxOccurs greater than one + * @param particle + * @return + * @throws SchemaCompilationException + */ private boolean isArray(XmlSchemaParticle particle) throws SchemaCompilationException{ long minOccurs = particle.getMinOccurs(); long maxOccurs = particle.getMaxOccurs(); Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java Mon Oct 31 22:25:05 2005 @@ -16,7 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * Constants for the QNames of standard schema types + */ public class SchemaConstants { + + + public static final String URI_DEFAULT_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD, "string"); public static final QName XSD_BOOLEAN = new QName(URI_DEFAULT_SCHEMA_XSD, "boolean"); Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java Mon Oct 31 22:25:05 2005 @@ -27,11 +27,21 @@ */ public class XSD2Java { - //for now the arguments this main method accepts is the source schema and the output - //location + + /** + * for now the arguments this main method accepts is the source schema and the output + * location + * @param args + */ public static void main(String[] args) { - //todo do some validation here - compile(args[0],args[1]); + if (args.length!=2){ + // printout the options + System.out.println("Argument1 - Source schema file name"); + System.out.println("Argument2 - Output folder name"); + } else{ + compile(args[0],args[1]); + } + } /** @@ -56,7 +66,7 @@ File outputFolder = new File(outputLocation); if (outputFolder.exists()){ if (outputFolder.isFile()) { - throw new IOException("specified location is a folder!"); + throw new IOException("specified location is not a folder!"); } }else{ outputFolder.mkdirs(); @@ -66,14 +76,8 @@ outputFolder)); compiler.compile(currentSchema); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (SchemaCompilationException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException("Compiler caused an exception",e); } } } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java Mon Oct 31 22:25:05 2005 @@ -22,6 +22,9 @@ * limitations under the License. */ +/** + * The java type map. uses a static map for caching + */ public class JavaTypeMap implements TypeMap { public Map getTypeMap() { Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/TypeMap.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/TypeMap.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/TypeMap.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/TypeMap.java Mon Oct 31 22:25:05 2005 @@ -19,6 +19,7 @@ /** * This is a typemapper for the bean writer + * */ public interface TypeMap { Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/ConverterUtil.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/ConverterUtil.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/ConverterUtil.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/ConverterUtil.java Mon Oct 31 22:25:05 2005 @@ -18,6 +18,13 @@ * limitations under the License. */ +/** + * Converter methods to go from + * 1. simple type -> String + * 2. simple type -> Object + * 3. String -> simpletype + * 4. Object list -> array + */ public class ConverterUtil { /* String conversion methods */ Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/SchemaPropertyLoader.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/SchemaPropertyLoader.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/SchemaPropertyLoader.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/util/SchemaPropertyLoader.java Mon Oct 31 22:25:05 2005 @@ -20,6 +20,9 @@ * limitations under the License. */ +/** + * Loads the properties for the schema compiler + */ public class SchemaPropertyLoader { private static String beanTemplate = null; private static BeanWriter beanWriterInstance = null; Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java Mon Oct 31 22:25:05 2005 @@ -25,11 +25,15 @@ * limitations under the License. */ +/** + * The bean writer interface. The schema compiler expects one of these to be + * presented to it and calls the appropriate methods + */ public interface BeanWriter { /** * Initialize this writer - * @param rootDir + * @param rootDir - The directory to be written into * @throws IOException */ public void init(File rootDir) throws IOException ; Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java?rev=329991&r1=329990&r2=329991&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java Mon Oct 31 22:25:05 2005 @@ -37,6 +37,9 @@ * limitations under the License. */ +/** + * Java Bean writer for the schema compiler. + */ public class JavaBeanWriter implements BeanWriter{ private String javaBeanTemplateName = null; @@ -56,8 +59,13 @@ public JavaBeanWriter(){ } + /** + * @see BeanWriter#init(java.io.File) + * @param rootDir + * @throws IOException + */ public void init(File rootDir) throws IOException{ - if (rootDir ==null){ + if (rootDir ==null){ this.rootDir = new File("."); }else if (!rootDir.isDirectory()){ throw new IOException("Root location needs to be a directory!"); @@ -69,7 +77,7 @@ javaBeanTemplateName = SchemaPropertyLoader.getBeanTemplate(); } /** - * + * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaComplexType, java.util.Map, org.apache.axis2.databinding.schema.BeanWriterMetaInfoHolder) * @param complexType * @param typeMap * @param metainf @@ -91,6 +99,17 @@ } + /** + * 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 + * @return + * @throws Exception + */ private String process(QName qName, BeanWriterMetaInfoHolder metainf, Map typeMap, boolean isElement) throws Exception { String packageName = URLProcessor.getNameSpaceFromURL(qName.getNamespaceURI()); String originalName = qName.getLocalPart(); @@ -117,7 +136,7 @@ } if (metainf.isAnonymous()){ - XSLTUtils.addAttribute(model,"anon","yes",rootElt); + XSLTUtils.addAttribute(model,"anon","yes",rootElt); } if (metainf.isExtension()){ @@ -148,7 +167,7 @@ javaName = getNonConflictingName(propertyNames,javaName); XSLTUtils.addAttribute(model,"name",xmlName,property); XSLTUtils.addAttribute(model,"javaname",javaName,property); - String javaClassNameForElement = metainf.getJavaClassNameForQName(name); + String javaClassNameForElement = metainf.getClassNameForQName(name); String shortTypeName = ""; if (metainf.getSchemaQNameForQName(name)!=null){ shortTypeName = metainf.getSchemaQNameForQName(name).getLocalPart(); @@ -173,7 +192,7 @@ } if (metainf.getAnyAttributeStatusForQName(name)){ - XSLTUtils.addAttribute(model,"anyAtt","yes",property); + XSLTUtils.addAttribute(model,"anyAtt","yes",property); } if (metainf.getArrayStatusForQName(name)){ XSLTUtils.addAttribute(model,"array","yes",property); @@ -187,12 +206,12 @@ long minOccurs = metainf.getMinOccurs(name); if (minOccurs >0){ - XSLTUtils.addAttribute(model,"minOccurs",minOccurs +"",property); + XSLTUtils.addAttribute(model,"minOccurs",minOccurs +"",property); } long maxOccurs = metainf.getMaxOccurs(name); if (maxOccurs==Long.MAX_VALUE){ - XSLTUtils.addAttribute(model,"unbound","yes",property); + XSLTUtils.addAttribute(model,"unbound","yes",property); }else{ XSLTUtils.addAttribute(model,"maxOccurs",maxOccurs +"",property); } @@ -205,14 +224,23 @@ parse(model,out); //return the fully qualified class name return packageName+"."+className; + } + /** + * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map, org.apache.axis2.databinding.schema.BeanWriterMetaInfoHolder) + * @param simpleType + * @param typeMap + * @param metainf + * @return + * @throws SchemaCompilationException + */ public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException { throw new SchemaCompilationException("Not implemented yet"); } /** - * + * gets a non conflicting java name * @param listOfNames * @param nameBase * @return