Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

CorpoClasse.java

Go to the documentation of this file.
00001 package plp.orientadaObjetos1.declaracao.classe;
00002 
00003 import java.util.Iterator;
00004 import java.util.List;
00005 
00006 import plp.orientadaObjetos1.declaracao.procedimento.DecProcedimento;
00007 import plp.orientadaObjetos1.declaracao.procedimento.DecProcedimentoComposta;
00008 import plp.orientadaObjetos1.declaracao.variavel.CompostaDecVariavel;
00009 import plp.orientadaObjetos1.declaracao.variavel.DecVariavel;
00010 
00011 public class CorpoClasse {
00012 
00013     List atributos;
00014     List metodos;
00015     
00016     public CorpoClasse( List atributos, List metodos) {
00017         this.atributos = atributos;
00018         this.metodos = metodos;
00019     }
00020     
00021     public DecVariavel getAtributos() {
00022         DecVariavel atributos = null;
00023 
00024         //Se for atributos compostos
00025         if ( this.atributos.size()>1) {
00026             
00027             atributos = new CompostaDecVariavel();
00028 
00029             //Preencher a lista encadeada
00030             CompostaDecVariavel dvAtual = (CompostaDecVariavel) atributos;
00031             CompostaDecVariavel dvAnterior = null; 
00032             Iterator i = this.atributos.iterator();
00033             
00034             while (i.hasNext()) {
00035 
00036                 DecVariavel dv = (DecVariavel) i.next();
00037                 
00038                 //Se existe uma proxima decVariavel
00039                 if (i.hasNext()) {
00040                     dvAtual.setCurrent(dv);
00041                     dvAtual.setNext( new CompostaDecVariavel());
00042                     
00043                     dvAnterior = dvAtual;
00044                     dvAtual = (CompostaDecVariavel) dvAtual.getNext(); 
00045                 } 
00046                 //Se é a ultima decVariavel
00047                 else {
00048                     dvAnterior.setNext(dv);
00049                 }
00050             }
00051         }
00052         else {
00053             atributos = (DecVariavel) this.atributos.get(0);
00054         }
00055 
00056         return atributos;
00057     }
00058     
00059     public DecProcedimento getMetodos() {
00060         DecProcedimento metodos = null;
00061 
00062         //Se tiver mais de 1 metodo
00063         if ( this.metodos.size()>1) {
00064             
00065             metodos = new DecProcedimentoComposta();
00066 
00067             //Preencher a lista encadeada
00068             DecProcedimentoComposta dpAtual = (DecProcedimentoComposta) metodos;
00069             DecProcedimentoComposta dpAnterior = null; 
00070             Iterator i = this.metodos.iterator();
00071             
00072             while (i.hasNext()) {
00073 
00074                 DecProcedimento dv = (DecProcedimento) i.next();
00075                 
00076                 //Se existe uma proxima decVariavel
00077                 if (i.hasNext()) {
00078                     dpAtual.setCurrent(dv);
00079                     dpAtual.setNext( new DecProcedimentoComposta());
00080                     
00081                     dpAnterior = dpAtual;
00082                     dpAtual = (DecProcedimentoComposta) dpAtual.getNext(); 
00083                 } 
00084                 //Se é a ultima decVariavel
00085                 else {
00086                     dpAnterior.setNext(dv);
00087                 }
00088             }
00089         }
00090         else {
00091             metodos = (DecProcedimento) this.metodos.get(0);
00092         }
00093 
00094         return metodos;
00095     }
00096     
00097 }

Generated on Mon Aug 8 20:20:46 2005 for Linguagem OO1 - Generics by  doxygen 1.4.4