//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.script.compiler;


public class CharDataGenerator extends GeneratorBase implements EvaluteMethodPhase
{
	char[] chars;
	// process in 32k chunks
	private static final int MAXSIZE = 32 * 1024;
	public CharDataGenerator(char[] chars)
	{
		this.chars = chars;
	}
	public void generate(ScriptWriter writer, Class phase)
	{
		writer.indent();
		int current = 0;
		int limit = chars.length;
		while (current < limit)
		{
			int from = current;
			int to = Math.min(current + MAXSIZE, limit);
			generateChunk(writer, from, to);
			current = to;
		}
	}
	private void generateChunk(ScriptWriter writer, int from, int to)
	{
		writer.printMultiLn(new String(chars, from, (to - from)));
	}
}
