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

import java.util.*;

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

  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = NL + "function init(){" + NL + "" + NL + "}" + NL;
  protected final String TEXT_2 = NL;
  protected final String TEXT_3 = NL;
  protected final String TEXT_4 = NL;

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