001    /* EVolve - an Extensible Software Visualization Framework
002     * Copyright (C) 2001-2002 Qin Wang
003     *
004     * This library is free software; you can redistribute it and/or
005     * modify it under the terms of the GNU Library General Public
006     * License as published by the Free Software Foundation; either
007     * version 2 of the License, or (at your option) any later version.
008     *
009     * This library is distributed in the hope that it will be useful,
010     * but WITHOUT ANY WARRANTY; without even the implied warranty of
011     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012     * Library General Public License for more details.
013     *
014     * You should have received a copy of the GNU Library General Public
015     * License along with this library; if not, write to the
016     * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017     * Boston, MA 02111-1307, USA.
018     */
019    
020    /*
021     * EVolve is distributed at http://www.sable.mcgill.ca/EVolve/
022     */
023    
024    package EVolve.data;
025    
026    import java.util.*;
027    
028    /**
029     * Entity builder.
030     */
031    public class EntityBuilder extends ElementBuilder {
032        private ArrayList comparatorList;
033    
034        /**
035         * Creates an entity builder.
036         *
037         * @param   entityName name of the entities
038         * @param   entityDescription description of the entities
039         */
040        public EntityBuilder(String entityName, String entityDescription) {
041            super(entityName, entityDescription);
042            comparatorList = new ArrayList();
043        }
044    
045        /**
046         * Builds the element definition.
047         *
048         * @return  the element definition
049         */
050        public EntityDefinition buildDefinition() {
051            EntityDefinition entityDefinition = super.buildEntityDefinition();
052            entityDefinition.addComparators(comparatorList);
053            return entityDefinition;
054        }
055    
056        /**
057         * Starts building new entity.
058         *
059         * @param   entityName name of the entity
060         */
061        public void newEntity(String entityName) {
062            super.newEntity(entityName);
063        }
064    
065        /**
066         * Builds the entity.
067         *
068         * @return  the entity
069         */
070        public Entity buildEntity() {
071            return super.buildEntity();
072        }
073    
074        public void addComparator(EntityComparator entityComparator) {
075            comparatorList.add(entityComparator);
076        }
077    }