java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java
changeset 20 90dc76051e56
parent 6 38625daa449b
child 21 2bc6c427894d
     1.1 --- a/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java	Wed Feb 11 22:25:09 2009 +0100
     1.2 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java	Fri Feb 13 00:26:59 2009 +0100
     1.3 @@ -23,11 +23,19 @@
     1.4      private static final long serialVersionUID = 7932392366943861342L;
     1.5      private static final Logger log = Logger.getLogger(DenniSouhrn.class.getName());
     1.6      private static final long DEN = 1000 * 60 * 60 * 24;
     1.7 -    private static String formatDataVzor = "yyyy-mm-dd";
     1.8 +    private static String formatDataVzor = "yyyy-MM-dd";
     1.9      public static DateFormat formatData = new SimpleDateFormat(formatDataVzor);
    1.10      private Date den;
    1.11 +    private int cil;
    1.12 +
    1.13 +    public String getDenString() {
    1.14 +        return formatData.format(getDen());
    1.15 +    }
    1.16  
    1.17      public Date getDen() {
    1.18 +        if (den == null) {
    1.19 +            nastavVychoziDen();
    1.20 +        }
    1.21          return den;
    1.22      }
    1.23  
    1.24 @@ -37,22 +45,42 @@
    1.25          } else {
    1.26              this.den = den;
    1.27          }
    1.28 -        log.log(Level.INFO, "Den nastaven na: " + formatData.format(den));
    1.29 +        log.log(Level.FINE, "Den nastaven na: " + formatData.format(den));
    1.30      }
    1.31  
    1.32 -    public void setDen(String den) {
    1.33 -        if (den == null || den.length() != formatDataVzor.length()) {
    1.34 +    public void setDenString(String den) {
    1.35 +        if (den == null) {
    1.36              nastavVychoziDen();
    1.37          }
    1.38  
    1.39          try {
    1.40              this.den = new Date(formatData.parse(den).getTime());
    1.41          } catch (ParseException e) {
    1.42 -            log.log(Level.INFO, "Chybně zadané datum: " + den, e);
    1.43 +            log.log(Level.FINE, "Chybně zadané datum: " + den, e);
    1.44              nastavVychoziDen();
    1.45          }
    1.46      }
    1.47  
    1.48 +    public void setCilString(String cil) {
    1.49 +        try {
    1.50 +            this.cil = Integer.parseInt(cil);
    1.51 +        } catch (Exception e) {
    1.52 +            this.cil = 0;
    1.53 +        }
    1.54 +    }
    1.55 +
    1.56 +    public void setCil(int cil) {
    1.57 +        this.cil = cil;
    1.58 +    }
    1.59 +
    1.60 +    public String getCilString() {
    1.61 +        return String.valueOf(cil);
    1.62 +    }
    1.63 +
    1.64 +    public int getCil() {
    1.65 +        return cil;
    1.66 +    }
    1.67 +
    1.68      /**
    1.69       * Ve výchozím stavu zobrazujeme souhrn za předešlý den.
    1.70       * @return včerejšek
    1.71 @@ -62,17 +90,17 @@
    1.72      }
    1.73  
    1.74      private void nastavVychoziDen() {
    1.75 -        log.log(Level.INFO, "Nastavuji den na výchozí hodnotu.");
    1.76 +        log.log(Level.FINE, "Nastavuji den na výchozí hodnotu.");
    1.77          setDen(getVychoziDen());
    1.78      }
    1.79  
    1.80      public Collection<Souhrn> getSouhrn() {
    1.81          Collection<Souhrn> souhrn = new ArrayList<Souhrn>();
    1.82  
    1.83 -        Cil cil = new Cil(1, "Frantovo.cz", "http://frantovo.cz/blog/", null, null);
    1.84 +        Cil c = new Cil(1, "Frantovo.cz", "http://frantovo.cz/blog/", null, null);
    1.85  
    1.86          for (int i = 1; i < 11; i++) {
    1.87 -            Souhrn s = new Souhrn(getVychoziDen(), new SitovaAdresa("10.0.0.8", i + ".frantovo.cz"), 100 + i, cil);
    1.88 +            Souhrn s = new Souhrn(getVychoziDen(), new SitovaAdresa("10.0.0.8", i + ".frantovo.cz"), 100 + i, c);
    1.89              souhrn.add(s);
    1.90          }
    1.91