/*
 * Created on 02/02/2007
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package agilpizza.servlet;

import java.util.regex.Pattern;

public class ValidacaoUtil {

	public static boolean isVazio(String valor) {
		return valor == null || valor.trim().equals("");
	}

	public static boolean isCEPInvalido(String cep) {
		return !Pattern.matches("[0-9]{5}|[0-9]{5}-?[0-9]{3}", cep);
	}

	public static int getQuantidade(String numero) {
		if (!Pattern.matches("[0-9]*", numero)) {
			throw new NumberFormatException();
		}
		if (numero.length() == 0) {
			numero = "0";
		}
		return Integer.parseInt(numero);
	}

}
