Subversion Repositories bacoAlunos

Rev

Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
BERSERK - a BusinEss Runtime and SEcurity Resources Kit
Copyright (C) 2003 Goncalo Luiz

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 (at your option) 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

To contact Goncalo Luiz use the following e-mail address (use an @ instead of the _):
gedl_mega.ist.utl.pt
*/

/*
 * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
 *
 *
 * Created at 21/Out/2003 , 13:24:16
 *
 */

package pt.utl.ist.berserk.storage.digester.serviceManager;
import java.util.LinkedList;
import java.util.List;
import pt.utl.ist.berserk.logic.serviceManager.IServiceDefinition;
/**
 * An auxiliar class that helps reading service definition using Digester.<br/>
 * Provides rollback methods to Digester.
 * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
 *
 *
 * Created at 21/Out/2003 , 13:24:16
 *
 */

public class ServiceDefinitionProcessor
{
        private 1.5.0/docs/api/java/lang/String.html">String desiredName;
        private IServiceDefinition desiredServiceDefinition;
        private 5+0%2Fdocs%2Fapi+List">List desiredServices;
        /**
         * Default constructor required by Digester.
         *
         */

        public ServiceDefinitionProcessor()
        {
        }
        /**
         * Creates a <code>ServiceDefinitionProcessor</code> based on the name
         * @param name the name of the desired service definition
         */

        public ServiceDefinitionProcessor(1.5.0/docs/api/java/lang/String.html">String name)
        {
                this.desiredName = name;
        }
       
        /**
         * Gets the desired service definition
         * @return the read service definition
         */

        public IServiceDefinition getServiceDefinition()
        {
                return this.desiredServiceDefinition;
        }
        /**
         * Gets all the service definitions. Is called back when the <code>readAll</code> method is invoked
         * @see ServiceDefinitionDigester#readAll()
         * @return the list of services
         */

        public 5+0%2Fdocs%2Fapi+List">List getServiceDefinitions()
        {
                return this.desiredServices;
        }
       
        /**
         * Does a name-based check if <code>serviceDefinition</code> is the desired one
         * @param serviceDefinition the tested <code>serviceDefinition</code>
         */

        public void processByName(IServiceDefinition serviceDefinition)
        {
                if (this.desiredName.equals(serviceDefinition.getName()))
                {
                        this.desiredServiceDefinition = serviceDefinition;
                }
        }
        /**
         * Called back to add a new service definition to the list
         * @param service the whole list of read service definitions
         */

        public void addService(IServiceDefinition service)
        {
                if (this.desiredServices == null)
                        this.desiredServices = new 1.5.0/docs/api/java/util/LinkedList.html">LinkedList();
                this.desiredServices.add(service);
        }
}