/*
 *************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *  
 *************************************************************************
 */ 
package org.eclipse.birt.data.engine.api.querydefn;

import java.util.List;

import org.eclipse.birt.core.data.DataType;
import org.eclipse.birt.data.engine.api.IBaseExpression;
import org.eclipse.birt.data.engine.api.IComputedColumn;
import org.eclipse.birt.data.engine.api.IScriptExpression;

/**
 * Default implementation of {@link org.eclipse.birt.data.engine.api.IComputedColumn} interface.<p>
 */
public class ComputedColumn implements IComputedColumn
{
    protected String name;
	protected IBaseExpression expr;
	protected int dataType;
	private String aggrFuntion;
	private List argument;
	private IScriptExpression filter;
	private int positionHint = -1;
    
	/**
	 * @param name
	 * @param expr
	 */
    public ComputedColumn( String name, String expr )
	{
		this.name = name;
		this.expr = new ScriptExpression( expr );
		this.dataType = DataType.ANY_TYPE;
		this.aggrFuntion = null;
    }
    
    /**
     * Constructs a new computed column with specified name and expression
     * @param name Name of computed column
     * @param expr Expression of computed column
     * @param dataType data Type of computed column
     */
    public ComputedColumn( String name, String expr, int dataType )
	{
		this.name = name;
		this.expr = new ScriptExpression(expr);
		this.dataType = dataType;
		this.aggrFuntion = null;
    }
    
    /**
     * @param name
     * @param expr
     * @param dataType
     * @param aggrFunction
     */
    public ComputedColumn( String name, String expr, int dataType, String aggrFunction, IScriptExpression filter, List argument  )
    {
    	this.name = name;
		this.expr = expr != null ? new ScriptExpression( expr ) : null;
		this.dataType = dataType;
		this.aggrFuntion = aggrFunction;
		this.argument = argument;
		this.filter = filter;
    }
    
    public ComputedColumn( String name, IScriptExpression expr, int dataType, String aggrFunction, IScriptExpression filter, List argument  )
    {
    	this.name = name;
		this.expr = expr;
		this.dataType = dataType;
		this.aggrFuntion = aggrFunction;
		this.argument = argument;
		this.filter = filter;
    }
    /*
     *  (non-Javadoc)
     * @see org.eclipse.birt.data.engine.api.IComputedColumn#getName()
     */
    public String getName()
    {
        return name;
    }

    /*
     *  (non-Javadoc)
     * @see org.eclipse.birt.data.engine.api.IComputedColumn#getExpression()
     */
    public IBaseExpression getExpression()
    {
        return expr;
    }

    /*
     *  (non-Javadoc)
     * @see org.eclipse.birt.data.engine.api.IComputedColumn#getDataType()
     */
	public int getDataType( )
	{
		return this.dataType;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.birt.data.engine.api.IComputedColumn#getAggregateFunction()
	 */
	public String getAggregateFunction( )
	{
		return this.aggrFuntion;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.birt.data.engine.api.IComputedColumn#getAggregateArgument()
	 */
	public List getAggregateArgument( )
	{
		return this.argument;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.birt.data.engine.api.IComputedColumn#getAggregateFilter()
	 */
	public IScriptExpression getAggregateFilter( )
	{
		return this.filter;
	}
	
	public void setPositionHint( int positionHint )
	{
		this.positionHint = positionHint;
	}
	
	public int getPositionHint( )
	{
		return this.positionHint;
	}
}

@@ -1160,40 +1160,8 @@
 er;%0A
-%09private int positionHint = -1;%0A
     
@@ -3675,166 +3675,6 @@
 %0A%09%7D%0A
-%09%0A%09public void setPositionHint( int positionHint )%0A%09%7B%0A%09%09this.positionHint = positionHint;%0A%09%7D%0A%09%0A%09public int getPositionHint( )%0A%09%7B%0A%09%09return this.positionHint;%0A%09%7D%0A
 %7D%0A

Enhance join pushdown logic