java/Postak/src/cz/frantovo/postak/InternetAddressKomu.java
author František Kučera <franta-hg@frantovo.cz>
Sat, 28 Feb 2009 18:06:12 +0100
changeset 4 dfb345ef9452
parent 0 e76872ad5226
permissions -rw-r--r--
Drobnosti a serializace
     1 package cz.frantovo.postak;
     2 
     3 import java.io.UnsupportedEncodingException;
     4 import javax.mail.Message.RecipientType;
     5 import javax.mail.internet.InternetAddress;
     6 
     7 /**
     8  * Rozšíření InternetAddress tak, aby obsahovala i informaci o typu příjemce: komu, kopie, skrytá
     9  * @author fiki
    10  */
    11 public class InternetAddressKomu extends InternetAddress {
    12     private static final long serialVersionUID = 5616579686371892208L;
    13 
    14     private RecipientType typ = RecipientType.BCC;
    15 
    16     /**
    17      * Typ příjemce: komu, kopie, skrytý.
    18      * Výchozí hodnota je BCC
    19      */
    20     public RecipientType getTyp() {
    21         return typ;
    22     }
    23 
    24     /**
    25      * Typ příjemce: komu, kopie, skrytý.
    26      * Výchozí hodnota je BCC
    27      */
    28     public void setTyp(RecipientType typ) {
    29         this.typ = typ;
    30     }
    31 
    32     @Override
    33     public String getPersonal() {
    34         String sup = super.getPersonal();
    35         if (sup == null || sup.length() < 1) {
    36             return getAddress();
    37         } else {
    38             return sup;
    39         }
    40     }
    41 
    42     public InternetAddressKomu() {
    43         super();
    44     }
    45 
    46     /** Výchozí typ příjemce: skrytá kopie */
    47     public InternetAddressKomu(String adresa, String jmeno) throws UnsupportedEncodingException {
    48         super(adresa, jmeno);
    49     }
    50 
    51     public InternetAddressKomu(String adresa, String jmeno, RecipientType typ) throws UnsupportedEncodingException {
    52         super(adresa, jmeno);
    53         setTyp(typ);
    54     }
    55 }