001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2013 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.scan.filesystem.internal;
021    
022    import javax.annotation.CheckForNull;
023    import java.io.File;
024    import java.io.Serializable;
025    import java.util.Map;
026    
027    public interface InputFile extends Serializable {
028    
029      /**
030       * Canonical path of source directory.
031       * Example: <code>/path/to/module/src/main/java</code> or <code>C:\path\to\module\src\main\java</code>
032       */
033      String ATTRIBUTE_SOURCEDIR_PATH = "SRC_DIR_PATH";
034    
035      /**
036       * Relative path from source directory. File separator is the forward slash ('/'),
037       * even on MSWindows.
038       */
039      String ATTRIBUTE_SOURCE_RELATIVE_PATH = "SRC_REL_PATH";
040    
041      /**
042       * Detected language
043       */
044      String ATTRIBUTE_LANGUAGE = "LANG";
045    
046      /**
047       *
048       */
049      String ATTRIBUTE_TYPE = "TYPE";
050      String TYPE_SOURCE = "SOURCE";
051      String TYPE_TEST = "TEST";
052    
053      String ATTRIBUTE_STATUS = "STATUS";
054      String STATUS_SAME = "SAME";
055      String STATUS_CHANGED = "CHANGED";
056      String STATUS_ADDED = "ADDED";
057    
058      String ATTRIBUTE_HASH = "HASH";
059    
060    
061      /**
062       * Path is relative from module base directory. Path is unique and identifies file
063       * within given <code>{@link org.sonar.api.scan.filesystem.ModuleFileSystem}</code>.
064       * File separator is the forward slash ('/'), even on MSWindows.
065       * <p/>
066       * Returns <code>src/main/java/com/Foo.java</code> if module base dir is
067       * <code>/absolute/path/to/module</code> and if file is
068       * <code>/absolute/path/to/module/src/main/java/com/Foo.java</code>.
069       * <p/>
070       * Returned path is never null.
071       */
072      String path();
073    
074      /**
075       * Not-null canonical path. File separator is forward slash ('/'), even on MSWindows.
076       */
077      String absolutePath();
078    
079      File file();
080    
081      /**
082       * Not-null filename, including extension
083       */
084      String name();
085    
086      /**
087       * Not-null type (is it a source file or a unit test file?).
088       * See constant values prefixed by <code>TYPE_</code>, for example {@link #TYPE_SOURCE}.
089       */
090      String type();
091    
092      /**
093       * Does the given attribute have the given value ?
094       */
095      boolean has(String attribute, String value);
096    
097      /**
098       * See list of attribute keys in constants starting with ATTRIBUTE_.
099       */
100      @CheckForNull
101      String attribute(String key);
102    
103      Map<String, String> attributes();
104    }