summaryrefslogtreecommitdiffstats
path: root/conversion/ConvertFile.java
blob: 2cf62f361bdb9d026aedc04c0a2ea72f897ceb4d (plain) (blame)
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
30
31
32
33
34
35
36
package scruf.conversion;

import scruf.io.*;
import scruf.parsers.*;
import java.util.*;
import java.io.*;

public class ConvertFile {
    private List<Parser> parsers;
    private ReadFile readFile;
    public ConvertFile() {
	parsers = new ParserList().list();
    }
    public void convert(File file) {
	/**
	 * footer is optional, so it is null
	 * by default.
	 */
	PresentFile.footer = null;
	/**
	 * takes the present file reference
	 * for use outside this method.
	 */
	PresentFile.file = file;
	readFile = new ReadFile(file);
	String fileContent = readFile.getContent();
	// start conversion.
	for(Parser p:parsers) {
	    fileContent = p.parse(fileContent);
	}

	// Write converted file to respective html file.
	File outputFile = new File(file.getAbsolutePath()+".html");
	new WriteFile(outputFile,fileContent).write();
    }
}