1 23 package org.hammurapi.inspectors.testcases.fixes; 24 25 import java.io.FileInputStream ; 26 import java.io.InputStream ; 27 28 import org.hammurapi.inspectors.testcases.HammurapiTestCasesException; 29 30 35 public class CodeTooLongRuleFixTestCase { 36 37 private static org.apache.log4j.Logger logger = 38 org.apache.log4j.Logger.getRootLogger(); 39 40 private static final String FILE_ERROR_TXT = "File error"; 41 private static final String CASE_TXT1 = "case 1"; 42 private static final String CASE_TXT2 = "case 2"; 43 private static final String CASE_TXT3 = "case 3"; 44 private static final int CASE_NBR1 = 1; 45 private static final int CASE_NBR2 = 2; 46 private static final int CASE_NBR3 = 3; 47 private static final int CASE_NBR4 = 4; 48 49 51 public int getByte(final String fName, final String which) 52 throws HammurapiTestCasesException { 53 54 if (CASE_TXT1.compareTo(which)==0) { 55 return getByte(fName, CASE_NBR1); 56 } else if (CASE_TXT2.compareTo(which)==0) { 57 return getByte(fName, CASE_NBR2); 58 } else if (CASE_TXT3.compareTo(which)==0) { 59 return getByte(fName, CASE_NBR3); 60 } else { 61 return getByte(fName, CASE_NBR4); 62 } 63 } 64 65 66 public int getByte(final String fName, final int nbr) 67 throws HammurapiTestCasesException { 68 69 try { 70 InputStream is = new FileInputStream (fName); 71 int c = 0; 72 int retVal = 0; 73 while (c<nbr) { 74 retVal = is.read(); 75 } 76 return retVal; 77 78 } catch (java.io.IOException e) { 79 logger.fatal(FILE_ERROR_TXT, e); 80 throw new HammurapiTestCasesException(e); 81 } 82 } 83 85 } 86 87 | Popular Tags |