package com.brilliance.isc.swift.swifteditor;

import com.brilliance.isc.swift.swifteditor.tag.message.MessageFormat;
import com.brilliance.isc.swift.swifteditor.tag.message.SWFMessage;
import junit.framework.TestCase;
import org.apache.commons.io.IOUtils;

import java.io.*;


public class SwitfMessagePattern extends TestCase {

    private void  genPattern(String mty) throws IOException {
        SWFMessage swfMessage = MessageFormat.getSWFMessage(mty);
        String json = swfMessage.toFormatJSON();
        System.out.println("--------------------------------");
        json = "const Tags = "+json+"\r\n\r\n"+"const Title = \""+swfMessage.getName()+"\"\r\n\r\n";
        json = json+ "export default { Tags,Title}";
        // System.out.println(json);
        File targetJs = new File("d:/SwiftMT");
        if(!targetJs.exists())
            targetJs.mkdirs();
        targetJs = new File(targetJs,"MT"+mty+".js");
        if(!targetJs.exists())
            targetJs.createNewFile();
        FileWriter writer = new FileWriter(targetJs);
        IOUtils.write(json,writer);
        IOUtils.closeQuietly(writer);
    }

    public void testGen202() throws IOException {
        genPattern("202");
    }
    public void testGen103() throws IOException {
        genPattern("103");
    }
    public void testGen566() throws IOException {
        genPattern("535");
    }
    public void testGen775761() throws IOException {
        genPattern("775");
        genPattern("761");
    }
}
