001: /*
002: * Hammurapi
003: * Automated Java code review system.
004: * Copyright (C) 2004 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.org
021: * e-Mail: support@hammurapi.biz
022: */
023:
024: // --- VIOLATION ---
025: package org.hammurapi.inspectors.testcases.violations;
026:
027: import java.io.FileInputStream;
028: import java.io.InputStream;
029:
030: import org.hammurapi.inspectors.testcases.HammurapiTestCasesException;
031:
032: /**
033: * MaxLinesInFileRule
034: * @author Pavel Vlasov
035: * @version $Revision: 1.1 $
036: */
037: public class MaxLinesInFileRuleViolationTestCase {
038:
039: private static org.apache.log4j.Logger logger = org.apache.log4j.Logger
040: .getRootLogger();
041:
042: private static final String FILE_ERROR_TXT = "File error";
043:
044: /** Java doc automaticaly generated by Hammurapi */
045: public int getFirstByte(final String fName)
046: throws HammurapiTestCasesException {
047:
048: try {
049: InputStream is = new FileInputStream(fName);
050: return is.read();
051:
052: } catch (Exception e) {
053: logger.fatal(FILE_ERROR_TXT, e);
054: throw new HammurapiTestCasesException(e);
055: }
056: }
057:
058: /** Java doc automaticaly generated by Hammurapi */
059: public int getSecondByte(final String fName)
060: throws HammurapiTestCasesException {
061:
062: try {
063: InputStream is = new FileInputStream(fName);
064: is.read();
065: return is.read();
066:
067: } catch (Exception e) {
068: logger.fatal(FILE_ERROR_TXT, e);
069: throw new HammurapiTestCasesException(e);
070: }
071: }
072:
073: /** Java doc automaticaly generated by Hammurapi */
074: public int getThirdByte(final String fName)
075: throws HammurapiTestCasesException {
076:
077: try {
078: InputStream is = new FileInputStream(fName);
079: is.read();
080: is.read();
081: return is.read();
082:
083: } catch (Exception e) {
084: logger.fatal(FILE_ERROR_TXT, e);
085: throw new HammurapiTestCasesException(e);
086: }
087: }
088:
089: /** Java doc automaticaly generated by Hammurapi */
090: public int getFourthByte(final String fName)
091: throws HammurapiTestCasesException {
092:
093: try {
094: InputStream is = new FileInputStream(fName);
095: is.read();
096: is.read();
097: is.read();
098: return is.read();
099:
100: } catch (Exception e) {
101: logger.fatal(FILE_ERROR_TXT, e);
102: throw new HammurapiTestCasesException(e);
103: }
104: }
105: }
106: //--- END VIOLATION ---
|