/*******************************************************************************
 * 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.report.model.script;

import java.util.Map;

import org.mozilla.javascript.ScriptableObject;

/**
 * Represents the scriptable object for <code>ReportDesignHandle</code>.
 * 
 * @see org.eclipse.birt.report.model.api.ReportDesignHandle
 */

public class NativeReport extends ScriptableObject
{

	/**
	 * Class name in JavaScript.
	 */

	public static final String CLASS_NAME = "Report"; //$NON-NLS-1$

	/**
	 * The cached report instance.
	 */

	private Report report = null;

	/**
	 * The zero-argument constructor used by Rhino runtime to create instances
	 */

	public NativeReport( )
	{
	}

	/**
	 * JavaScript function that is the constructor .
	 * 
	 * @param report
	 *            a report instance
	 */

	public void jsConstructor( Object report )
	{
		assert report instanceof Report;
		this.report = (Report) report;
	}

	/**
	 * Returns the configuration variables bound with the report design.
	 * 
	 * @return the configuration variables bound with the report design.
	 */

	public Map jsGet_config( )
	{
		return this.report.getConfig( );
	}

	/**
	 * Returns a <code>ReportDefinition</code> object that describes the
	 * design of the report.
	 * 
	 * @return a <code>ReportDefinition</code> object that describes the
	 *         design of the report.
	 */

	public ReportDefinition jsGet_design( )
	{
		return this.report.getDesign( );
	}
    

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.mozilla.javascript.Scriptable#getClassName()
	 */

	public String getClassName( )
	{
		return CLASS_NAME;
	}
}