package jp.co.cybec.laxide.file.template;

import java.util.*;

public class LetsAjaxPlainLayoutTemplate
{
  protected static String nl;
  public static synchronized LetsAjaxPlainLayoutTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    LetsAjaxPlainLayoutTemplate result = new LetsAjaxPlainLayoutTemplate();
    nl = null;
    return result;
  }

  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = NL + "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" + NL + "<html>" + NL + "<head>";
  protected final String TEXT_2 = NL + "    ";
  protected final String TEXT_3 = NL + "    <script type='text/javascript' src='";
  protected final String TEXT_4 = "'></script>";
  protected final String TEXT_5 = NL + "    <link rel=\"stylesheet\" href=\"";
  protected final String TEXT_6 = "\" type=\"text/css\">";
  protected final String TEXT_7 = "  " + NL + "</head>";
  protected final String TEXT_8 = NL + "    ";
  protected final String TEXT_9 = NL + "    ";
  protected final String TEXT_10 = NL + NL + "    </body>" + NL + "</html>";
  protected final String TEXT_11 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     List headList = (List) ((Map)argument).get("headTagList"); 
       for (Iterator iter = headList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_2);
    stringBuffer.append( iter.next() );
       } 
     List scriptNameList = (List) ((Map)argument).get("scriptNameList"); 
     for (Iterator iter = scriptNameList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_3);
    stringBuffer.append( iter.next() );
    stringBuffer.append(TEXT_4);
     } 
     List cssList = (List) ((Map)argument).get("cssNameList"); 
     for (Iterator iter = cssList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_5);
    stringBuffer.append( iter.next() );
    stringBuffer.append(TEXT_6);
     } 
    stringBuffer.append(TEXT_7);
     List bodyList = (List) ((Map)argument).get("bodyTag"); 
       for (Iterator iter = bodyList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_8);
    stringBuffer.append( iter.next() );
       }  
     List contentsList = (List) ((Map)argument).get("contents"); 
       for (Iterator iter = contentsList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_9);
    stringBuffer.append( iter.next() );
       }  
    stringBuffer.append(TEXT_10);
    stringBuffer.append(TEXT_11);
    return stringBuffer.toString();
  }
}
