/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * Initial developer(s): Philippe Durieux
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
*/


package org.objectweb.jonas_ejb.deployment.api;

import java.lang.Class;

import org.objectweb.jonas_ejb.deployment.xml.EjbLocalRef;

/**
 * Class that represents an ejb-local-ref tag.
 */
public class EjbLocalRefDesc {

    String name;
    String localhome;
    String local;
    String ejblink;

    /**
     * Package protected constructor used by API
     */
    EjbLocalRefDesc(EjbLocalRef lr) throws DeploymentDescException {
        name = lr.getEjbRefName().getValue();
	localhome = lr.getLocalHome().getValue();
	local = lr.getLocal().getValue();
	if (lr.getEjbLink() == null) {
	    throw new DeploymentDescException("ejb-link missing for ejb-local-ref "+name);
	}
	ejblink = lr.getEjbLink().getValue();
    }

    /**
     * Get the name of the ejb-ref 
     * @return String representation of the name.
     */
    public String getName() {
            return name;
    }

    /**
     * Get the LocalHome class of the target bean
     * @return String representation of the class.
     */
    public String getLocalHome() {
            return localhome;
    }

    /**
     * Get the Local class of the target bean
     * @return String representation of the class.
     */
    public String getLocal() {
            return local;
    }

    /**
     * Get the ejb-link
     * @return String representation of the ejb-link
     */
    public String getEjbLink() {
            return ejblink;
    }

    
    /**
     * String representation of the object for test purpose
     * @return String representation of this object
     */
    public String toString() {
        StringBuffer ret = new StringBuffer();
        ret.append("\ngetName()="+getName());
        ret.append("\ngetLocalHome()="+getLocalHome());
        ret.append("\ngetLocal()="+getLocal());
        ret.append("\ngetEjbLink()="+getEjbLink());
        return ret.toString();
    }
    
    
}

