/*
 * Copyright (C) 2004-2005  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.exedio.cope;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

public final class StatementInfo
{
	private ArrayList childs;
	final String text;
	
	StatementInfo(final String text)
	{
		this.text = text;
	}
	
	public String getText()
	{
		return text;
	}
	
	public Collection getChilds()
	{
		return
			childs==null
			? Collections.EMPTY_LIST
			: Collections.unmodifiableList(childs);
	}
	
	void addChild(final StatementInfo newChild)
	{
		if(childs==null)
			childs = new ArrayList();

		childs.add(newChild);
	}
	
	public void print(final PrintStream o)
	{
		print(o, 0);
	}

	private void print(final PrintStream o, int level)
	{
		for(int i=0; i<level; i++)
			o.print("  ");
		o.println(text);
		level++;
		for(Iterator i = childs.iterator(); i.hasNext(); )
			((StatementInfo)i.next()).print(o, level);
	}

}

@@ -1026,16 +1026,33 @@
 t childs
+LazilyInitialized
 ;%0A%09final
@@ -1225,24 +1225,41 @@
 rn%0A%09%09%09childs
+LazilyInitialized
 ==null%0A%09%09%09? 
@@ -1321,16 +1321,33 @@
 t(childs
+LazilyInitialized
 );%0A%09%7D%0A%09%0A
@@ -1409,25 +1409,59 @@
 ilds
-==null)%0A%09%09%09childs
+LazilyInitialized==null)%0A%09%09%09childsLazilyInitialized
  = n
@@ -1485,16 +1485,33 @@
 %09%09childs
+LazilyInitialized
 .add(new
@@ -1742,16 +1742,33 @@
 = childs
+LazilyInitialized
 .iterato

rename childs to childsLazilyInitialized