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

import org.eclipse.birt.report.model.core.DesignElement;
import org.eclipse.birt.report.model.elements.ReportDesign;
import org.xml.sax.SAXException;

/**
 * Back compatible for ReportDesign.msgBaseName property.
 * 
 * <pre>
 *  
 *  Old design file:
 *  
 *  &lt;Property name=&quot;msgBaseName&quot;&gt;message.properties &lt;/Property&gt; 
 *  
 *  New design file:
 *  
 *  &lt;Property name=&quot;includeResource&quot;&gt;message.properties &lt;/Property&gt;
 */

public class CompatibleReportPropertyState extends PropertyState
{

	private static final String MSG_BASE_NAME_PROP = "msgBaseName"; //$NON-NLS-1$

	/**
	 * Constructor
	 * 
	 * @param theHandler
	 *            the design file parser handler
	 * @param element
	 *            the element which holds this property
	 */

	CompatibleReportPropertyState( ModuleParserHandler theHandler,
			DesignElement element )
	{
		super( theHandler, element );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.util.AbstractParseState#end()
	 */

	public void end( ) throws SAXException
	{
		if ( MSG_BASE_NAME_PROP.equalsIgnoreCase( name ) )
		{
			String value = text.toString( );
			
			setProperty( ReportDesign.INCLUDE_RESOURCE_PROP, value );
			
			return;
		}

		super.end( );
	}

}
