Exemplo n.º 1
0
  static void eliminarLugarFicheroLOC(Lugar lugar) {
    String fichero = lugar.getFicheroLOC();

    try {
      FileReader fr = new FileReader(fichero);
      BufferedReader br = new BufferedReader(fr);

      String linea;
      ArrayList lineas = new ArrayList();

      do {
        linea = br.readLine();
        if (linea != null) {
          if (!linea.substring(0, lugar.nombre.length()).equals(lugar.nombre)) lineas.add(linea);
        } else break;
      } while (true);
      br.close();
      fr.close();

      FileOutputStream fos = new FileOutputStream(fichero);
      PrintWriter pw = new PrintWriter(fos);

      for (int i = 0; i < lineas.size(); i++) pw.println((String) lineas.get(i));
      pw.flush();
      pw.close();
      fos.close();

    } catch (FileNotFoundException e) {
      System.err.println("error: eliminando " + e);

    } catch (IOException e) {
      System.err.println("error: eliminando 2 : " + e);
    }
  }
Exemplo n.º 2
0
    public Lugar assembleLugar(LugarDto){
	Lugar lugar = new Lugar();
	lugar.setTipo(tipo);
	lugar.setNombre(nombre);
	lugar.setLongitud(longitud);
	lugar.setLatitud(latitud):
	lugar.setDescripcion(descripcion);
	lugar.setFechaAlta(fecha_alta);
	lugar.setFechaUltMod(new Date());
	return lugar;
    }
Exemplo n.º 3
0
  /* toString(), equals() y hashCode() para Espectaculo, utilizando la identidad natural del objeto */
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Espectaculo espectaculo = (Espectaculo) o;

    if (evento != null ? !evento.equals(espectaculo.evento) : espectaculo.evento != null)
      return false;
    if (lugar != null ? !lugar.equals(espectaculo.lugar) : espectaculo.lugar != null) return false;

    return true;
  }
Exemplo n.º 4
0
  static void parseLOC(String archivoLugares) throws FileNotFoundException {
    FileReader fr = new FileReader(archivoLugares);
    BufferedReader br = new BufferedReader(fr);
    String linea, nombre;
    double latitud, longitud, altitud, offset;

    try {
      do {
        linea = br.readLine();
        if (linea != null) {
          StringTokenizer st = new StringTokenizer(linea, ":", false);
          if (st.countTokens() == 5) {
            nombre = st.nextToken();
            latitud = Double.parseDouble(st.nextToken());
            longitud = Double.parseDouble(st.nextToken());
            altitud = Double.parseDouble(st.nextToken());
            offset = Double.parseDouble(st.nextToken());
            Lugar lugar = new Lugar(nombre, latitud, longitud, altitud, offset);
            lugar.setFicheroLOC(archivoLugares);
            lugares.add(lugar);
          }
        } else break;
      } while (true);
      br.close();
      fr.close();
      Object[] satArray = lugares.toArray();
      Arrays.sort(satArray);
      lugares.clear();
      for (int i = 0; i < satArray.length; i++) lugares.add(satArray[i]);

    } catch (IOException e) {
      System.err.println("error: Leyendo archivo LOC : " + e);
    } catch (NumberFormatException e) {
      System.err.println("error: Leyendo en un campo del archivo LOC : " + e);
    }
  }
Exemplo n.º 5
0
 @Override
 public int hashCode() {
   int result = evento != null ? evento.hashCode() : 0;
   result = 31 * result + (lugar != null ? lugar.hashCode() : 0);
   return result;
 }