/* * Fila.java * * Created on 20 de Abril de 2006, 09:08 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package business; import java.beans.XMLEncoder; import java.io.BufferedOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.util.Vector; /** * * @author 008802 */ public class Fila { private Vector elementos; /** Creates a new instance of Fila */ public Fila() { elementos = new Vector(); } public void insereElemento( Paciente elemento ){ elementos.add(elemento); } public Paciente primeiro(){ return elementos.firstElement(); } public Paciente ultimo(){ return elementos.lastElement(); } public Paciente remove(){ return elementos.remove(0); } public int getTamanho(){ return elementos.size(); } public Fila clone(){ Fila f = new Fila(); for( int i = 0; i < elementos.size(); i++ ){ f.insereElemento( elementos.get(i) ); } return f; } public boolean save(){ XMLEncoder e = null; try { e = new XMLEncoder( new BufferedOutputStream( new FileOutputStream( "fila.xml" ) ) ); e.writeObject( elementos ); return true; } catch (FileNotFoundException ex) { return false; } finally{ e.close(); } } }