コード例 #1
0
ファイル: Main.java プロジェクト: amdantas/projetos-unirn
  public static void main(String[] args) throws ParseException {

    DadosPessoais[] pessoas = new DadosPessoais[NUM_MAXIMO];

    Municipio natal = new Municipio("Natal");
    Municipio recife = new Municipio("Recife");

    for (int i = 0; i < pessoas.length; i++) {
      DadosPessoais pessoa = new DadosPessoais();
      pessoa.setNome("NOME PESSOA " + i);
      pessoa.setDataNascimento(formatador.parse("01/04/199" + i));
      pessoa.setEmail("[email protected]." + i);
      pessoa.setCidadeNascimento(natal);

      Endereco endereco = new Endereco();
      endereco.setRua("RUA " + i);
      endereco.setNumero((i + 10) * 80);
      endereco.setCep("593434" + ((i + 10) * 45));
      endereco.setMunicipio(recife);

      pessoa.setEnderecoContato(endereco);

      pessoas[i] = pessoa;
    }

    for (DadosPessoais p : pessoas) {
      System.out.println(p);
    }
  }
コード例 #2
0
 public String getDetalheDestino() {
   for (Endereco endereco : enderecos) {
     if (StatusEndereco.DESTINO == endereco.getStatusEndereco()) {
       return endereco.toString();
     }
   }
   return "Nao disponivel";
 }
コード例 #3
0
 // m�todos utilitario para a camada de vis�o
 public String getDetalheOrigem() {
   for (Endereco endereco : enderecos) {
     if (StatusEndereco.ORIGEM == endereco.getStatusEndereco()) {
       return endereco.toString();
     }
   }
   return "Nao disponivel";
 }
コード例 #4
0
 /**
  * Método que cadastrar um objeto de classe Paciente no Repositório
  *
  * @param Objeto da Classe Paciente.
  * @return void
  * @throws EnderecoJaCadastradoException
  */
 public void cadastrarEnderco(Endereco endereco) throws EnderecoJaCadastradoException {
   // Verifica se o Paciente existe no repositório
   if (this.enderecoExiste(endereco.getId())) throw new EnderecoJaCadastradoException();
   endereco.setId(this.id);
   enderecos[this.indice] = endereco;
   this.indice = this.indice + 1;
   this.id = this.id + 1;
 }
コード例 #5
0
ファイル: Cliente.java プロジェクト: mersonff/bhcontrole
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Cliente other = (Cliente) obj;
   if (cnpj == null) {
     if (other.cnpj != null) return false;
   } else if (!cnpj.equals(other.cnpj)) return false;
   if (cpf == null) {
     if (other.cpf != null) return false;
   } else if (!cpf.equals(other.cpf)) return false;
   if (email == null) {
     if (other.email != null) return false;
   } else if (!email.equals(other.email)) return false;
   if (endereco == null) {
     if (other.endereco != null) return false;
   } else if (!endereco.equals(other.endereco)) return false;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (nome == null) {
     if (other.nome != null) return false;
   } else if (!nome.equals(other.nome)) return false;
   if (telefones == null) {
     if (other.telefones != null) return false;
   } else if (!telefones.equals(other.telefones)) return false;
   return true;
 }
コード例 #6
0
ファイル: Pessoa.java プロジェクト: NaroPerry/abc
 @Override
 public String toString() {
   return "\nNome: "
       + nome
       + "\nData de nascimento: "
       + dataNascimento
       + "\nTelefone: "
       + foneContato
       + "\nEndereço: "
       + endereco.toString();
 }
コード例 #7
0
ファイル: Cliente.java プロジェクト: mersonff/bhcontrole
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((cnpj == null) ? 0 : cnpj.hashCode());
   result = prime * result + ((cpf == null) ? 0 : cpf.hashCode());
   result = prime * result + ((email == null) ? 0 : email.hashCode());
   result = prime * result + ((endereco == null) ? 0 : endereco.hashCode());
   result = prime * result + ((id == null) ? 0 : id.hashCode());
   result = prime * result + ((nome == null) ? 0 : nome.hashCode());
   result = prime * result + ((telefones == null) ? 0 : telefones.hashCode());
   return result;
 }
