View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.cpd;
5   
6   import java.io.FilenameFilter;
7   import java.util.Arrays;
8   import java.util.List;
9   import java.util.Properties;
10  
11  import net.sourceforge.pmd.util.filter.Filters;
12  
13  public abstract class AbstractLanguage implements Language {
14      private final String name;
15      private final String terseName;
16  	private final Tokenizer tokenizer;
17  	private final FilenameFilter fileFilter;
18  	private final List<String> extensions;
19  
20  	public AbstractLanguage(String name, String terseName, Tokenizer tokenizer, String... extensions) {
21  	    this.name = name;
22  	    this.terseName = terseName;
23  		this.tokenizer = tokenizer;
24  		fileFilter = Filters.toFilenameFilter(Filters.getFileExtensionOrDirectoryFilter(extensions));
25  		this.extensions = Arrays.asList(extensions);
26  	}
27  
28  	public FilenameFilter getFileFilter() {
29  		return fileFilter;
30  	}
31  
32  	public Tokenizer getTokenizer() {
33  		return tokenizer;
34  	}
35  
36  	public void setProperties(Properties properties) {
37  	    // needs to be implemented by subclasses.
38  	}
39  
40  	public String getName() {
41  	    return name;
42  	}
43  
44  	public String getTerseName() {
45  	    return terseName;
46  	}
47  
48  	public List<String> getExtensions() {
49  	    return extensions;
50  	}
51  }