Coverage Report - org.kuali.student.contract.writer.service.ServiceExceptionWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceExceptionWriter
0%
0/38
N/A
1
 
 1  
 /*
 2  
  * Copyright 2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may        obtain a copy of the License at
 7  
  *
 8  
  *         http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.student.contract.writer.service;
 17  
 
 18  
 import org.kuali.student.contract.model.ServiceContractModel;
 19  
 import org.kuali.student.contract.model.ServiceMethodError;
 20  
 import org.kuali.student.contract.writer.JavaClassWriter;
 21  
 import org.kuali.student.contract.writer.JavaEnumConstantCalculator;
 22  
 
 23  
 /**
 24  
  *
 25  
  * @author nwright
 26  
  * @deprecated 
 27  
  */
 28  
 public class ServiceExceptionWriter extends JavaClassWriter
 29  
 {
 30  
 
 31  
  private ServiceContractModel model;
 32  
  private String directory;
 33  
  private String rootPackage;
 34  
  private ServiceMethodError error;
 35  
 
 36  
  public ServiceExceptionWriter (ServiceContractModel model,
 37  
                                 String directory,
 38  
                                 String rootPackage,
 39  
                                 ServiceMethodError error)
 40  
  {
 41  0
   super (directory, calcPackage (rootPackage), calcClassName (error.getType ()));
 42  0
   this.model = model;
 43  0
   this.directory = directory;
 44  0
   this.rootPackage = rootPackage;
 45  0
   this.error = error;
 46  0
  }
 47  
 
 48  
  public static String calcPackage (String rootPackage)
 49  
  {
 50  0
   return PureJavaInfcServiceWriter.calcPackage ("exception", rootPackage);
 51  
  }
 52  
 
 53  
  public static String calcClassName (String type)
 54  
  {
 55  0
   return new JavaEnumConstantCalculator (type).reverse () + "Exception";
 56  
  }
 57  
 
 58  
  /**
 59  
   * Write out the entire file
 60  
   * @param out
 61  
   */
 62  
  public void write ()
 63  
  {
 64  0
   String className = calcClassName (error.getType ());
 65  0
   indentPrintln ("public class " + className + " extends Exception");
 66  0
   openBrace ();
 67  0
   indentPrintln ("");
 68  0
          indentPrintln ("private static final long serialVersionUID = 1L;");
 69  0
   indentPrintln ("");
 70  0
   indentPrintln ("public " + className + "()");
 71  0
   openBrace ();
 72  0
   indentPrintln ("super ();");
 73  0
   closeBrace ();
 74  
 
 75  0
   indentPrintln ("");
 76  0
   indentPrintln ("public " + className + "(String msg)");
 77  0
   openBrace ();
 78  0
   indentPrintln ("super (msg);");
 79  0
   closeBrace ();
 80  
 
 81  0
   indentPrintln ("");
 82  0
   indentPrintln ("public " + className + "(Throwable cause)");
 83  0
   openBrace ();
 84  0
   indentPrintln ("super (cause);");
 85  0
   closeBrace ();
 86  
 
 87  0
   indentPrintln ("");
 88  0
   indentPrintln ("public " + className + "(String msg, Throwable cause)");
 89  0
   openBrace ();
 90  0
   indentPrintln ("super (msg, cause);");
 91  0
   closeBrace ();
 92  
 
 93  0
   indentPrintln ("");
 94  0
   closeBrace ();
 95  
 
 96  0
   this.writeJavaClassAndImportsOutToFile ();
 97  0
   this.getOut ().close ();
 98  0
  }
 99  
 
 100  
 }