package org.apache.maven.hibernate.jelly;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * ====================================================================
 */

import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.hibernate.beans.CodeGenerationBean;

/**
 * @author <a href="paulkearney@gmail.com">Paul Kearney</a> 
 * @version $Id$
 */
public class CodeGenerationTag extends TagSupport {
    
	private CodeGenerationBean bean = new CodeGenerationBean();

	/**
	 * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
	 */
	public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException {

		execute();
	}

	/**
	 *  
	 */
	protected void execute() throws JellyTagException 
	{
		try {
			bean.execute();
		} catch (Exception e) {
			String msg = "Code generation operation failed";			
			throw new JellyTagException(msg, e);
		}
	}
	
	public String getBasedir()
    {
        return bean.getBasedir();
    }

    public String getExcludes()
    {
        return bean.getExcludes();
    }

    public String getIncludes()
    {
        return bean.getIncludes();
    }
    
    public String getOutputdir() 
    {
    	return bean.getOutputdir();
    }

    public void setBasedir(String string)
    {
        bean.setBasedir(string);
    }
	
	public void setExcludes(String string)
    {
        bean.setExcludes(string);
    }

    public void setIncludes(String string)
    {
        bean.setIncludes(string);
    }
    
    public void setOutputdir(String dir) 
    {
    	bean.setOutputdir(dir);
    }
    
    public String toString()
    {
        return bean.toString();
    }
}
