src/net/fortuna/ical4j/model/AddressList.java

branch
ICAL4J_EMBED_1
changeset 15
cc93757aeca3
parent 14
5ae3e5665a0b
child 18
6dcaece8ec41
     1.1 --- a/src/net/fortuna/ical4j/model/AddressList.java	Thu Feb 12 18:02:00 2015 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,147 +0,0 @@
     1.4 -/**
     1.5 - * Copyright (c) 2012, Ben Fortuna
     1.6 - * All rights reserved.
     1.7 - *
     1.8 - * Redistribution and use in source and binary forms, with or without
     1.9 - * modification, are permitted provided that the following conditions
    1.10 - * are met:
    1.11 - *
    1.12 - *  o Redistributions of source code must retain the above copyright
    1.13 - * notice, this list of conditions and the following disclaimer.
    1.14 - *
    1.15 - *  o Redistributions in binary form must reproduce the above copyright
    1.16 - * notice, this list of conditions and the following disclaimer in the
    1.17 - * documentation and/or other materials provided with the distribution.
    1.18 - *
    1.19 - *  o Neither the name of Ben Fortuna nor the names of any other contributors
    1.20 - * may be used to endorse or promote products derived from this software
    1.21 - * without specific prior written permission.
    1.22 - *
    1.23 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.24 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.25 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.26 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    1.27 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.28 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.29 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.30 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.31 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.32 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.33 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.34 - */
    1.35 -package net.fortuna.ical4j.model;
    1.36 -
    1.37 -import java.io.Serializable;
    1.38 -import java.net.URI;
    1.39 -import java.net.URISyntaxException;
    1.40 -import java.util.Iterator;
    1.41 -import java.util.List;
    1.42 -import java.util.StringTokenizer;
    1.43 -
    1.44 -import net.fortuna.ical4j.util.CompatibilityHints;
    1.45 -import net.fortuna.ical4j.util.Strings;
    1.46 -import net.fortuna.ical4j.util.Uris;
    1.47 -import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
    1.48 -
    1.49 -/**
    1.50 - * $Id$ [23-Apr-2004]
    1.51 - *
    1.52 - * Defines a list of iCalendar addresses.
    1.53 - * @author Ben Fortuna
    1.54 - */
    1.55 -public class AddressList implements Serializable {
    1.56 -
    1.57 -    private static final long serialVersionUID = 81383256078213569L;
    1.58 -
    1.59 -    private List addresses;
    1.60 -
    1.61 -    /**
    1.62 -     * Default constructor.
    1.63 -     */
    1.64 -    public AddressList() {
    1.65 -        addresses = new CopyOnWriteArrayList();
    1.66 -    }
    1.67 -
    1.68 -    /**
    1.69 -     * Parses the specified string representation to create a list of addresses.
    1.70 -     * @param aValue a string representation of a list of addresses
    1.71 -     * @throws URISyntaxException where the specified string is not a valid representation
    1.72 -     */
    1.73 -    public AddressList(final String aValue) throws URISyntaxException {
    1.74 -        addresses = new CopyOnWriteArrayList();
    1.75 -        final StringTokenizer t = new StringTokenizer(aValue, ",");
    1.76 -        while (t.hasMoreTokens()) {
    1.77 -
    1.78 -            try {
    1.79 -                addresses.add(new URI(Uris.encode(Strings
    1.80 -                        .unquote(t.nextToken()))));
    1.81 -            }
    1.82 -            catch (URISyntaxException use) {
    1.83 -                // ignore invalid addresses if relaxed parsing is enabled..
    1.84 -                if (!CompatibilityHints.isHintEnabled(
    1.85 -                        CompatibilityHints.KEY_RELAXED_PARSING)) {
    1.86 -
    1.87 -                    throw use;
    1.88 -                }
    1.89 -            }
    1.90 -        }
    1.91 -    }
    1.92 -
    1.93 -    /**
    1.94 -     * {@inheritDoc}
    1.95 -     */
    1.96 -    public final String toString() {
    1.97 -        final StringBuffer b = new StringBuffer();
    1.98 -        for (final Iterator i = addresses.iterator(); i.hasNext();) {
    1.99 -            b.append(Strings.quote(Uris.decode(Strings.valueOf(i.next()))));
   1.100 -            if (i.hasNext()) {
   1.101 -                b.append(',');
   1.102 -            }
   1.103 -        }
   1.104 -        return b.toString();
   1.105 -    }
   1.106 -
   1.107 -    /**
   1.108 -     * Add an address to the list.
   1.109 -     * @param address the address to add
   1.110 -     * @return true
   1.111 -     * @see List#add(java.lang.Object)
   1.112 -     */
   1.113 -    public final boolean add(final URI address) {
   1.114 -        return addresses.add(address);
   1.115 -    }
   1.116 -
   1.117 -    /**
   1.118 -     * @return boolean indicates if the list is empty
   1.119 -     * @see List#isEmpty()
   1.120 -     */
   1.121 -    public final boolean isEmpty() {
   1.122 -        return addresses.isEmpty();
   1.123 -    }
   1.124 -
   1.125 -    /**
   1.126 -     * @return an iterator
   1.127 -     * @see List#iterator()
   1.128 -     */
   1.129 -    public final Iterator iterator() {
   1.130 -        return addresses.iterator();
   1.131 -    }
   1.132 -
   1.133 -    /**
   1.134 -     * Remove an address from the list.
   1.135 -     * @param address the address to remove
   1.136 -     * @return true if the list contained the specified address
   1.137 -     * @see List#remove(java.lang.Object)
   1.138 -     */
   1.139 -    public final boolean remove(final URI address) {
   1.140 -        return addresses.remove(address);
   1.141 -    }
   1.142 -
   1.143 -    /**
   1.144 -     * @return the number of addresses in the list
   1.145 -     * @see List#size()
   1.146 -     */
   1.147 -    public final int size() {
   1.148 -        return addresses.size();
   1.149 -    }
   1.150 -}

mercurial