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

import java.util.List;

import org.eclipse.birt.report.model.core.DesignElement;
import org.eclipse.birt.report.model.core.Module;
import org.eclipse.birt.report.model.metadata.ElementRefValue;
import org.eclipse.birt.report.model.metadata.PropertyDefn;

/**
 * Abstract element name space in one module. Subclass must override one or more
 * resolve methods in this class. Otherwise, assertion error may occur.
 */

abstract class AbstractNameScope implements IModuleNameScope
{

	/**
	 * The module this name space is associated.
	 */

	protected Module module;

	/**
	 * The name space ID, which is the constants defined in
	 * {@link org.eclipse.birt.report.model.core.Module}.
	 */

	protected int nameSpaceID;

	/**
	 * Constructs the name space with module and name space ID.
	 * 
	 * @param module
	 *            the module this name space is assocaited.
	 * @param nameSpaceID
	 *            the ID of name space. The constants are defined in
	 *            {@link org.eclipse.birt.report.model.core.Module}.
	 */

	public AbstractNameScope( Module module, int nameSpaceID )
	{
		this.module = module;
		this.nameSpaceID = nameSpaceID;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.IModuleNameSpace#canContain(java.lang.String)
	 */

	public boolean canContain( String elementName )
	{
		return module.getNameSpace( nameSpaceID ).getElement( elementName ) == null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.namespace.IModuleNameSpace#getElements(int)
	 */

	public List getElements( int level )
	{
		assert false;
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.namespace.IModuleNameSpace#resolve(org.eclipse.birt.report.model.core.DesignElement,
	 *      org.eclipse.birt.report.model.metadata.PropertyDefn)
	 */

	public ElementRefValue resolve( DesignElement element, PropertyDefn propDefn )
	{
		assert false;
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.namespace.IModuleNameSpace#resolve(java.lang.String,
	 *      org.eclipse.birt.report.model.metadata.PropertyDefn)
	 */

	public ElementRefValue resolve( String elementName, PropertyDefn propDefn )
	{
		assert false;
		return null;
	}
}
