java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/FunkceEL.java
author František Kučera <franta-hg@frantovo.cz>
Sun Jun 20 14:46:47 2010 +0200 (2010-06-20)
changeset 145 0efefbf5f8b6
parent 134 4bd1e353c527
child 154 bf21a4abea9b
permissions -rw-r--r--
Formátování kódu, důsledné používání tabulátorů, drobné úpravy, StringBuilder
franta-hg@66
     1
package cz.frantovo.nekurak.web;
franta-hg@66
     2
franta-hg@68
     3
import cz.frantovo.nekurak.dto.Podnik;
franta-hg@66
     4
import cz.frantovo.nekurak.servlet.Fotky;
franta-hg@134
     5
import cz.frantovo.nekurak.util.Komentare;
franta-hg@134
     6
import cz.frantovo.nekurak.vyjimky.KomentarovaVyjimka;
franta-hg@66
     7
franta-hg@66
     8
/**
franta-hg@66
     9
 * Knihovna funkcí použitelná v EL
franta-hg@66
    10
 * @author fiki
franta-hg@66
    11
 */
franta-hg@66
    12
public class FunkceEL {
franta-hg@66
    13
franta-hg@145
    14
	/** Musí odpovídat cestě, kam je namapovaný servlet. */
franta-hg@145
    15
	private static final String SERVLET = "fotky";
franta-hg@66
    16
franta-hg@145
    17
	public static String fotka(int id, boolean nahled) {
franta-hg@145
    18
		String prostredek = nahled ? Fotky.PODADRESAR_NAHLED : Fotky.PODADRESAR_ORIGINAL;
franta-hg@145
    19
		return SERVLET + "/" + prostredek + "/" + id + "." + Fotky.PRIPONA;
franta-hg@145
    20
	}
franta-hg@68
    21
franta-hg@145
    22
	public static boolean maFotky(Podnik p) {
franta-hg@145
    23
		return !p.getFotky().isEmpty();
franta-hg@145
    24
	}
franta-hg@134
    25
franta-hg@145
    26
	/**
franta-hg@145
    27
	 * @param komentar komentář včetně kořenové značky, XML jako text
franta-hg@145
    28
	 * @return true, pokud vyhovuje XML schématu
franta-hg@145
    29
	 */
franta-hg@145
    30
	public static boolean zkontrolujKomentar(String komentar) {
franta-hg@145
    31
		try {
franta-hg@145
    32
			Komentare.zkontroluj(komentar);
franta-hg@145
    33
			return true;
franta-hg@145
    34
		} catch (KomentarovaVyjimka ex) {
franta-hg@145
    35
			return false;
franta-hg@145
    36
		}
franta-hg@134
    37
	}
franta-hg@66
    38
}