[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-cvs
Subject:    [Jibx-cvs] core/build/src/org/jibx/schema/codegen TypeData.java,
From:       Dennis Sosnoski <dsosnoski () users ! sourceforge ! net>
Date:       2009-04-16 11:39:09
Message-ID: E1LuPvx-0003UJ-Dn () fdv4jf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Update of /cvsroot/jibx/core/build/src/org/jibx/schema/codegen
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13329/src/org/jibx/schema/codegen


Modified Files:
	DefinitionItem.java PackageHolder.java GroupItem.java 
	CodeGen.java StructureClassHolder.java 
	SchemaDocumentationGenerator.java JavaType.java 
	ClassHolder.java ItemVisitor.java 
Added Files:
	TypeData.java 
Removed Files:
	ClassData.java 
Log Message:
Added <schema-type> customization to allow overrides to the default handling of \
predefined schema datatypes.

--- ClassData.java DELETED ---

--- NEW FILE: TypeData.java ---
/*
 * Copyright (c) 2009, Dennis M. Sosnoski. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, \
                are permitted provided that the
 * following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list \
                of conditions and the following
 * disclaimer. Redistributions in binary form must reproduce the above copyright \
                notice, this list of conditions and the
 * following disclaimer in the documentation and/or other materials provided with the \
                distribution. Neither the name of
 * JiBX nor the names of its contributors may be used to endorse or promote products \
                derived from this software without
 * specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \
                ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \
                FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR \
                ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \
                PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED \
                AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
                ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.jibx.schema.codegen;

/**
 * Information for a class matching a schema definition.
 * 
 * @author Dennis M. Sosnoski
 */
public class TypeData
{
    /** Fully-qualified class name. */
    private final String m_fullName;
    
    /** Class name as used for binding (with '$' marker for inner class). */
    private final String m_bindingName;
    
    /** Pregenerated class flag. */
    private final boolean m_pregenerated;
    
    /** Class represents simple value flag. */
    private final boolean m_simple;

    /**
     * Constructor with all values specified.
     * 
     * @param fullname fully-qualified class name in standard form ('.' as inner \
                class separator)
     * @param bindname fully-qualified class name as used in binding (with '$' inner \
                class separator)
     * @param pregen pregenerated class flag
     * @param simple simple value flag
     */
    public TypeData(String fullname, String bindname, boolean pregen, boolean simple) \
{  m_fullName = fullname;
        m_bindingName = bindname;
        m_pregenerated = pregen;
        m_simple = simple;
    }
    
    /**
     * Constructor for new top-level class.
     * 
     * @param fullname fully-qualified class name
     * @param simple simple value flag
     */
    public TypeData(String fullname, boolean simple) {
        this(fullname, fullname, false, simple);
    }

    /**
     * Constructor from new top-level or inner class.
     * 
     * @param fullname fully-qualified class name in standard form ('.' as inner \
                class separator)
     * @param bindname fully-qualified class name as used in binding (with '$' inner \
                class separator)
     * @param simple simple value flag
     */
    public TypeData(String fullname, String bindname, boolean simple) {
        this(fullname, bindname, false, simple);
    }

    /**
     * Get fully-qualified name.
     * 
     * @return name
     */
    public String getFullName() {
        return m_fullName;
    }

    /**
     * Get fully-qualified name as used in binding. This differs from the standard \
                fully-qualified name in that it uses
     * '$' rather than '.' to delimit inner class names.
     * 
     * @return name
     */
    public String getBindingName() {
        return m_bindingName;
    }
    
    /**
     * Check if pregenerated class.
     *
     * @return <code>true</code> if pregenerated, <code>false</code> if not
     */
    public boolean isPregenerated() {
        return m_pregenerated;
    }
    
    /**
     * Check if class represents a simple value.
     *
     * @return <code>true</code> if simple value, <code>false</code> if not
     */
    public boolean isSimpleValue() {
        return m_simple;
    }
}
Index: StructureClassHolder.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/StructureClassHolder.java,v
 retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** StructureClassHolder.java	9 Apr 2009 11:34:55 -0000	1.43
--- StructureClassHolder.java	16 Apr 2009 11:39:07 -0000	1.44
***************
*** 366,370 ****
       */
      private void setCollectionName(String name, Item item) {
!         String singular = NameUtilities.depluralize(name);
          if (!singular.equals(name)) {
              s_logger.debug("Converted name " + name + " to " + singular);
--- 366,370 ----
       */
      private void setCollectionName(String name, Item item) {
!         String singular = m_nameConverter.depluralize(name);
          if (!singular.equals(name)) {
              s_logger.debug("Converted name " + name + " to " + singular);
***************
*** 480,484 ****
                          // pluralize name for collection, as will be done with the \
                actual property name
                          // TODO: really need to use name structure and references, \
                to avoid duplicated efforts like this
!                         name = NameUtilities.pluralize(name);
                          
                      }
--- 480,484 ----
                          // pluralize name for collection, as will be done with the \
                actual property name
                          // TODO: really need to use name structure and references, \
                to avoid duplicated efforts like this
!                         name = m_nameConverter.pluralize(name);
                          
                      }
***************
*** 667,671 ****
              value.setSetName(sname);
          }
!         setValueFormatReference(node.getItem(), value, holder);
          
          // set test method if needed to pick between alternatives
--- 667,671 ----
              value.setSetName(sname);
          }
!         setValueHandlingOptions(node.getItem(), value, holder);
          
          // set test method if needed to pick between alternatives
***************
*** 1379,1383 ****
                  String propname = NameUtils.toNameWord(basename);
                  if (node.isCollection()) {
!                     propname = NameUtilities.pluralize(propname);
                  }
                  node.setPropName(propname);
--- 1379,1383 ----
                  String propname = NameUtils.toNameWord(basename);
                  if (node.isCollection()) {
!                     propname = m_nameConverter.pluralize(propname);
                  }
                  node.setPropName(propname);
***************
*** 1476,1482 ****
  
      /**
!      * Set the format reference for a &lt;value> component of the binding. If the \
                item defining the item is a reference,
!      * this uses the definition type name as the format and makes sure the \
                definition namespace is defined within the
!      * binding being generated.
       *
       * @param item
--- 1476,1483 ----
  
      /**
!      * Set serializer/deserializer options for a &lt;value> component of the \
                binding. If the item defining the item is a
!      * reference, this uses the definition type name as the format and makes sure \
                the definition namespace is defined
!      * within the binding being generated. If the item defining the item is a \
                builtin type, this sets the format and/or
!      * serializer/deserializer methods based on the type definition.
       *
       * @param item
***************
*** 1484,1488 ****
       * @param holder
       */
!     private void setValueFormatReference(Item item, ValueElement value, \
BindingHolder holder) {  if (item instanceof ReferenceItem) {
              ReferenceItem refitem = (ReferenceItem)item;
--- 1485,1489 ----
       * @param holder
       */
!     private void setValueHandlingOptions(Item item, ValueElement value, \
BindingHolder holder) {  if (item instanceof ReferenceItem) {
              ReferenceItem refitem = (ReferenceItem)item;
***************
*** 1493,1496 ****
--- 1494,1503 ----
                  holder.addNamespaceReference(defitem.getSchemaComponent().getSchema(), \
qname.getUri());  }
+         } else if (item instanceof ValueItem) {
+             ValueItem valitem = (ValueItem)item;
+             JavaType jtype = valitem.getType();
+             value.setFormatName(jtype.getFormat());
+             value.setSerializerName(jtype.getSerializerMethod());
+             value.setDeserializerName(jtype.getDeserializerMethod());
          }
      }
***************
*** 1625,1629 ****
                              \
                value.setGetName(((LeafNode)nested).getGetMethodName());
                              \
                value.setSetName(((LeafNode)nested).getSetMethodName());
!                             setValueFormatReference(item, value, holder);
                              wrapcomp.addChild(value);
                              if \
                (SchemaUtils.isOptionalAttribute((AttributeElement)comp)) {
--- 1632,1636 ----
                              \
                value.setGetName(((LeafNode)nested).getGetMethodName());
                              \
                value.setSetName(((LeafNode)nested).getSetMethodName());
!                             setValueHandlingOptions(item, value, holder);
                              wrapcomp.addChild(value);
                              if \
                (SchemaUtils.isOptionalAttribute((AttributeElement)comp)) {
***************
*** 1802,1806 ****
                              if (item instanceof ReferenceItem) {
                                  DefinitionItem def = \
                ((ReferenceItem)item).getDefinition();
!                                 ClassData defclas = def.getGenerateClass();
                                  if (defclas.isSimpleValue()) {
                                      usetype = defclas.getBindingName();
--- 1809,1813 ----
                              if (item instanceof ReferenceItem) {
                                  DefinitionItem def = \
                ((ReferenceItem)item).getDefinition();
!                                 TypeData defclas = def.getGenerateClass();
                                  if (defclas.isSimpleValue()) {
                                      usetype = defclas.getBindingName();
***************
*** 1834,1838 ****
                                  
                                  // handle group directly if a structure class, else \
                just as <value>
!                                 ClassData groupclas = \
((GroupItem)item).getGenerateClass();  if (groupclas.isSimpleValue()) {
                                      usetype = groupclas.getBindingName();
--- 1841,1845 ----
                                  
                                  // handle group directly if a structure class, else \
                just as <value>
!                                 TypeData groupclas = \
((GroupItem)item).getGenerateClass();  if (groupclas.isSimpleValue()) {
                                      usetype = groupclas.getBindingName();
***************
*** 1861,1865 ****
                                      setName(leaf.getQName(), holder, value);
                                  }
!                                 setValueFormatReference(item, value, holder);
                                  value.setDeclaredType(usetype);
                                  collect.addChild(value);
--- 1868,1872 ----
                                      setName(leaf.getQName(), holder, value);
                                  }
!                                 setValueHandlingOptions(item, value, holder);
                                  value.setDeclaredType(usetype);
                                  collect.addChild(value);
***************
*** 1908,1912 ****
                              // handle reference directly if a structure class, else \
                just as value
                              DefinitionItem def = \
                ((ReferenceItem)item).getDefinition();
!                             ClassData defclas = def.getGenerateClass();
                              if (!defclas.isSimpleValue()) {
                                  struct = addReferenceStructure(leaf, def, consing, \
                holder, contain);
--- 1915,1919 ----
                              // handle reference directly if a structure class, else \
                just as value
                              DefinitionItem def = \
                ((ReferenceItem)item).getDefinition();
!                             TypeData defclas = def.getGenerateClass();
                              if (!defclas.isSimpleValue()) {
                                  struct = addReferenceStructure(leaf, def, consing, \
                holder, contain);
***************
*** 1916,1920 ****
                              
                              // handle group directly if a structure class, else \
                just as value
!                             ClassData groupclas = \
((GroupItem)item).getGenerateClass();  if (!groupclas.isSimpleValue()) {
                                  
--- 1923,1927 ----
                              
                              // handle group directly if a structure class, else \
                just as value
!                             TypeData groupclas = \
((GroupItem)item).getGenerateClass();  if (!groupclas.isSimpleValue()) {
                                  

Index: ClassHolder.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/ClassHolder.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** ClassHolder.java	9 Apr 2009 11:34:55 -0000	1.38
--- ClassHolder.java	16 Apr 2009 11:39:07 -0000	1.39
***************
*** 70,74 ****
   * @author Dennis M. Sosnoski
   */
! public abstract class ClassHolder extends ClassData implements IClassHolder
  {
      // collection constants
--- 70,74 ----
   * @author Dennis M. Sosnoski
   */
! public abstract class ClassHolder extends TypeData implements IClassHolder
  {
      // collection constants
***************
*** 134,138 ****
      
      /** Superclass to be extended as part of schema model (<code>null</code> if \
                none). */
!     private ClassData m_superClass;
      
      /** Superclass name to be extended if extension not required by model \
                (<code>null</code> if none). */
--- 134,138 ----
      
      /** Superclass to be extended as part of schema model (<code>null</code> if \
                none). */
!     private TypeData m_superClass;
      
      /** Superclass name to be extended if extension not required by model \
                (<code>null</code> if none). */
***************
*** 445,449 ****
       * @return base (<code>null</code> if none)
       */
!     public ClassData getSuperClass() {
          return m_superClass;
      }
--- 445,449 ----
       * @return base (<code>null</code> if none)
       */
!     public TypeData getSuperClass() {
          return m_superClass;
      }
***************
*** 454,458 ****
       * @param sclas (<code>null</code> if none)
       */
!     public void setSuperClass(ClassData sclas) {
          m_superClass = sclas;
          if (sclas != null) {
--- 454,458 ----
       * @param sclas (<code>null</code> if none)
       */
!     public void setSuperClass(TypeData sclas) {
          m_superClass = sclas;
          if (sclas != null) {

Index: JavaType.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/JavaType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JavaType.java	19 Apr 2008 18:35:08 -0000	1.2
--- JavaType.java	16 Apr 2009 11:39:07 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright (c) 2006-2008, Dennis M. Sosnoski. All rights reserved.
   * 
   * Redistribution and use in source and binary forms, with or without modification, \
                are permitted provided that the
--- 1,4 ----
  /*
!  * Copyright (c) 2006-2009, Dennis M. Sosnoski. All rights reserved.
   * 
   * Redistribution and use in source and binary forms, with or without modification, \
                are permitted provided that the
***************
*** 22,26 ****
--- 22,28 ----
  package org.jibx.schema.codegen;
  
+ import java.util.Collections;
  import java.util.HashMap;
+ import java.util.Map;
  
  /**
***************
*** 34,87 ****
  {
      /** Predefined schema simple type correspondences (note not all are defined \
                yet). */
!     private static final HashMap s_schemaTypesMap;
      static {
          // TODO define correspondences and add handling for current nulls
!         s_schemaTypesMap = new HashMap();
!         addType("anySimpleType", null);
!         addType("anyURI", null);
!         addType("base64Binary", "byte[]");
!         addType("boolean", "boolean", "java.lang.Boolean", \
                "org.jibx.runtime.Utility.ifBoolean");
!         addType("byte", "byte", "java.lang.Byte", \
                "org.jibx.runtime.Utility.ifByte");
!         addType("date", null, "java.sql.Date", "org.jibx.runtime.Utility.ifDate");
!         addType("dateTime", null, "java.util.Date", \
                "org.jibx.runtime.Utility.ifDateTime");
!         addType("decimal", "java.math.BigDecimal");
!         addType("double", "double", "java.lang.Double");
!         addType("duration", null);
!         addType("ENTITY", null);
!         addType("ENTITIES", null);
!         addType("float", "float", "java.lang.Float");
!         addType("gDay", null);
!         addType("gMonth", null);
!         addType("gMonthDay", null);
!         addType("gYear", null);
!         addType("gYearMonth", null);
!         addType("hexBinary", "byte[]");
!         addType("ID", "java.lang.String");
!         addType("IDREF", "java.lang.String");
!         addType("IDREFS", null);
!         addType("int", "int", "java.lang.Integer", \
                "org.jibx.runtime.Utility.ifInt");
!         addType("integer", null, "java.math.BigInteger", \
                "org.jibx.runtime.Utility.ifInteger");
!         addType("language", null);
!         addType("long", "long", "java.lang.Long", \
                "org.jibx.runtime.Utility.ifLong");
!         addType("Name", null);
!         addType("negativeInteger", null);
!         addType("nonNegativeInteger", null);
!         addType("nonPositiveInteger", null);
!         addType("normalizedString", null);
!         addType("NCName", null);
!         addType("NMTOKEN", null);
!         addType("NMTOKENS", null);
!         addType("NOTATION", null);
!         addType("positiveInteger", null);
!         addType("QName", "org.jibx.runtime.QName");
!         addType("short", "short", "java.lang.Short", \
                "org.jibx.runtime.Utility.ifShort");
!         addType("string", "java.lang.String");
!         addType("time", null, "java.sql.Time", "org.jibx.runtime.Utility.ifTime");
!         addType("token", null);
!         addType("unsignedByte", null);
!         addType("unsignedInt", null);
!         addType("unsignedLong", null);
!         addType("unsignedShort", null);
!     }
      
      /** &lt;any> schema component type. */
--- 36,89 ----
  {
      /** Predefined schema simple type correspondences (note not all are defined \
                yet). */
!     private static final Map s_schemaTypesMap;
      static {
          // TODO define correspondences and add handling for current nulls
!         Map map = new HashMap();
!         addType("anySimpleType", "java.lang.String", map);
!         addType("anyURI", "java.lang.String", map);
!         addType("base64Binary", "byte[]", map);
!         addType("boolean", "boolean", "java.lang.Boolean", \
                "org.jibx.runtime.Utility.ifBoolean", map);
!         addType("byte", "byte", "java.lang.Byte", \
                "org.jibx.runtime.Utility.ifByte", map);
!         addType("date", null, "java.sql.Date", "org.jibx.runtime.Utility.ifDate", \
                map);
!         addType("dateTime", null, "java.util.Date", \
                "org.jibx.runtime.Utility.ifDateTime", map);
!         addType("decimal", "java.math.BigDecimal", map);
!         addType("double", "double", "java.lang.Double", map);
!         addType("duration", "java.lang.String", map);
!         addType("ENTITY", "java.lang.String", map);
!         addType("ENTITIES", "java.lang.String", map);
!         addType("float", "float", "java.lang.Float", map);
!         addType("gDay", "java.lang.String", map);
!         addType("gMonth", "java.lang.String", map);
!         addType("gMonthDay", "java.lang.String", map);
!         addType("gYear", "java.lang.String", map);
!         addType("gYearMonth", "java.lang.String", map);
!         addType("hexBinary", "byte[]", map);
!         addType("ID", "java.lang.String", map);
!         addType("IDREF", "java.lang.String", map);
!         addType("IDREFS", "java.lang.String", map);
!         addType("int", "int", "java.lang.Integer", \
                "org.jibx.runtime.Utility.ifInt", map);
!         addType("integer", null, "java.math.BigInteger", \
                "org.jibx.runtime.Utility.ifInteger", map);
!         addType("language", "java.lang.String", map);
!         addType("long", "long", "java.lang.Long", \
                "org.jibx.runtime.Utility.ifLong", map);
!         addType("Name", "java.lang.String", map);
!         addType("negativeInteger", "java.lang.String", map);
!         addType("nonNegativeInteger", "java.lang.String", map);
!         addType("nonPositiveInteger", "java.lang.String", map);
!         addType("normalizedString", "java.lang.String", map);
!         addType("NCName", "java.lang.String", map);
!         addType("NMTOKEN", "java.lang.String", map);
!         addType("NMTOKENS", "java.lang.String", map);
!         addType("NOTATION", "java.lang.String", map);
!         addType("positiveInteger", "java.lang.String", map);
!         addType("QName", "org.jibx.runtime.QName", map);
!         addType("short", "short", "java.lang.Short", \
                "org.jibx.runtime.Utility.ifShort", map);
!         addType("string", "java.lang.String", map);
!         addType("time", null, "java.sql.Time", "org.jibx.runtime.Utility.ifTime", \
                map);
!         addType("token", "java.lang.String", map);
!         addType("unsignedByte", "java.lang.String", map);
!         addType("unsignedInt", "java.lang.String", map);
!         addType("unsignedLong", "java.lang.String", map);
!         addType("unsignedShort", "java.lang.String", map);
!         s_schemaTypesMap = Collections.unmodifiableMap(map);    }
      
      /** &lt;any> schema component type. */
***************
*** 100,109 ****
      private final String m_fqName;
      
-     /** Object type an implicit import flag (from <code>java.lang</code> package). \
                */
-     private final boolean m_isImplicit;
-     
      /** JiBX format name (for types requiring special handling, <code>null</code> \
otherwise). */  private final String m_format;
      
      /** Method to check if a text string matches the format for this type \
(<code>null</code> if unused). */  private final String m_checkMethod;
--- 102,114 ----
      private final String m_fqName;
      
      /** JiBX format name (for types requiring special handling, <code>null</code> \
otherwise). */  private final String m_format;
      
+     /** Method to convert instance of type to a text string. */
+     private final String m_serializerMethod;
+     
+     /** Method to convert text string to instance of type. */
+     private final String m_deserializerMethod;
+     
      /** Method to check if a text string matches the format for this type \
(<code>null</code> if unused). */  private final String m_checkMethod;
***************
*** 115,131 ****
       * @param slname schema type local name
       * @param pname primitive type name (<code>null</code> if none)
!      * @param fqname object type fully-qualified name (<code>null</code> if none)
       * @param format JiBX format name (<code>null</code> if none)
!      * @param check check method name (<code>null</code> if none)
       */
!     private JavaType(String slname, String pname, String fqname, String format, \
                String check) {
!         m_schemaName = slname;
!         m_primitiveName = pname;
          if (fqname == null) {
!             fqname = "java.lang.String";
          }
          m_fqName = fqname;
-         m_isImplicit = fqname.startsWith("java.lang.");
          m_format = format;
          m_checkMethod = check;
      }
--- 120,139 ----
       * @param slname schema type local name
       * @param pname primitive type name (<code>null</code> if none)
!      * @param fqname object type fully-qualified name (non-<code>null</code>)
       * @param format JiBX format name (<code>null</code> if none)
!      * @param ser fully-qualified serializer class and method name \
                (<code>null</code> if none)
!      * @param dser fully-qualified deserializer class and method name \
                (<code>null</code> if none)
!      * @param check fully-qualified check class and method name (<code>null</code> \
                if none)
       */
!     public JavaType(String slname, String pname, String fqname, String format, \
String ser, String dser, String check) {  if (fqname == null) {
!             throw new IllegalArgumentException("Internal error - object type \
required for definition");  }
+         m_schemaName = slname;
+         m_primitiveName = pname;
          m_fqName = fqname;
          m_format = format;
+         m_serializerMethod = ser;
+         m_deserializerMethod = dser;
          m_checkMethod = check;
      }
***************
*** 139,143 ****
       */
      private JavaType(String slname, String pname, String fqname) {
!         this(slname, pname, fqname, null, null);
      }
      
--- 147,151 ----
       */
      private JavaType(String slname, String pname, String fqname) {
!         this(slname, pname, fqname, null, null, null, null);
      }
      
***************
*** 148,153 ****
       * @param fqname fully-qualified java object type name
       */
!     private static void addType(String lname, String fqname) {
!         addType(lname, null, fqname, null);
      }
      
--- 156,161 ----
       * @param fqname fully-qualified java object type name
       */
!     private static void addType(String lname, String fqname, Map map) {
!         addType(lname, null, fqname, null, map);
      }
      
***************
*** 159,164 ****
       * @param fqname fully-qualified java object type name
       */
!     private static void addType(String lname, String pname, String fqname) {
!         addType(lname, null, fqname, null);
      }
      
--- 167,172 ----
       * @param fqname fully-qualified java object type name
       */
!     private static void addType(String lname, String pname, String fqname, Map map) \
                {
!         addType(lname, null, fqname, null, map);
      }
      
***************
*** 171,194 ****
       * @param check check method name (<code>null</code> if none)
       */
!     private static void addType(String lname, String pname, String fqname, String \
                check) {
!         s_schemaTypesMap.put(lname, new JavaType(lname, pname, fqname, null, \
check));  }
      
      //
!     // Lookup method
      
      /**
!      * Get type instance.
       * 
!      * @param name schema type local name
!      * @return type information (non-<code>null</code>)
       */
!     public static JavaType getType(String name) {
!         JavaType type = (JavaType)s_schemaTypesMap.get(name);
!         if (type == null) {
!             throw new IllegalArgumentException("Internal error: " + name + " is not \
                a recognized schema type name");
!         } else {
!             return type;
!         }
      }
      
--- 179,196 ----
       * @param check check method name (<code>null</code> if none)
       */
!     private static void addType(String lname, String pname, String fqname, String \
                check, Map map) {
!         map.put(lname, new JavaType(lname, pname, fqname, null, null, null, \
check));  }
      
      //
!     // Static access method
      
      /**
!      * Get map from schema type local name to Java type.
       * 
!      * @return map
       */
!     public static Map getTypeMap() {
!         return s_schemaTypesMap;
      }
      
***************
*** 216,228 ****
      
      /**
-      * Check if object type is implicit import.
-      * 
-      * @return implicit
-      */
-     public boolean isImplicit() {
-         return m_isImplicit;
-     }
-     
-     /**
       * Get primitive type name.
       * 
--- 218,221 ----
***************
*** 241,243 ****
--- 234,263 ----
          return m_format;
      }
+     
+     /**
+      * Get serializer method name.
+      * 
+      * @return name (<code>null</code> if none)
+      */
+     public String getSerializerMethod() {
+         return m_serializerMethod;
+     }
+     
+     /**
+      * Get deserializer method name.
+      * 
+      * @return name (<code>null</code> if none)
+      */
+     public String getDeserializerMethod() {
+         return m_deserializerMethod;
+     }
+     
+     /**
+      * Get check method name.
+      * 
+      * @return name (<code>null</code> if none)
+      */
+     public String getCheckMethod() {
+         return m_checkMethod;
+     }
  }
\ No newline at end of file

Index: CodeGen.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/CodeGen.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** CodeGen.java	10 Apr 2009 12:10:34 -0000	1.19
--- CodeGen.java	16 Apr 2009 11:39:07 -0000	1.20
***************
*** 1585,1589 ****
              DefinitionItem definition = (DefinitionItem)items.get(i);
              QName qname = definition.getQName();
!             ClassData clas = null;
              switch (definition.getSchemaComponent().type()) {
                  case SchemaBase.ATTRIBUTEGROUP_TYPE:
--- 1585,1589 ----
              DefinitionItem definition = (DefinitionItem)items.get(i);
              QName qname = definition.getQName();
!             TypeData clas = null;
              switch (definition.getSchemaComponent().type()) {
                  case SchemaBase.ATTRIBUTEGROUP_TYPE:
***************
*** 1592,1601 ****
                  case SchemaBase.SIMPLETYPE_TYPE:
                  {
!                     clas = (ClassData)typemap.get(qname);
                      break;
                  }
                  case SchemaBase.ELEMENT_TYPE:
                  {
!                     clas = (ClassData)elemmap.get(qname);
                      break;
                  }
--- 1592,1601 ----
                  case SchemaBase.SIMPLETYPE_TYPE:
                  {
!                     clas = (TypeData)typemap.get(qname);
                      break;
                  }
                  case SchemaBase.ELEMENT_TYPE:
                  {
!                     clas = (TypeData)elemmap.get(qname);
                      break;
                  }
***************
*** 1846,1853 ****
       * @return data
       */
!     private static ClassData buildClassData(String cname, boolean simple) {
          String bname = cname;
          String fname = bname.replace('$', '.');
!         return new ClassData(fname, bname, true, simple);
      }
  
--- 1846,1853 ----
       * @return data
       */
!     private static TypeData buildClassData(String cname, boolean simple) {
          String bname = cname;
          String fname = bname.replace('$', '.');
!         return new TypeData(fname, bname, true, simple);
      }
  
***************
*** 1877,1881 ****
                  MappingElementBase mapping = (MappingElementBase)element;
                  String cname = mapping.getClassName();
!                 ClassData data = buildClassData(cname, false);
                  if (mapping.isAbstract()) {
                      QName qname = mapping.getTypeQName();
--- 1877,1881 ----
                  MappingElementBase mapping = (MappingElementBase)element;
                  String cname = mapping.getClassName();
!                 TypeData data = buildClassData(cname, false);
                  if (mapping.isAbstract()) {
                      QName qname = mapping.getTypeQName();
***************
*** 1900,1904 ****
                  String name = format.getTypeName();
                  if (name != null) {
!                     ClassData data = buildClassData(name, true);
                      typemap.put(format.getQName(), data);
                  }
--- 1900,1904 ----
                  String name = format.getTypeName();
                  if (name != null) {
!                     TypeData data = buildClassData(name, true);
                      typemap.put(format.getQName(), data);
                  }

Index: PackageHolder.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/PackageHolder.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** PackageHolder.java	9 Apr 2009 11:34:55 -0000	1.17
--- PackageHolder.java	16 Apr 2009 11:39:07 -0000	1.18
***************
*** 192,196 ****
       * @param ast
       */
!     public void generate(boolean verbose, ClassData clasdata, BindingHolder \
bindhold, AST ast) {  if (!clasdata.isPregenerated()) {
              ClassHolder clashold = (ClassHolder)clasdata;
--- 192,196 ----
       * @param ast
       */
!     public void generate(boolean verbose, TypeData clasdata, BindingHolder \
bindhold, AST ast) {  if (!clasdata.isPregenerated()) {
              ClassHolder clashold = (ClassHolder)clasdata;

Index: ItemVisitor.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/ItemVisitor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ItemVisitor.java	8 Mar 2009 06:59:15 -0000	1.14
--- ItemVisitor.java	16 Apr 2009 11:39:07 -0000	1.15
***************
*** 53,56 ****
--- 53,59 ----
      private static final Logger s_logger = \
Logger.getLogger(ItemVisitor.class.getName());  
+     /** Extension information for the global definition being constructed. */
+     private GlobalExtension m_global;
+     
      /** Group currently being constructed. */
      private GroupItem m_group;
***************
*** 74,78 ****
          DefinitionItem definition = new DefinitionItem(comp);
          m_group = definition;
!         ((GlobalExtension)comp.getExtension()).setDefinition(definition);
          TreeWalker wlkr = new TreeWalker(null, null);
          wlkr.walkElement(comp, this);
--- 77,82 ----
          DefinitionItem definition = new DefinitionItem(comp);
          m_group = definition;
!         m_global = (GlobalExtension)comp.getExtension();
!         m_global.setDefinition(definition);
          TreeWalker wlkr = new TreeWalker(null, null);
          wlkr.walkElement(comp, this);
***************
*** 140,143 ****
--- 144,163 ----
      
      /**
+      * Get the data type information for a built-in schema type.
+      *
+      * @param def schema type definition
+      * @return type information
+      */
+     private JavaType getSchemaType(CommonTypeDefinition def) {
+         String name = def.getName();
+         JavaType type = (JavaType)m_global.getSchemaTypes().get(name);
+         if (type == null) {
+             throw new IllegalArgumentException("Unknown schema type '" + name + \
'\''); +         } else {
+             return type;
+         }
+     }
+     
+     /**
       * Build an item from a type reference. For a predefined schema type this will \
                be a simple {@link ValueItem}
       * wrapped in a {@link GroupItem}; for a global type it will be a reference to \
                a global definition.
***************
*** 149,153 ****
          if (def.isPredefinedType()) {
              GroupItem group = m_group.addGroup(comp);
!             group.addValue(comp, def.getQName(), JavaType.getType(def.getName()));
          } else {
              addReference(comp, def);
--- 169,173 ----
          if (def.isPredefinedType()) {
              GroupItem group = m_group.addGroup(comp);
!             group.addValue(comp, def.getQName(), getSchemaType(def));
          } else {
              addReference(comp, def);
***************
*** 367,371 ****
                  CommonTypeDefinition type = types[i];
                  if (type.isPredefinedType()) {
!                     struct.addValue(node, type.getQName(), \
JavaType.getType(type.getName()));  } else {
                      GroupItem hold = m_group;
--- 387,391 ----
                  CommonTypeDefinition type = types[i];
                  if (type.isPredefinedType()) {
!                     struct.addValue(node, type.getQName(), getSchemaType(type));
                  } else {
                      GroupItem hold = m_group;

Index: SchemaDocumentationGenerator.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/SchemaDocumentationGenerator.java,v
 retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SchemaDocumentationGenerator.java	9 Apr 2009 11:34:55 -0000	1.9
--- SchemaDocumentationGenerator.java	16 Apr 2009 11:39:07 -0000	1.10
***************
*** 148,152 ****
                      if (!childgroup.isIgnored()) {
                          if (!childgroup.isInline()) {
!                             ClassData genclas = childgroup.getGenerateClass();
                              if (genclas == null) {
                                  throw new IllegalStateException("Internal error - \
                no generate class");
--- 148,152 ----
                      if (!childgroup.isIgnored()) {
                          if (!childgroup.isInline()) {
!                             TypeData genclas = childgroup.getGenerateClass();
                              if (genclas == null) {
                                  throw new IllegalStateException("Internal error - \
no generate class");

Index: GroupItem.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/GroupItem.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** GroupItem.java	9 Apr 2009 11:34:55 -0000	1.16
--- GroupItem.java	16 Apr 2009 11:39:07 -0000	1.17
***************
*** 60,64 ****
  
      /** Generated class information (<code>null</code> if inlined). */
!     private ClassData m_generateClass;
  
      /** Flag for all child nodes are optional. In cases where multiple items are \
                associated with the same schema
--- 60,64 ----
  
      /** Generated class information (<code>null</code> if inlined). */
!     private TypeData m_generateClass;
  
      /** Flag for all child nodes are optional. In cases where multiple items are \
                associated with the same schema
***************
*** 344,348 ****
       * @return class
       */
!     public ClassData getGenerateClass() {
          return m_generateClass;
      }
--- 344,348 ----
       * @return class
       */
!     public TypeData getGenerateClass() {
          return m_generateClass;
      }
***************
*** 354,358 ****
       * @param clas
       */
!     public void setGenerateClass(ClassData clas) {
          m_generateClass = clas;
      }
--- 354,358 ----
       * @param clas
       */
!     public void setGenerateClass(TypeData clas) {
          m_generateClass = clas;
      }
***************
*** 377,381 ****
              DefinitionItem def = ((ReferenceItem)m_head).getDefinition();
              if (isEnumeration() == def.isEnumeration()) {
!                 ClassData base = def.getGenerateClass();
                  if (s_logger.isDebugEnabled()) {
                      s_logger.debug("Setting base class for " + \
                m_generateClass.getFullName() + " to " +
--- 377,381 ----
              DefinitionItem def = ((ReferenceItem)m_head).getDefinition();
              if (isEnumeration() == def.isEnumeration()) {
!                 TypeData base = def.getGenerateClass();
                  if (s_logger.isDebugEnabled()) {
                      s_logger.debug("Setting base class for " + \
m_generateClass.getFullName() + " to " +

Index: DefinitionItem.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/DefinitionItem.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** DefinitionItem.java	9 Apr 2009 11:34:55 -0000	1.11
--- DefinitionItem.java	16 Apr 2009 11:39:07 -0000	1.12
***************
*** 138,142 ****
       */
      public boolean isPregenerated() {
!         ClassData data = getGenerateClass();
          return data != null && data.isPregenerated();
      }
--- 138,142 ----
       */
      public boolean isPregenerated() {
!         TypeData data = getGenerateClass();
          return data != null && data.isPregenerated();
      }


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Jibx-cvs mailing list
Jibx-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic