File: ExtractorFactory.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (29 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package tim.prune.function.filesleuth.extract;

import java.io.File;

public abstract class ExtractorFactory
{
	/** Use the filename extension to create an appropriate extractor */
	public static ContentExtractor createExtractor(File inFile)
	{
		String filename = (inFile == null ? null : inFile.getName().toLowerCase());
		if (filename == null || !filename.contains(".")) {
			return null;
		}
		if (filename.endsWith(".txt") || filename.endsWith(".csv")) {
			return new TextFileExtractor(inFile);
		}
		if (filename.endsWith(".gpx") || filename.endsWith(".kml")) {
			return new XmlFileExtractor(inFile);
		}
		if (filename.endsWith(".kmz") || filename.endsWith(".zip")) {
			return new ZipFileExtractor(inFile);
		}
		if (filename.endsWith(".gz")) {
			return new GzipFileExtractor(inFile);
		}
		// TODO: what about json / nmea?
		return null;
	}
}