Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 83   Methods: 3
NCLOC: 58   Classes: 1
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
TopLevelBinding.java 75% 100% 100% 90%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.xml.schema.compiler;
 11   
 
 12   
 import org.jbind.xml.base.IBindingAttributes;
 13   
 import org.jbind.xml.base.ISymbolspace;
 14   
 import org.jbind.xml.base.ISymbolspaces;
 15   
 import org.jbind.xml.base.StringUtil;
 16   
 import org.jbind.xml.core.cmp.IComponent;
 17   
 
 18   
 public abstract class TopLevelBinding extends Binding {
 19   
 
 20   
   private String myPackage;
 21   
 
 22  1820
   public TopLevelBinding(String aPackage, ICartridge aCartridge, IComponent aComponent) {
 23   
     // the schema package
 24  1820
     myPackage = aPackage;
 25   
 
 26   
     // the sub package coming from the cartridge
 27  1820
     addSubPackage(aCartridge.getSubPackage());
 28   
 
 29   
     // the subpackage coming from the symbolspace
 30  1820
     ISymbolspace symbolspace = aComponent.getSymbolspace();
 31  1820
     String symbolspaceSubPackage = null;
 32  1820
     if (symbolspace == ISymbolspaces.TYPE) {
 33  964
       symbolspaceSubPackage = aComponent.getStringBindingAttribute(IBindingAttributes.TYPE_SUB_PACKAGE);
 34  856
     } else if (symbolspace == ISymbolspaces.ATTRIBUTE) {
 35  118
       symbolspaceSubPackage = aComponent.getStringBindingAttribute(IBindingAttributes.ATTRIBUTE_SUB_PACKAGE);
 36  118
       if (null == symbolspaceSubPackage) {
 37  118
         symbolspaceSubPackage = "attribute";
 38   
       }
 39  738
     } else if (symbolspace == ISymbolspaces.ELEMENT) {
 40  580
       symbolspaceSubPackage = aComponent.getStringBindingAttribute(IBindingAttributes.ELEMENT_SUB_PACKAGE);
 41  580
       if (null == symbolspaceSubPackage) {
 42  580
         symbolspaceSubPackage = "element";
 43   
       }
 44  158
     } else if (symbolspace == ISymbolspaces.ATTRIBUTE_GROUP) {
 45  88
       symbolspaceSubPackage = aComponent.getStringBindingAttribute(IBindingAttributes.ATTR_GROUP_SUB_PACKAGE);
 46  88
       if (null == symbolspaceSubPackage) {
 47  88
         symbolspaceSubPackage = "attrGroup";
 48   
       }
 49  70
     } else if (symbolspace == ISymbolspaces.ELEMENT_GROUP) {
 50  70
       symbolspaceSubPackage = aComponent.getStringBindingAttribute(IBindingAttributes.ELEM_GROUP_SUB_PACKAGE);
 51  70
       if (null == symbolspaceSubPackage) {
 52  70
         symbolspaceSubPackage = "elemGroup";
 53   
       }
 54   
     } else {
 55   
       assert false : "unexpected symbolspace: " + symbolspace;
 56   
     }
 57  1820
     addSubPackage(symbolspaceSubPackage);
 58   
 
 59  1820
     String bindingName = aComponent.getLocalStringBindingAttribute(IBindingAttributes.NAME);
 60  1820
     if (null == bindingName) {
 61  1820
       bindingName = aComponent.getName();
 62   
     }
 63  1820
     int idx = bindingName.lastIndexOf('.');
 64  1820
     if (idx >= 0) {
 65   
       // the sub package coming from the component name
 66  30
       addSubPackage(bindingName.substring(0, idx));
 67   
     }
 68   
 
 69   
   }
 70   
 
 71  3670
   protected void addSubPackage(String aSubPackage) {
 72  3670
     if ((null != aSubPackage) && !"".equals(aSubPackage)) {
 73  886
       myPackage = (null != myPackage) ? myPackage + "." + aSubPackage : aSubPackage;
 74   
     }
 75  3670
     myPackage = StringUtil.toJavaPackage(myPackage);
 76   
   }
 77   
 
 78  21635
   public String getPackage() {
 79  21635
     return myPackage;
 80   
   }
 81   
 
 82   
 }
 83