/* MultiComposer.java

	Purpose:
		
	Description:
		
	History:
		Tue Dec 26 08:48:59 TST 2010, Created by Ashish Dasnurkar

Copyright (C) 2010 Potix Corporation. All Rights Reserved.

*/

package org.zkoss.zss.jsp.ui;

import java.io.Serializable;

import org.zkoss.lang.Classes;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.Composer;

/**
 * @author ashish
 *
 */
/*package*/class MultiComposer  implements Composer, Serializable {
	private static final long serialVersionUID = 1L;
	private final Composer[] _cs;
		/*package*/MultiComposer(Object[] cs) throws Exception {
			if (cs instanceof Composer[]) {
				_cs = (Composer[])cs;
			} else {
				_cs = new Composer[cs.length];
				for (int j = cs.length; --j >=0;) {
					final Object o = cs[j];
					_cs[j] = (Composer)(
						o instanceof String ?
							Classes.newInstanceByThread(((String)o).trim()):
						o instanceof Class ?
							((Class)o).newInstance(): (Composer)o);
				}
			}
		}
		public void doAfterCompose(Component comp) throws Exception {
			for (int j = 0; j < _cs.length; ++j)
				_cs[j].doAfterCompose(comp);
		}
}
