Package br.com.caelum.stella.format

Examples of br.com.caelum.stella.format.CNPJFormatter


            errors.add(messageProducer.getMessage(CNPJError.INVALID_FORMAT));
          }
         
          String unformatedCNPJ = null;
          try{
        unformatedCNPJ = new CNPJFormatter().unformat(cnpj);
          }catch(IllegalArgumentException e){
            errors.add(messageProducer.getMessage(CNPJError.INVALID_DIGITS));
            return errors;
          }
         
View Full Code Here


     * Caso contrário, ele guarda o parâmetro como passado em ambos os atributos.
     *
     * @param numero número do CPF.
     */
    public CNPJ(String numero) {
      CNPJFormatter formatador = new CNPJFormatter();
      if (formatador.isFormatted(numero)) {
      this.numero = formatador.unformat(numero);
      this.numeroFormatado = numero;
    } else if (formatador.canBeFormatted(numero)) {
      this.numero = numero;
      this.numeroFormatado = formatador.format(numero);
    } else {
      this.numero = this.numeroFormatado = numero;
    }
    }
View Full Code Here

        String unformatedCNPJ = null;
        if (isFormatted) {
            if (!(CNPJ_FORMATED.matcher(cnpj).matches())) {
                errors.add(CNPJError.INVALID_FORMAT);
            }
            unformatedCNPJ = (new CNPJFormatter()).unformat(cnpj);
        } else {
            if (!CNPJ_UNFORMATED.matcher(cnpj).matches()) {
                errors.add(CNPJError.INVALID_DIGITS);
            }
            unformatedCNPJ = cnpj;
View Full Code Here

    private Formatter formatter;

    @Before
    public void before() {
        formatter = new CNPJFormatter();
    }
View Full Code Here

                    errors.add(CNPJError.INVALID_DIGITS);
                }
            } else {
                String unformatedCNPJ;
                if (isFormatted) {
                    CNPJFormatter formatter = new CNPJFormatter();
                    unformatedCNPJ = formatter.unformat(cnpj);
                } else {
                    unformatedCNPJ = cnpj;
                }
                if (!hasValidCheckDigits(unformatedCNPJ)) {
                    errors.add(CNPJError.INVALID_CHECK_DIGITS);
View Full Code Here

                    errors.add(CNPJError.INVALID_DIGITS);
                }
            } else {
                String unformatedCNPJ;
                if (isFormatted) {
                    CNPJFormatter formatter = new CNPJFormatter();
                    unformatedCNPJ = formatter.unformat(cnpj);
                } else {
                    unformatedCNPJ = cnpj;
                }
                if (!hasValidCheckDigits(unformatedCNPJ)) {
                    errors.add(CNPJError.INVALID_CHECK_DIGITS);
View Full Code Here

TOP

Related Classes of br.com.caelum.stella.format.CNPJFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.