~ubuntu-branches/debian/jessie/bgfinancas/jessie

« back to all changes in this revision

Viewing changes to src/Biblioteca/Mascaras.java

  • Committer: Package Import Robot
  • Author(s): Jose Robson Mariano Alves
  • Date: 2014-09-24 15:01:45 UTC
  • Revision ID: package-import@ubuntu.com-20140924150145-le88tcphc5vmc8sh
Tags: upstream-2.0
ImportĀ upstreamĀ versionĀ 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2010, 2012, 2014 Jose Robson Mariano Alves
 
3
 
 
4
This file is part of bgfinancas.
 
5
 
 
6
This program is free software: you can redistribute it and/or modify
 
7
it under the terms of the GNU General Public License as published by
 
8
the Free Software Foundation, either version 3 of the License, or
 
9
(at your option) any later version.
 
10
 
 
11
This package is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
GNU General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public License
 
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
*/
 
20
 
 
21
package Biblioteca;
 
22
 
 
23
import java.text.ParseException;
 
24
import javax.swing.text.DefaultFormatterFactory;
 
25
import javax.swing.text.MaskFormatter;
 
26
 
 
27
public class Mascaras {
 
28
    
 
29
    private Mascaras(){ }
 
30
    
 
31
    public static DefaultFormatterFactory Cep()   
 
32
    {   
 
33
        MaskFormatter cep = null;   
 
34
        try    
 
35
        {    
 
36
            cep = new MaskFormatter("##.###-###");   
 
37
        }    
 
38
        catch (ParseException e) { }   
 
39
        DefaultFormatterFactory factory = new DefaultFormatterFactory(cep, cep);   
 
40
        return factory;   
 
41
    }
 
42
    
 
43
    public static DefaultFormatterFactory Data()   
 
44
    {   
 
45
        MaskFormatter data = null;   
 
46
        try    
 
47
        {    
 
48
            data = new MaskFormatter("##/##/####");   
 
49
        }    
 
50
        catch (ParseException e) { }   
 
51
        DefaultFormatterFactory factory = new DefaultFormatterFactory(data, data);   
 
52
        return factory;   
 
53
    }
 
54
    
 
55
    public static DefaultFormatterFactory CPF()   
 
56
    {   
 
57
        MaskFormatter cpf = null;   
 
58
        try    
 
59
        {    
 
60
            cpf = new MaskFormatter("###.###.###-##");   
 
61
        }    
 
62
        catch (ParseException e) { }   
 
63
        DefaultFormatterFactory factory = new DefaultFormatterFactory(cpf, cpf);   
 
64
        return factory;   
 
65
    }
 
66
    
 
67
    public static DefaultFormatterFactory CNPJ()   
 
68
    {   
 
69
        MaskFormatter cnpj = null;   
 
70
        try    
 
71
        {    
 
72
            cnpj = new MaskFormatter("##.###.###/####-##");   
 
73
        }    
 
74
        catch (ParseException e) { }   
 
75
        DefaultFormatterFactory factory = new DefaultFormatterFactory(cnpj, cnpj);   
 
76
        return factory;   
 
77
    }
 
78
    
 
79
}