001    /*
002     * $RCSfile: RequestHandler.java,v $ 
003     *
004     * Created on Dec 2, 2004, 16:19 PM
005     *
006     * This file is part of the STAR Scheduler.
007     * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory
008     *
009     * STAR Scheduler is free software; you can redistribute it and/or modify
010     * it under the terms of the GNU General Public License as published by
011     * the Free Software Foundation; either version 2 of the License, or
012     * (at your option) any later version.
013     *
014     * STAR Scheduler is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017     * GNU General Public License for more details.
018     *
019     * You should have received a copy of the GNU General Public License
020     * along with STAR Scheduler; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022     */
023    package gov.bnl.star.offline.scheduler.request;
024    
025    import org.xml.sax.helpers.DefaultHandler;
026    import java.util.*;
027    import java.util.logging.Logger;
028    import java.util.ArrayList;
029    
030    /** Abstract parent class to read STAR scheduler
031     * job request elements and create a Request. Subclassed 
032     * from DefaultHandler, which receives parse events from
033     * a SAXParser
034     *
035     * @author  paulh
036     * @version $Revision: 1.2 $ $Date: 2006/11/21 00:41:31 $
037     */
038    public abstract class RequestHandler extends DefaultHandler {
039    
040        static protected Logger log = Logger.getLogger(RequestHandler.class.getName());
041        protected ArrayList requests = new ArrayList();
042        protected Map defaults;
043        protected String xmlFileName;
044     
045        public RequestHandler(String fileName) {
046            xmlFileName = fileName;
047        }
048    
049        public Request[] getRequests() {
050            Request[] reqs = new Request[requests.size()];
051                                                                                    
052            for (int count = 0; count < requests.size(); count++) {
053                reqs[count] = (Request) requests.get(count);
054            }
055                                                                                    
056            return reqs;
057        }    
058    
059        public void setDefaults(Map defaults) {
060            this.defaults = defaults;
061        }
062        
063    }