[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/custom
From:       Dennis Sosnoski <dsosnoski () users ! sourceforge ! net>
Date:       2008-07-31 12:20:48
Message-ID: E1KOX9K-0005o6-PU () mail ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/custom
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv9861/src/org/jibx/schema/codegen/custom


Modified Files:
	SchemaRootBase.java SchemaCustom.java binding.xml 
Log Message:
Add remove-annotations attribute to binding definition at schema base level.

Index: binding.xml
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/custom/binding.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** binding.xml	20 Jun 2008 00:55:26 -0000	1.4
--- binding.xml	31 Jul 2008 12:20:44 -0000	1.5
***************
*** 44,47 ****
--- 44,48 ----
      <value name="strip-prefixes" field="m_stripPrefixes" usage="optional"/>
      <value name="strip-suffixes" field="m_stripSuffixes" usage="optional"/>
+     <value name="delete-annotations" field="m_deleteAnnotations" usage="optional"/>
      <structure map-as="org.jibx.schema.codegen.custom.NestingCustomBase"/>
    </mapping>

Index: SchemaCustom.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/custom/SchemaCustom.java,v
 retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** SchemaCustom.java	20 Jun 2008 00:55:26 -0000	1.11
--- SchemaCustom.java	31 Jul 2008 12:20:40 -0000	1.12
***************
*** 39,42 ****
--- 39,43 ----
  import org.jibx.schema.codegen.PackageHolder;
  import org.jibx.schema.elements.AnnotatedBase;
+ import org.jibx.schema.elements.AnnotationElement;
  import org.jibx.schema.elements.FacetElement;
  import org.jibx.schema.elements.FilteredSegmentList;
***************
*** 194,203 ****
       * non-excluded globals. It then applies the customizations to the extensions.
       * 
!      * @param nconv name converter 
!      * @param pack package for generated classes
       * @param vctx validation context
       */
      public void extend(NameConverter nconv, PackageHolder pack, ValidationContext \
vctx) {  
          // build the basic include and exclude sets
          Set inclset = Collections.EMPTY_SET;
--- 195,220 ----
       * non-excluded globals. It then applies the customizations to the extensions.
       * 
!      * @param nconv name converter (<code>null</code> if no code generation)
!      * @param pack package for generated classes (<code>null</code> if no code \
                generation)
       * @param vctx validation context
       */
      public void extend(NameConverter nconv, PackageHolder pack, ValidationContext \
vctx) {  
+         // start by deleting annotations, if requested
+         TreeWalker wlkr = new TreeWalker(null, null);
+         if (isDeleteAnnotations()) {
+             
+             // first delete all annotation children of the schema element itself
+             for (int i = 0; i < m_schema.getChildCount(); i++) {
+                 if (m_schema.getChild(i).type() == SchemaBase.ANNOTATION_TYPE) {
+                     m_schema.detachChild(i);
+                 }
+             }
+             m_schema.compactChildren();
+             
+             // now remove all embedded annotations within any definitions
+             wlkr.walkSchema(m_schema, new AnnotationDeletionVisitor());
+         }
+         
          // build the basic include and exclude sets
          Set inclset = Collections.EMPTY_SET;
***************
*** 224,229 ****
          m_extension.setTypeReplacer(this);
          FilteredSegmentList globals = m_schema.getTopLevelChildren();
!         ExtensionBuilderVisitor builder = new ExtensionBuilderVisitor(nconv);
!         TreeWalker wlkr = new TreeWalker(null, null);
          // Level level = TreeWalker.setLogging(s_logger.getLevel());
          boolean inner = isUseInner();
--- 241,245 ----
          m_extension.setTypeReplacer(this);
          FilteredSegmentList globals = m_schema.getTopLevelChildren();
!         ExtensionBuilderVisitor builder = new ExtensionBuilderVisitor();
          // Level level = TreeWalker.setLogging(s_logger.getLevel());
          boolean inner = isUseInner();
***************
*** 358,376 ****
      private static class ExtensionBuilderVisitor extends SchemaVisitor
      {
-         /** Name converter. */
-         private final NameConverter m_nameConverter;
-         
          /** Extension for root component being expanded. */
          private GlobalExtension m_root;
- 
-         /**
-          * Constructor.
-          * 
-          * @param nconv name converter
-          */
-         public ExtensionBuilderVisitor(NameConverter nconv) {
-             super();
-             m_nameConverter = nconv;
-         }
          
          /**
--- 374,379 ----
***************
*** 396,399 ****
--- 399,419 ----
      
      /**
+      * Visitor to delete annotations from schema components.
+      */
+     private static class AnnotationDeletionVisitor extends SchemaVisitor
+     {
+         /**
+          * Visit any component of schema definition. This just deletes any \
annotation present. +          * 
+          * @param node
+          * @return <code>true</code> to continue expansion
+          */
+         public boolean visit(AnnotatedBase node) {
+             node.setAnnotation(null);
+             return true;
+         }
+     }
+     
+     /**
       * Visitor to flag extensions to remove unused facets. This relies on each \
                customization being set as the type
       * substitution handler for the corresponding extension.

Index: SchemaRootBase.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/codegen/custom/SchemaRootBase.java,v
 retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SchemaRootBase.java	20 Jun 2008 00:55:26 -0000	1.4
--- SchemaRootBase.java	31 Jul 2008 12:20:38 -0000	1.5
***************
*** 51,54 ****
--- 51,57 ----
      private Boolean m_useInner;
      
+     /** Delete annotations flag. */
+     private Boolean m_deleteAnnotations;
+     
      /** Prefix strings to be stripped when converting names. */
      private String[] m_stripPrefixes;
***************
*** 130,133 ****
--- 133,153 ----
      
      /**
+      * Check whether annotations are to be deleted. The default is \
<code>false</code> if not overridden at any level. +      *
+      * @return delete annotations flag
+      */
+     public boolean isDeleteAnnotations() {
+         SchemaRootBase root = this;
+         while (root != null) {
+             if (root.m_deleteAnnotations != null) {
+                 return root.m_deleteAnnotations.booleanValue();
+             } else {
+                 root = root.getRootParent();
+             }
+         }
+         return false;
+     }
+     
+     /**
       * Get the prefixes to be stripped when converting XML names.
       *


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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