001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar 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 GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020package org.sonar.api.resources; 021 022import java.io.File; 023import java.io.FileNotFoundException; 024import java.io.InputStream; 025 026/** 027 * @since 2.6 028 */ 029public interface InputFile { 030 /** 031 * The source base directory, different than the project basedir. 032 * 033 * <p>For example in maven projects, the basedir of a source file stored in 034 * <code>src/main/java/org/foo/</code> is the directory <code>src/main/java</code>.</p> 035 */ 036 File getFileBaseDir(); 037 038 /** 039 * Get the underlying file. 040 * 041 * @return the file 042 */ 043 File getFile(); 044 045 /** 046 * Path relative to basedir. Directory separator is slash <code>'/'</code>, whatever the platform. 047 * 048 * <p>Example on windows: if file basedir is <code>c:\project\src\</code> and file is <code>c:\project\src\org\foo\Bar.java</code>, then relative path 049 * is <code>org/foo/Bar.java</code></p> 050 * 051 * <p>Example on unix: if file basedir is <code>/project/src</code> and file is <code>/project/src/org/foo/Bar.java</code>, then relative path 052 * is <code>org/foo/Bar.java</code> as well.</p> 053 */ 054 String getRelativePath(); 055 056 /** 057 * Get an {@link InputStream} that reads from the file. 058 * 059 * <p>The returned stream is buffered so there is no need to use a 060 * <code>BufferedInputStream</code></p> 061 * 062 * @return the stream 063 * @throws FileNotFoundException if the file is not found 064 * @since 3.1 065 */ 066 InputStream getInputStream() throws FileNotFoundException; 067}