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    
024    /**
025     * This layer over {@link java.io.File} adds information for code analyzers.
026     *
027     * @since 4.2
028     */
029    public interface InputFile extends InputPath {
030    
031      enum Type {
032        MAIN, TEST
033      }
034    
035      /** 
036       * Status regarding previous analysis
037       */
038      enum Status {
039        SAME, CHANGED, ADDED
040      }
041    
042      /**
043       * Path relative to module base directory. Path is unique and identifies file
044       * within given <code>{@link FileSystem}</code>. File separator is the forward
045       * slash ('/'), even on Microsoft Windows.
046       * <p/>
047       * Returns <code>src/main/java/com/Foo.java</code> if module base dir is
048       * <code>/path/to/module</code> and if file is
049       * <code>/path/to/module/src/main/java/com/Foo.java</code>.
050       * <p/>
051       * Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').
052       */
053      @Override
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      @Override
064      String absolutePath();
065    
066      /**
067       * The underlying absolute {@link java.io.File}
068       */
069      @Override
070      File file();
071    
072      /**
073       * Language, for example "java" or "php". It's automatically guessed if it is not
074       * set in project settings.
075       */
076      String language();
077    
078      /**
079       * Does it contain main or test code ?
080       */
081      Type type();
082    
083      /**
084       * Status regarding previous analysis
085       */
086      Status status();
087    
088      /**
089       * Number of physical lines. This method supports all end-of-line characters. Returns
090       * zero if the file is empty.
091       */
092      int lines();
093    }