KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > inspectors > testcases > fixes > CodeTooLongRuleFixTestCase


1 /*
2  * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Hammurapi Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.hammurapi.org
21  * e-Mail: support@hammurapi.biz
22 */

23 package org.hammurapi.inspectors.testcases.fixes;
24
25 import java.io.FileInputStream JavaDoc;
26 import java.io.InputStream JavaDoc;
27
28 import org.hammurapi.inspectors.testcases.HammurapiTestCasesException;
29
30 /**
31  * CodeTooLongRule
32  * @author Pavel Vlasov
33  * @version $Revision: 1.1 $
34  */

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 JavaDoc FILE_ERROR_TXT = "File error";
41     private static final String JavaDoc CASE_TXT1 = "case 1";
42     private static final String JavaDoc CASE_TXT2 = "case 2";
43     private static final String JavaDoc 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     // --- FIX ---
50
/** Java doc automaticaly generated by Hammurapi */
51     public int getByte(final String JavaDoc fName, final String JavaDoc 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     /** Java doc automaticaly generated by Hammurapi */
66     public int getByte(final String JavaDoc fName, final int nbr)
67         throws HammurapiTestCasesException {
68             
69         try {
70             InputStream JavaDoc is = new FileInputStream JavaDoc(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 JavaDoc e) {
79             logger.fatal(FILE_ERROR_TXT, e);
80             throw new HammurapiTestCasesException(e);
81         }
82     }
83     // --- END FIX ---
84

85 }
86
87
Popular Tags