001    package ezvcard.types;
002    
003    import java.util.Date;
004    
005    import ezvcard.VCardSubTypes;
006    import ezvcard.VCardVersion;
007    
008    /*
009     Copyright (c) 2012, Michael Angstadt
010     All rights reserved.
011    
012     Redistribution and use in source and binary forms, with or without
013     modification, are permitted provided that the following conditions are met: 
014    
015     1. Redistributions of source code must retain the above copyright notice, this
016     list of conditions and the following disclaimer. 
017     2. Redistributions in binary form must reproduce the above copyright notice,
018     this list of conditions and the following disclaimer in the documentation
019     and/or other materials provided with the distribution. 
020    
021     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
022     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
023     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
024     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
025     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
026     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
027     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
028     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
029     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031    
032     The views and conclusions contained in the software and documentation are those
033     of the authors and should not be interpreted as representing official policies, 
034     either expressed or implied, of the FreeBSD Project.
035     */
036    
037    /**
038     * Defines the person's time of death.
039     * 
040     * <p>
041     * <b>Setting the time of death</b>
042     * </p>
043     * 
044     * <pre>
045     * VCard vcard = new VCard();
046     * 
047     * //complete date
048     * Calendar c = Calendar.getInstance();
049     * c.set(Calendar.YEAR, 1954);
050     * c.set(Calendar.MONTH, Calendar.JUNE);
051     * c.set(Calendar.DAY_OF_MONTH, 7);
052     * DeathdateType deathdate = new DeathdateType();
053     * deathdate.setDate(c.getTime(), false);
054     * vcard.setDeathdate(deathdate);
055     * 
056     * //reduced accuracy date
057     * deathdate = new DeathdateType();
058     * deathdate.setReducedAccuracyDate(&quot;--0607&quot;); //June 7
059     * vcard.setDeathdate(deathdate);
060     * 
061     * //plain text value
062     * deathdate = new DeathdateType();
063     * deathdate.setText(&quot;circa 1954&quot;);
064     * vcard.setDeathdate(deathdate);
065     * </pre>
066     * 
067     * <p>
068     * <b>Getting the time of death</b>
069     * </p>
070     * 
071     * <pre>
072     * VCard vcard = ...
073     * DeathdateType deathdate = vcard.getDeathdate();
074     * if (deathdate != null){
075     *   if (deathdate.getDate() != null){
076     *     System.out.println(deathdate.getDate());
077     *   } else if (deathdate.getReducedAccuracyDate() != null){
078     *     System.out.println(deathdate.getReducedAccuracyDate());
079     *   } else if (deathdate.getText() != null){
080     *     System.out.println(deathdate.getText());
081     *   }
082     * }
083     * </pre>
084     * 
085     * <p>
086     * vCard property name: DEATHDATE
087     * </p>
088     * <p>
089     * vCard versions: 4.0
090     * </p>
091     * @author Michael Angstadt
092     * @see <a href="http://tools.ietf.org/html/rfc6474">RFC 6474</a>
093     */
094    public class DeathdateType extends DateOrTimeType {
095            public static final String NAME = "DEATHDATE";
096    
097            public DeathdateType() {
098                    super(NAME);
099            }
100    
101            /**
102             * @param date the time of death
103             */
104            public DeathdateType(Date date) {
105                    super(NAME, date);
106            }
107    
108            @Override
109            public VCardVersion[] getSupportedVersions() {
110                    return new VCardVersion[] { VCardVersion.V4_0 };
111            }
112    
113            /**
114             * Gets the LANGUAGE parameter.
115             * @return the language or null if not set
116             * @see VCardSubTypes#getLanguage
117             */
118            public String getLanguage() {
119                    return subTypes.getLanguage();
120            }
121    
122            /**
123             * Sets the LANGUAGE parameter.
124             * @param language the language or null to remove
125             * @see VCardSubTypes#setLanguage
126             */
127            public void setLanguage(String language) {
128                    subTypes.setLanguage(language);
129            }
130    }