src/net/fortuna/ical4j/model/property/Attendee.java

Tue, 10 Feb 2015 18:12:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 18:12:00 +0100
changeset 0
fb9019fb1bf7
permissions
-rw-r--r--

Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.

     1 /**
     2  * Copyright (c) 2012, Ben Fortuna
     3  * All rights reserved.
     4  *
     5  * Redistribution and use in source and binary forms, with or without
     6  * modification, are permitted provided that the following conditions
     7  * are met:
     8  *
     9  *  o Redistributions of source code must retain the above copyright
    10  * notice, this list of conditions and the following disclaimer.
    11  *
    12  *  o Redistributions in binary form must reproduce the above copyright
    13  * notice, this list of conditions and the following disclaimer in the
    14  * documentation and/or other materials provided with the distribution.
    15  *
    16  *  o Neither the name of Ben Fortuna nor the names of any other contributors
    17  * may be used to endorse or promote products derived from this software
    18  * without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  */
    32 package net.fortuna.ical4j.model.property;
    34 import java.io.IOException;
    35 import java.net.URI;
    36 import java.net.URISyntaxException;
    37 import java.text.ParseException;
    39 import net.fortuna.ical4j.model.Parameter;
    40 import net.fortuna.ical4j.model.ParameterList;
    41 import net.fortuna.ical4j.model.Property;
    42 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    43 import net.fortuna.ical4j.model.ValidationException;
    44 import net.fortuna.ical4j.util.ParameterValidator;
    45 import net.fortuna.ical4j.util.Strings;
    46 import net.fortuna.ical4j.util.Uris;
    48 /**
    49  * $Id$
    50  * 
    51  * Created: [Apr 6, 2004]
    52  *
    53  * Defines an ATTENDEE iCalendar component property.
    54  * @author benf
    55  */
    56 public class Attendee extends Property {
    58     private static final long serialVersionUID = 8430929418723298803L;
    60     private URI calAddress;
    62     /**
    63      * Default constructor.
    64      */
    65     public Attendee() {
    66         super(ATTENDEE, PropertyFactoryImpl.getInstance());
    67     }
    69     /**
    70      * @param aValue a value string for this component
    71      * @throws URISyntaxException where the specified value string is not a valid uri
    72      */
    73     public Attendee(final String aValue) throws URISyntaxException {
    74         super(ATTENDEE, PropertyFactoryImpl.getInstance());
    75         setValue(aValue);
    76     }
    78     /**
    79      * @param aList a list of parameters for this component
    80      * @param aValue a value string for this component
    81      * @throws URISyntaxException where the specified value string is not a valid uri
    82      */
    83     public Attendee(final ParameterList aList, final String aValue)
    84             throws URISyntaxException {
    85         super(ATTENDEE, aList, PropertyFactoryImpl.getInstance());
    86         setValue(aValue);
    87     }
    89     /**
    90      * @param aUri a URI
    91      */
    92     public Attendee(final URI aUri) {
    93         super(ATTENDEE, PropertyFactoryImpl.getInstance());
    94         calAddress = aUri;
    95     }
    97     /**
    98      * @param aList a list of parameters for this component
    99      * @param aUri a URI
   100      */
   101     public Attendee(final ParameterList aList, final URI aUri) {
   102         super(ATTENDEE, aList, PropertyFactoryImpl.getInstance());
   103         calAddress = aUri;
   104     }
   106     /**
   107      * {@inheritDoc}
   108      */
   109     public final void setValue(final String aValue) throws URISyntaxException {
   110         calAddress = Uris.create(aValue);
   111     }
   113     /**
   114      * {@inheritDoc}
   115      */
   116     public final void validate() throws ValidationException {
   118         /*
   119          * ; the following are optional, ; but MUST NOT occur more than once (";" cutypeparam) / (";"memberparam) / (";"
   120          * roleparam) / (";" partstatparam) / (";" rsvpparam) / (";" deltoparam) / (";" delfromparam) / (";"
   121          * sentbyparam) / (";"cnparam) / (";" dirparam) / (";" languageparam) /
   122          */
   123         ParameterValidator.getInstance().assertOneOrLess(Parameter.CUTYPE,
   124                 getParameters());
   125         ParameterValidator.getInstance().assertOneOrLess(Parameter.MEMBER,
   126                 getParameters());
   127         ParameterValidator.getInstance().assertOneOrLess(Parameter.ROLE,
   128                 getParameters());
   129         ParameterValidator.getInstance().assertOneOrLess(Parameter.PARTSTAT,
   130                 getParameters());
   131         ParameterValidator.getInstance().assertOneOrLess(Parameter.RSVP,
   132                 getParameters());
   133         ParameterValidator.getInstance().assertOneOrLess(
   134                 Parameter.DELEGATED_TO, getParameters());
   135         ParameterValidator.getInstance().assertOneOrLess(
   136                 Parameter.DELEGATED_FROM, getParameters());
   137         ParameterValidator.getInstance().assertOneOrLess(Parameter.SENT_BY,
   138                 getParameters());
   139         ParameterValidator.getInstance().assertOneOrLess(Parameter.CN,
   140                 getParameters());
   141         ParameterValidator.getInstance().assertOneOrLess(Parameter.DIR,
   142                 getParameters());
   143         ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
   144                 getParameters());
   146         /* scheduleagent and schedulestatus added for CalDAV scheduling
   147          */
   148         ParameterValidator.getInstance().assertOneOrLess(Parameter.SCHEDULE_AGENT,
   149                                                          getParameters());
   150         ParameterValidator.getInstance().assertOneOrLess(Parameter.SCHEDULE_STATUS,
   151                                                          getParameters());
   152         /*
   153          * ; the following is optional, ; and MAY occur more than once (";" xparam)
   154          */
   155     }
   157     /**
   158      * @return Returns the calAddress.
   159      */
   160     public final URI getCalAddress() {
   161         return calAddress;
   162     }
   164     /**
   165      * {@inheritDoc}
   166      */
   167     public final String getValue() {
   168         return Uris.decode(Strings.valueOf(getCalAddress()));
   169     }
   171     /**
   172      * @param calAddress The calAddress to set.
   173      */
   174     public final void setCalAddress(final URI calAddress) {
   175         this.calAddress = calAddress;
   176     }
   178     /**
   179      * {@inheritDoc}
   180      */
   181     public final Property copy() throws IOException, URISyntaxException, ParseException {
   182         // URI are immutable
   183         return new Attendee(new ParameterList(getParameters(), false), calAddress);  
   184     }
   185 }

mercurial