/*******************************************************************************
 * 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.elements;

import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.VariableElementHandle;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.birt.report.model.core.Module;

/**
 * 
 */
public class VariableElement extends ContentElement
{

	/**
	 * Default constructor.
	 */

	public VariableElement( )
	{

	}

	/**
	 * constructor
	 * 
	 * @param name
	 *            the element name.
	 */
	public VariableElement( String name )
	{
		this.name = name;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.birt.report.model.core.DesignElement#apply(org.eclipse.birt
	 * .report.model.elements.ElementVisitor)
	 */

	public void apply( ElementVisitor visitor )
	{
		visitor.visitVariableElement( this );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.DesignElement#getElementName()
	 */

	public String getElementName( )
	{
		return ReportDesignConstants.VARIABLE_ELEMENT;
	}

	/**
	 * Returns an API handle for this element.
	 * 
	 * @param module
	 *            the report design
	 * @return an API handle for this element
	 */

	public VariableElementHandle handle( Module module )
	{
		return new VariableElementHandle( module, this );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.birt.report.model.api.core.IDesignElement#getHandle(org.eclipse
	 * .birt.report.model.core.Module)
	 */

	public DesignElementHandle getHandle( Module module )
	{
		return handle( module );
	}

}

@@ -890,16 +890,65 @@
 ment%0A%7B%0A%0A
+%09protected VariableElementHandle handle = null;%0A%0A
 %09/**%0A%09 *
@@ -1819,22 +1819,232 @@
  )%0A%09%7B%0A%09%09
-return
+if ( handle == null )%0A%09%09%7B%0A%09%09%09Module root = getRoot( );%0A%09%09%09if ( root != null && root != module )%0A%09%09%09%09throw new IllegalArgumentException(%0A%09%09%09%09%09%09%22Illgal varialble element handle generation!%22 ); //$NON-NLS-1$%0A%09%09%09handle =
  new Var
@@ -2071,32 +2071,54 @@
 module, this );%0A
+%09%09%7D%0A%0A%09%09return handle;%0A
 %09%7D%0A%0A%09/*%0A%09 * (non

fix 308967 -- cache variable element handle.