/******************************************************************************* * Copyright (c) 2011 IRIS/DMC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * IRIS/DMC- initial API and implementation * * ACKNOWLEDGEMENT * This software was developed as part of a project supported by * Cooperative Agreement Number G10AC00533 from the United States * Geological Survey. Its contents are solely the responsibility of * the authors and the USGS is not responsible for the efficacy, * safety, or suitability of this software. ******************************************************************************/ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Stage { private int order; private ChannelEpoch epoch; private List filters = new ArrayList(); public Stage(int order){ this.order = order; } public int getOrder() { return order; } public void setOrder(int order) { this.order = order; } public List getFilters() { return filters; } public void add(Filter filter) { //to deal with data errors if(this.filters.size()>1){ //get last one& check for split blocketts Filter f = filters.get(filters.size()-1); if(f.getType() == filter.getType()){ int repeat = filter.getRepeat()+f.getRepeat(); f.modify(repeat); System.out.println("Duplicates..."); return; } } filter.setStage(this); this.filters.add(filter); } public Filter get(int type){ for(Filter f:filters){ if(f.getType()==type){ return f; } } return null; } public ChannelEpoch getEpoch() { return epoch; } public void setEpoch(ChannelEpoch epoch) { this.epoch = epoch; } public void writeXml(XMLWriter out) throws IOException{ Map attributes = new HashMap(); attributes.put("stage", ""+this.order); out.startElement("Response", attributes); for(Filter filter:this.filters){ filter.writeXml(out); } out.endElement(); out.flush(); } }