コード例 #8
0
ファイル: AddPostoView.java プロジェクト: rsmrafael/t10
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    CNPJ = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    RS = new javax.swing.JTextField();
    NF = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    Bandeira = new javax.swing.JTextField();
    Endereco = new javax.swing.JTextField();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    Bairro = new javax.swing.JTextField();
    CEP = new javax.swing.JTextField();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    ImgPath = new javax.swing.JTextField();
    jButton2 = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jtPriceList = new javax.swing.JTable();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    price = new javax.swing.JTextField();
    JComboBox_Combustivel = new javax.swing.JComboBox<>();
    jLabel10 = new javax.swing.JLabel();
    dia = new javax.swing.JTextField();
    jLabel11 = new javax.swing.JLabel();
    mes = new javax.swing.JTextField();
    jLabel12 = new javax.swing.JLabel();
    ano = new javax.swing.JTextField();
    jButton3 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Adicionar Posto");

    CNPJ.setToolTipText("");

    jLabel2.setText("CNPJ:");

    jLabel3.setText("Razão Social:");

    RS.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RSActionPerformed(evt);
          }
        });

    NF.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            NFActionPerformed(evt);
          }
        });

    jLabel4.setText("Nome Fantasia:");

    jLabel5.setText("Bandeira:");

    Endereco.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            EnderecoActionPerformed(evt);
          }
        });

    jLabel6.setText("Endereço:");

    jLabel7.setText("Bairro:");

    Bairro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BairroActionPerformed(evt);
          }
        });

    jLabel8.setText("CEP:");

    jLabel9.setText("Caminho para Imagem:");

    jButton2.setText("Cancelar");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });

    jButton1.setText("Confirmar");
    jButton1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
          }
        });

    jtPriceList.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {
              {null, null, null, null},
              {null, null, null, null},
              {null, null, null, null},
              {null, null, null, null}
            },
            new String[] {"Title 1", "Title 2", "Title 3", "Title 4"}));
    jScrollPane1.setViewportView(jtPriceList);

    jLabel13.setText("Tipo de Combustível");

    jLabel14.setText("Preco");

    JComboBox_Combustivel.setModel(
        new javax.swing.DefaultComboBoxModel<>(new String[] {"Gasolina", "Etanol", "Diesel"}));
    JComboBox_Combustivel.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(java.awt.event.ItemEvent evt) {
            JComboBox_CombustivelItemStateChanged(evt);
          }
        });
    JComboBox_Combustivel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            JComboBox_CombustivelActionPerformed(evt);
          }
        });

    jLabel10.setText("Dia");

    jLabel11.setText("Mes");

    jLabel12.setText("Ano");

    jButton3.setText("Adicionar Preço");
    jButton3.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
          }
        });

    jButton5.setText("Atualizar Preço");
    jButton5.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
          }
        });

    jButton4.setText("Remover Preço");
    jButton4.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel9)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(ImgPath))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel8)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(CEP))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(Bairro))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel4)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(NF))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(CNPJ))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel3)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(RS))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel6)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(Endereco))
                            .addComponent(jScrollPane1)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(jLabel10)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(
                                                        dia,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        27,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(jLabel11))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(jLabel14)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(
                                                        price,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        76,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(mes)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(jLabel12)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(
                                                        ano,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        61,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(jLabel13)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(
                                                        JComboBox_Combustivel,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        88,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                layout
                                                    .createSequentialGroup()
                                                    .addGap(0, 10, Short.MAX_VALUE)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .TRAILING,
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(jButton3)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .UNRELATED)
                                                                    .addComponent(jButton5)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addComponent(jButton4))
                                                            .addGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .TRAILING,
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(jButton1)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .UNRELATED)
                                                                    .addComponent(jButton2))))))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel5)
                                    .addGap(18, 18, 18)
                                    .addComponent(Bandeira))
                            .addComponent(
                                jLabel1,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(
                                CNPJ,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(
                                RS,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(
                                NF,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(
                                Bandeira,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(
                                Endereco,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(
                                Bairro,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(
                                CEP,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(
                                ImgPath,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jScrollPane1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        122,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12)
                            .addComponent(
                                dia,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                mes,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                ano,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(
                                JComboBox_Combustivel,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton4)
                            .addComponent(jButton5)
                            .addComponent(jButton3)
                            .addComponent(jLabel14)
                            .addComponent(
                                price,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(jButton2))
                    .addContainerGap()));

    pack();
  } // </editor-fold>//GEN-END:initComponents
コード例 #9
0
ファイル: Utilities.java プロジェクト: RamonReis/Ramon-s
  public static void uneArquivos(
      RandomAccessFile arg0, RandomAccessFile arg1, FileOutputStream arg3) throws Exception {
    DataOutputStream dOut = new DataOutputStream(arg3);
    Endereco end0 = new Endereco();
    Endereco end1 = new Endereco();
    end0.leEndereco(arg0);
    end1.leEndereco(arg1);
    // System.out.println(end1.getCep());
    while (arg0.getFilePointer() < arg0.length() || arg1.getFilePointer() < arg1.length()) {

      // System.out.println(Integer.parseInt(end0.getCep()));
      if (arg1.getFilePointer() == arg1.length() && arg0.getFilePointer() != arg0.length()) {
        while (arg0.getFilePointer() < arg0.length()) {
          end0.leEndereco(arg0);
          dOut.write(end0.getLogradouroB());
          dOut.write(end0.getBairroB());
          dOut.write(end0.getCidadeB());
          dOut.write(end0.getEstadoB());
          dOut.write(end0.getSiglaB());
          dOut.write(end0.getCepB());
          dOut.writeByte(0);
          dOut.writeBytes("\n");
        }
        break;
      } else if (arg0.getFilePointer() == arg0.length() && arg1.getFilePointer() != arg1.length()) {
        while (arg1.getFilePointer() < arg1.length()) {
          end1.leEndereco(arg1);
          dOut.write(end1.getLogradouroB());
          dOut.write(end1.getBairroB());
          dOut.write(end1.getCidadeB());
          dOut.write(end1.getEstadoB());
          dOut.write(end1.getSiglaB());
          dOut.write(end1.getCepB());
          dOut.writeByte(0);
          dOut.writeBytes("\n");
        }
        break;
      } else if (end0.getCep().compareTo(end1.getCep()) <= 0) {
        dOut.write(end0.getLogradouroB());
        dOut.write(end0.getBairroB());
        dOut.write(end0.getCidadeB());
        dOut.write(end0.getEstadoB());
        dOut.write(end0.getSiglaB());
        dOut.write(end0.getCepB());
        dOut.writeByte(0);
        dOut.writeBytes("\n");
        end0.leEndereco(arg0);
      } else if (end0.getCep().compareTo(end1.getCep()) > 0) {
        dOut.write(end1.getLogradouroB());
        dOut.write(end1.getBairroB());
        dOut.write(end1.getCidadeB());
        dOut.write(end1.getEstadoB());
        dOut.write(end1.getSiglaB());
        dOut.write(end1.getCepB());
        dOut.writeByte(0);
        dOut.writeBytes("\n");
        end1.leEndereco(arg1);
      } else System.out.println("Erro!");
    }
    arg3.close();
  }
コード例 #10
0
ファイル: Utilities.java プロジェクト: RamonReis/Ramon-s
  public static void divideEntrada(RandomAccessFile arg0) throws Exception {
    ArrayList<Endereco> array = new ArrayList<Endereco>();
    FileOutputStream saida = null;
    int k = 0;
    long valorArqEntrBytes = arg0.length();
    long numeroRegistros =
        (valorArqEntrBytes
            / (298 + 2)); // 298 - cada registro / 2 - 1 byte em branco + 1 byte quebra de linha
    int numeroRegArqSaida = (int) numeroRegistros / 8;
    int contadorAux = numeroRegArqSaida;

    // System.out.println(f.length());
    while (arg0.getFilePointer() < arg0.length()) // para Detectar EOF
    {
      // System.out.println(f.getFilePointer());
      contadorAux = numeroRegArqSaida;
      Endereco e = new Endereco();
      e.leEndereco(arg0);
      array.add(e);
      if (array.size() == numeroRegArqSaida) {
        Collections.sort(array, new ComparadorDeEnderecos());

        for (int i = 0; i < contadorAux; i++) {
          if (i == 0) {
            saida = new FileOutputStream("saidaN0ID" + String.valueOf(k++) + ".dat");
            if (numeroRegistros % 2 != 0)
              contadorAux++; // Se o numero total de registros do arquivo inicial for ímapr, o
            // primeiro arquivo de saída terá um registro a mais.
          }
          DataOutputStream dout = new DataOutputStream(saida);
          dout.write(array.get(i).getLogradouroB());
          dout.write(array.get(i).getBairroB());
          dout.write(array.get(i).getCidadeB());
          dout.write(array.get(i).getEstadoB());
          dout.write(array.get(i).getSiglaB());
          dout.write(array.get(i).getCepB());
          dout.writeBytes("\n");
          /*
          dout.writeBytes(array.get(i).getLogradouro());
          dout.writeBytes(array.get(i).getBairro());
          dout.writeBytes(array.get(i).getCidade());
          dout.writeBytes(array.get(i).getEstado());
          dout.writeBytes(array.get(i).getSigla());
          dout.writeBytes(array.get(i).getCep());
          */
        }
        array.clear();
      }
    }
    if (array.size() != 0) {
      int l = 0;
      saida = new FileOutputStream("saida" + String.valueOf(k++) + ".dat");
      Collections.sort(array, new ComparadorDeEnderecos());
      while (l != array.size()) {
        DataOutputStream dout = new DataOutputStream(saida);
        dout.write(array.get(l).getLogradouroB());
        dout.write(array.get(l).getBairroB());
        dout.write(array.get(l).getCidadeB());
        dout.write(array.get(l).getEstadoB());
        dout.write(array.get(l).getSiglaB());
        dout.write(array.get(l).getCepB());
        dout.writeByte(0);
        dout.writeBytes("\n");
        /*
        dout.writeBytes(array.get(l).getLogradouro());
        dout.writeBytes(array.get(l).getBairro());
        dout.writeBytes(array.get(l).getCidade());
        dout.writeBytes(array.get(l).getEstado());
        dout.writeBytes(array.get(l).getSigla());
        dout.writeBytes(array.get(l).getCep());
        */
        l++;
      }
      array.clear();
    } else System.out.println("Error!");
    arg0.close();
  }
コード例 #11
0
 /**
  * Método que atualiza um objeto de classe Paciente no Repositório
  *
  * @param Objeto da Classe Paciente.
  * @return Paciente
  * @throws EnderecoNaoEncontradoException
  */
 public void atualizarEndereco(Endereco endereco) throws EnderecoNaoEncontradoException {
   int i = getIndice(endereco.getId());
   if (i == -1) throw new EnderecoNaoEncontradoException();
   enderecos[i] = endereco;
 }
コード例 #12
0
ファイル: Uf.java プロジェクト: viniciusjns/escola
  public Endereco removeEndereco(Endereco endereco) {
    getEnderecos().remove(endereco);
    endereco.setUf(null);

    return endereco;
  }
コード例 #13
0
ファイル: Uf.java プロジェクト: viniciusjns/escola
  public Endereco addEndereco(Endereco endereco) {
    getEnderecos().add(endereco);
    endereco.setUf(this);

    return endereco;
  }