/* ************************************************************************
#
#  DivConq
#
#  http://divconq.com/
#
#  Copyright:
#    Copyright 2012 eTimeline, LLC. All rights reserved.
#
#  License:
#    See the license.txt file in the project's top-level directory for details.
#
#  Authors:
#    * Andy White
#
************************************************************************ */
package divconq.db.query;

import divconq.struct.ListStruct;

/**
 * This is a collection of database fields to be selected by a query.  A selected
 * field may be formated and also may hold a subquery.
 * 
 * @author Andy
 *
 */
public class SelectFields {
	protected ListStruct fields = new ListStruct();
	
	/**
	 * @return the selected fields (uses an internal format)
	 */
	public ListStruct getFields() {
		return this.fields;
	}
	
	/**
	 * @param fields/subqueries to use as initial values for select
	 */
	public SelectFields(ISelectField... items) {
		this.addField(items);
	}	
	
	/**
	 * @param fields/subqueries to add to the select
	 */
	public void addField(ISelectField... items) {
		if (items != null)
			for (ISelectField itm : items)
				this.fields.addItem(itm.getParams());
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.fields.toString();
	}
}
