Coverage details for base.user.jcard.Birthdate

LineHitsSource
1 /*******************************************************************************
2  * InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program 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, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20  
21 package base.user.jcard;
220 
23 import javax.print.attribute.standard.MediaSize.ISO;
24  
2515public class Birthdate extends Property {
26  
27     private int yyyy;
28     private int mm;
29     private int dd;
30     
31     private static final String BIRTHDATE_FIELD_DELIMITER = "-";
32     
33     /**
34      * Sets the birthdate of the contact.
35      * @param yyyy 4 digit year
36      * @param mm 2 digit month
37      * @param dd 2 digit day
380     * @see ISO 8601 date encoding standard
390     */
400    public void setBirthdate(int yyyy, int mm, int dd) {
4112        this.yyyy = yyyy;
4212        this.mm = mm;
4312        this.dd = dd;
4412    }
450    
460    @Override
47     protected void setPropertyName() {
4815        super.PROPERTY_NAME = "BDAY:";
4915    }
500    
51     @Override
52     public void doValidate() throws JCardException {
539        if(dd < 1 || dd > 31 ||
543            mm < 1 || mm > 12 ||
553            yyyy < 1900) // may need to change year validation
566            throw new JCardException("Validation error: Valid date not entered");
573    }
580 
590    @Override
600    public String toString() {
6112        StringBuffer birthdate = new StringBuffer(21);
6212        birthdate.append(Integer.toString(yyyy));
6312        birthdate.append(BIRTHDATE_FIELD_DELIMITER);
6412        birthdate.append(Integer.toString(mm));
6512        birthdate.append(BIRTHDATE_FIELD_DELIMITER);
6612        birthdate.append(Integer.toString(dd));
6712        return birthdate.toString();
68     }
69  
70 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.