org.sonar.api.batch.fs.internal
Class DefaultInputFile

java.lang.Object
  extended by org.sonar.api.batch.fs.internal.DefaultInputFile
All Implemented Interfaces:
Serializable, InputFile

public class DefaultInputFile
extends Object
implements InputFile, InputFile, Serializable

Since:
4.2
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.sonar.api.batch.fs.InputFile
InputFile.Status, InputFile.Type
 
Constructor Summary
DefaultInputFile(String relativePath)
           
 
Method Summary
 String absolutePath()
          Marked as nullable just for the unit tests that do not call setFile(java.io.File) previously.
 String deprecatedKey()
          Key used before version 4.2.
 boolean equals(Object o)
           
 File file()
          The underlying absolute File
 File getFile()
          Deprecated. in 4.2. Use file()
 File getFileBaseDir()
          Deprecated. in 4.2. Replaced by FileSystem.baseDir()
 InputStream getInputStream()
          Get an InputStream that reads from the file.
 String getRelativePath()
          Deprecated. in 4.2. Use relativePath()
 String hash()
          Digest hash of the file.
 int hashCode()
           
 String key()
          Component key.
 String language()
          Marked as nullable just for the unit tests that do not call setLanguage(String) previously.
 int lines()
          Number of physical lines.
 String pathRelativeToSourceDir()
          Used only for backward-compatibility.
 String relativePath()
          Path relative to module base directory.
 DefaultInputFile setAbsolutePath(String s)
           
 void setBasedir(File basedir)
           
 DefaultInputFile setDeprecatedKey(String s)
           
 DefaultInputFile setFile(File file)
           
 DefaultInputFile setHash(String hash)
           
 DefaultInputFile setKey(String s)
           
 DefaultInputFile setLanguage(String language)
           
 DefaultInputFile setLines(int lines)
           
 DefaultInputFile setPathRelativeToSourceDir(String s)
           
 DefaultInputFile setSourceDirAbsolutePath(String s)
           
 DefaultInputFile setStatus(InputFile.Status status)
           
 DefaultInputFile setType(InputFile.Type type)
           
 String sourceDirAbsolutePath()
          Used only for backward-compatibility.
 InputFile.Status status()
          Marked as nullable just for the unit tests that do not previously call setStatus(org.sonar.api.batch.fs.InputFile.Status)
 String toString()
           
 InputFile.Type type()
          Does it contain main or test code ?
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultInputFile

public DefaultInputFile(String relativePath)
Method Detail

relativePath

public String relativePath()
Description copied from interface: InputFile
Path relative to module base directory. Path is unique and identifies file within given FileSystem. File separator is the forward slash ('/'), even on Microsoft Windows.

Returns src/main/java/com/Foo.java if module base dir is /path/to/module and if file is /path/to/module/src/main/java/com/Foo.java.

Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').


absolutePath

@CheckForNull
public String absolutePath()
Marked as nullable just for the unit tests that do not call setFile(java.io.File) previously.


file

public File file()
Description copied from interface: InputFile
The underlying absolute File


language

@CheckForNull
public String language()
Marked as nullable just for the unit tests that do not call setLanguage(String) previously.


type

public InputFile.Type type()
Description copied from interface: InputFile
Does it contain main or test code ?


status

@CheckForNull
public InputFile.Status status()
Marked as nullable just for the unit tests that do not previously call setStatus(org.sonar.api.batch.fs.InputFile.Status)


hash

@CheckForNull
public String hash()
Digest hash of the file. Marked as nullable just for the unit tests that do not previously call setHash(String)


lines

public int lines()
Description copied from interface: InputFile
Number of physical lines. This method supports all end-of-line characters. Returns zero if the file is empty.


key

@CheckForNull
public String key()
Component key. It's marked as nullable just for the unit tests that do not previously call setKey(String).


setAbsolutePath

public DefaultInputFile setAbsolutePath(String s)

setLanguage

public DefaultInputFile setLanguage(String language)

setFile

public DefaultInputFile setFile(File file)

setType

public DefaultInputFile setType(InputFile.Type type)

setStatus

public DefaultInputFile setStatus(InputFile.Status status)

setHash

public DefaultInputFile setHash(String hash)

setLines

public DefaultInputFile setLines(int lines)

setKey

public DefaultInputFile setKey(String s)

deprecatedKey

public String deprecatedKey()
Key used before version 4.2. It can be different than key on Java files.


setDeprecatedKey

public DefaultInputFile setDeprecatedKey(String s)

sourceDirAbsolutePath

public String sourceDirAbsolutePath()
Used only for backward-compatibility. Meaningless since version 4.2.


setSourceDirAbsolutePath

public DefaultInputFile setSourceDirAbsolutePath(String s)

pathRelativeToSourceDir

public String pathRelativeToSourceDir()
Used only for backward-compatibility. Meaningless since version 4.2.


setPathRelativeToSourceDir

public DefaultInputFile setPathRelativeToSourceDir(String s)

getFileBaseDir

@Deprecated
public File getFileBaseDir()
Deprecated. in 4.2. Replaced by FileSystem.baseDir()

Description copied from interface: InputFile
The source base directory, different than the project basedir.

For example in maven projects, the basedir of a source file stored in src/main/java/org/foo/ is the directory src/main/java.

Specified by:
getFileBaseDir in interface InputFile

setBasedir

public void setBasedir(File basedir)

getFile

@Deprecated
public File getFile()
Deprecated. in 4.2. Use file()

Description copied from interface: InputFile
Get the underlying file.

Specified by:
getFile in interface InputFile
Returns:
the file

getRelativePath

@Deprecated
public String getRelativePath()
Deprecated. in 4.2. Use relativePath()

Description copied from interface: InputFile
Path relative to basedir. Directory separator is slash '/', whatever the platform.

Example on windows: if file basedir is c:\project\src\ and file is c:\project\src\org\foo\Bar.java, then relative path is org/foo/Bar.java

Example on unix: if file basedir is /project/src and file is /project/src/org/foo/Bar.java, then relative path is org/foo/Bar.java as well.

Specified by:
getRelativePath in interface InputFile

getInputStream

public InputStream getInputStream()
                           throws FileNotFoundException
Description copied from interface: InputFile
Get an InputStream that reads from the file.

The returned stream is buffered so there is no need to use a BufferedInputStream

Specified by:
getInputStream in interface InputFile
Returns:
the stream
Throws:
FileNotFoundException - if the file is not found

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2014 SonarSource. All Rights Reserved.