Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 101   Methods: 10
NCLOC: 73   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
AbstractCartridge.java 94,4% 100% 90% 96,9%
 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.core.cmp.IBinding;
 13   
 import org.jbind.xml.core.cmp.IComponent;
 14   
 import org.jbind.xml.schema.cmp.ComponentVisitor;
 15   
 
 16   
 public abstract class AbstractCartridge extends ComponentVisitor implements ICartridge {
 17   
 
 18   
   private int myNumber;
 19   
 
 20  12
   public AbstractCartridge() {}
 21   
 
 22  36396
   public final int getCartridgeNo() {
 23  36396
     return myNumber;
 24   
   }
 25  12
   public final void setCartridgeNo(int aNumber) {
 26  12
     myNumber = aNumber;
 27   
   }
 28   
 
 29  0
   public void initCartridge(ICartridgeMgr aCartrigedMgr) {}
 30   
 
 31  1820
   public String getSubPackage() {
 32  1820
     return null;
 33   
   }
 34   
 
 35   
   /**
 36   
    * Converts a string into a valid java constant.
 37   
    *
 38   
    * @param aString <i>(required)</i>.
 39   
    * @return <i>(required)</i>.
 40   
    */
 41  69
   protected static String constant(String aString) {
 42  69
     StringBuffer sb = new StringBuffer();
 43  69
     boolean first = true;
 44  69
     boolean wasUpperCase = false;
 45  69
     for (int i = 0; i < aString.length(); i++) {
 46  315
       char c = aString.charAt(i);
 47  315
       if (first) {
 48  69
         if (!Character.isJavaIdentifierStart(c)) {
 49  28
           if (Character.isJavaIdentifierPart(c)) {
 50  20
             sb.append("_");
 51   
           } else {
 52  8
             c = '_';
 53   
           }
 54   
         }
 55   
       } else {
 56  246
         if (!Character.isJavaIdentifierPart(c)) {
 57  11
           c = '_';
 58   
         }
 59   
       }
 60  315
       if (!first && Character.isUpperCase(c) && !wasUpperCase) {
 61  1
         sb.append("_");
 62   
       }
 63  315
       sb.append(Character.toUpperCase(c));
 64  315
       wasUpperCase = Character.isUpperCase(c);
 65  315
       first = false;
 66   
     }
 67  69
     return sb.toString();
 68   
   }
 69   
 
 70  5959
   public String getUsableFqName(IComponent aComponent) {
 71  5959
     IBinding b = getBinding(aComponent);
 72  5959
     return (null != b) ? b.getFqName() : null;
 73   
   }
 74   
 
 75  461
   public String getNameForPackage(IComponent aComponent, String aPackage) {
 76  461
     if (null == aPackage) {
 77  97
       return getUsableFqName(aComponent);
 78   
     }
 79  364
     String res = null;
 80  364
     IBinding b = getBinding(aComponent);
 81  364
     if (null != b) {
 82  364
       if (aPackage.equals(b.getPackage())) {
 83  20
         res = b.getName('.');
 84   
       } else {
 85  344
         res = b.getFqName();
 86   
       }
 87   
     }
 88  364
     return res;
 89   
   }
 90   
 
 91  1313
   public String getInnerName(IComponent aComponent) {
 92  1313
     IBinding b = getBinding(aComponent);
 93  1313
     return b.getInnerName();
 94   
   }
 95   
 
 96  11170
   protected IBinding getBinding(IComponent aComponent) {
 97  11170
     IBinding[] bindings = aComponent.getBindings();
 98  11170
     return (null != bindings) ? bindings[getCartridgeNo()] : null;
 99   
   }
 100   
 }
 101