001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube 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 * SonarQube 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 License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.api.batch.fs;
021
022 import java.io.File;
023 import java.io.Serializable;
024
025 /**
026 * This layer over {@link java.io.File} adds information for code analyzers.
027 *
028 * @since 4.2
029 */
030 public interface InputFile extends Serializable {
031
032 enum Type {
033 MAIN, TEST
034 }
035
036 /**
037 * Status regarding previous analysis
038 */
039 enum Status {
040 SAME, CHANGED, ADDED
041 }
042
043 /**
044 * Path relative to module base directory. Path is unique and identifies file
045 * within given <code>{@link FileSystem}</code>. File separator is the forward
046 * slash ('/'), even on Microsoft Windows.
047 * <p/>
048 * Returns <code>src/main/java/com/Foo.java</code> if module base dir is
049 * <code>/path/to/module</code> and if file is
050 * <code>/path/to/module/src/main/java/com/Foo.java</code>.
051 * <p/>
052 * Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').
053 */
054 String relativePath();
055
056 /**
057 * Normalized absolute path. File separator is forward slash ('/'), even on Microsoft Windows.
058 * <p/>
059 * This is not canonical path. Symbolic links are not resolved. For example if /project/src links
060 * to /tmp/src and basedir is /project, then this method returns /project/src/index.php. Use
061 * {@code file().getCanonicalPath()} to resolve symbolic link.
062 */
063 String absolutePath();
064
065 /**
066 * The underlying absolute {@link java.io.File}
067 */
068 File file();
069
070 /**
071 * Language, for example "java" or "php". It's automatically guessed if it is not
072 * set in project settings.
073 */
074 String language();
075
076 /**
077 * Does it contain main or test code ?
078 */
079 Type type();
080
081 /**
082 * Status regarding previous analysis
083 */
084 Status status();
085
086 /**
087 * Number of physical lines. This method supports all end-of-line characters. Returns
088 * zero if the file is empty.
089 */
090 int lines();
091 }