net.sourceforge.pmd.lang

## Class LanguageVersionDiscoverer

- java.lang.Object
- - net.sourceforge.pmd.lang.LanguageVersionDiscoverer

    public class LanguageVersionDiscoverer
    extends Object

This class can discover the LanguageVersion of a source file. Further, every Language has a default LanguageVersion, which can be temporarily overridden here.

### Constructor Summary

Constructors
Constructor and Description
`LanguageVersionDiscoverer()`

### Method Summary

Methods
`LanguageVersion` `getDefaultLanguageVersion(Language language)` Get the current default LanguageVersion for the given Language.
`LanguageVersion` `getDefaultLanguageVersionForFile(File sourceFile)` Get the default LanguageVersion for the first Language of a given source file.
`LanguageVersion` `getDefaultLanguageVersionForFile(String fileName)` Get the LanguageVersion for the first Language of a source file with the given name.
`List<Language>` `getLanguagesForFile(File sourceFile)` Get the Languages of a given source file.
`List<Language>` `getLanguagesForFile(String fileName)` Get the Languages of a given source file.
`LanguageVersion` `setDefaultLanguageVersion(LanguageVersion languageVersion)` Set the given LanguageVersion as the current default for it's Language.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### LanguageVersionDiscoverer

    public LanguageVersionDiscoverer()

### Method Detail

#### setDefaultLanguageVersion

    public LanguageVersion setDefaultLanguageVersion(LanguageVersion languageVersion)

Set the given LanguageVersion as the current default for it's Language.

Parameters:
  `languageVersion` - The new default for the Language.
Returns:
  The previous default version for the language.

#### getDefaultLanguageVersion

    public LanguageVersion getDefaultLanguageVersion(Language language)

Get the current default LanguageVersion for the given Language.

Parameters:
  `language` - The Language.
Returns:
  The current default version for the language.

#### getDefaultLanguageVersionForFile

    public LanguageVersion getDefaultLanguageVersionForFile(File sourceFile)

Get the default LanguageVersion for the first Language of a given source file.

Parameters:
  `sourceFile` - The file.
Returns:
  The currently configured LanguageVersion for the source file, or `null` if there are no supported Languages for the file.

#### getDefaultLanguageVersionForFile

    public LanguageVersion getDefaultLanguageVersionForFile(String fileName)

Get the LanguageVersion for the first Language of a source file with the given name.

Parameters:
  `fileName` - The file name.
Returns:
  The currently configured LanguageVersion for the source file or `null` if there are no supported Languages for the file.

#### getLanguagesForFile

    public List<Language> getLanguagesForFile(File sourceFile)

Get the Languages of a given source file.

Parameters:
  `sourceFile` - The file.
Returns:
  The Languages for the source file, may be empty.

#### getLanguagesForFile

    public List<Language> getLanguagesForFile(String fileName)

Get the Languages of a given source file.

Parameters:
  `fileName` - The file name.
Returns:
  The Languages for the source file, may be empty.