001package Torello.Browser.JsonAST;
002
003import static Torello.Java.C.BYELLOW;
004import static Torello.Java.C.RESET;
005
006import Torello.Java.FileRW;
007
008import Torello.HTML.Balance;
009import Torello.HTML.HTMLPage;
010
011import java.io.IOException;
012
013/** Iterates both trees - the "Browser Protocol" and the "Java Script Protocol" */
014@Torello.JavaDoc.Annotations.StaticFunctional
015@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="TOHTML_JDHBI")
016public class WriteBothHTMLFiles
017{
018    private WriteBothHTMLFiles() { }
019
020    static void write(
021            final String    ROOT_DIR,
022            final API       browser,
023            final API       js
024        )
025        throws IOException
026    {
027        String html, report;
028
029        html = HTML$API.run(js);
030        System.out.println("Writing File: " + BYELLOW + ROOT_DIR + "js.html" + RESET);
031        FileRW.writeFile(html,  ROOT_DIR + "js.html");
032
033        report = Balance.toStringBalance
034            (Balance.checkNonZero(Balance.check(HTMLPage.getPageTokens(html, false))));
035        System.out.println("Balance Report:\n" + report);
036
037        html = HTML$API.run(browser);
038        System.out.println("Writing File: " + BYELLOW + ROOT_DIR + "browser.html" + RESET);
039        FileRW.writeFile(html, ROOT_DIR + "browser.html");
040
041        report = Balance.toStringBalance
042            (Balance.checkNonZero(Balance.check(HTMLPage.getPageTokens(html, false))));
043        System.out.println("Balance Report:\n" + report);
044
045    }
046}