Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 55   Methods: 4
NCLOC: 37   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
MethodVariant.java 75% 86,7% 100% 85,2%
 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.StringUtil;
 13   
 import org.jbind.xml.core.cmp.ISourceInfo;
 14   
 import org.jbind.xml.msg.XmlException;
 15   
 import org.jbind.xml.msg.XmlMessages;
 16   
 
 17   
 public class MethodVariant {
 18   
 
 19  6282
   public static MethodVariant getMethodVariant(ISourceInfo aSourceInfo, String aName, String aDefault) throws XmlException {
 20  6282
     MethodVariant res = null;
 21  6282
     String s = aSourceInfo.getStringBindingAttribute(aName);
 22  6282
     if (null == s) {
 23  5648
       s = aDefault;
 24   
     }
 25  6282
     if ("normal".equals(s)) {
 26  2594
       res = MethodVariant.NORMAL;
 27  3688
     } else if ("hook".equals(s)) {
 28  0
       res = MethodVariant.HOOK;
 29  3688
     } else if ("none".equals(s)) {
 30  3688
       res = MethodVariant.NONE;
 31   
     } else {
 32  0
       throw new XmlException(XmlMessages.unknownPropertyVariant(s, aName, aSourceInfo));
 33   
     }
 34  6282
     return res;
 35   
   }
 36   
 
 37   
   public static final MethodVariant NORMAL = new MethodVariant(false);
 38   
   public static final MethodVariant HOOK = new MethodVariant(true);
 39   
   public static final MethodVariant NONE = new MethodVariant(false);
 40   
 
 41   
   private boolean myIsHook;
 42   
 
 43  9
   private MethodVariant(boolean anIsHook) {
 44  9
     myIsHook = anIsHook;
 45   
   }
 46   
 
 47  1199
   public String methodName(String aMethodNamePrefix, String aPropertyName) {
 48  1199
     return (myIsHook ? ("do" + StringUtil.firstUpper(aMethodNamePrefix)) : aMethodNamePrefix) + StringUtil.firstUpper(aPropertyName);
 49   
   }
 50   
 
 51  1199
   public String method(String aReturnType, String aMethodNamePrefix, String aPropertyName) {
 52  1199
     return (myIsHook ? "protected " : "public ") + aReturnType + " " + methodName(aMethodNamePrefix, aPropertyName);
 53   
   }
 54   
 }
 55