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

import java.util.*;

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

  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<?xml version=\"1.0\" encoding=\"SHIFT_JIS\" ?>" + NL + "<letAjaxHtml>" + NL;
  protected final String TEXT_2 = NL + "    ";
  protected final String TEXT_3 = NL + "    </letsAjaxBody>" + NL + "    " + NL + "</letAjaxHtml>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     List bodyList = (List) ((Map)argument).get("bodyList"); 
       for (Iterator iter = bodyList.iterator(); iter.hasNext(); ) { 
    stringBuffer.append(TEXT_2);
    stringBuffer.append( iter.next() );
       }  
    stringBuffer.append(TEXT_3);
    return stringBuffer.toString();
  }
}
