src/net/fortuna/ical4j/model/property/Organizer.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.

michael@0 1 /**
michael@0 2 * Copyright (c) 2012, Ben Fortuna
michael@0 3 * All rights reserved.
michael@0 4 *
michael@0 5 * Redistribution and use in source and binary forms, with or without
michael@0 6 * modification, are permitted provided that the following conditions
michael@0 7 * are met:
michael@0 8 *
michael@0 9 * o Redistributions of source code must retain the above copyright
michael@0 10 * notice, this list of conditions and the following disclaimer.
michael@0 11 *
michael@0 12 * o Redistributions in binary form must reproduce the above copyright
michael@0 13 * notice, this list of conditions and the following disclaimer in the
michael@0 14 * documentation and/or other materials provided with the distribution.
michael@0 15 *
michael@0 16 * o Neither the name of Ben Fortuna nor the names of any other contributors
michael@0 17 * may be used to endorse or promote products derived from this software
michael@0 18 * without specific prior written permission.
michael@0 19 *
michael@0 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
michael@0 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
michael@0 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
michael@0 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
michael@0 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
michael@0 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
michael@0 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
michael@0 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 31 */
michael@0 32 package net.fortuna.ical4j.model.property;
michael@0 33
michael@0 34 import java.net.URI;
michael@0 35 import java.net.URISyntaxException;
michael@0 36
michael@0 37 import net.fortuna.ical4j.model.Parameter;
michael@0 38 import net.fortuna.ical4j.model.ParameterList;
michael@0 39 import net.fortuna.ical4j.model.Property;
michael@0 40 import net.fortuna.ical4j.model.PropertyFactoryImpl;
michael@0 41 import net.fortuna.ical4j.model.ValidationException;
michael@0 42 import net.fortuna.ical4j.util.ParameterValidator;
michael@0 43 import net.fortuna.ical4j.util.Strings;
michael@0 44 import net.fortuna.ical4j.util.Uris;
michael@0 45
michael@0 46 /**
michael@0 47 * $Id$
michael@0 48 *
michael@0 49 * Created: [Apr 6, 2004]
michael@0 50 *
michael@0 51 * Defines an ORGANIZER iCalendar component property.
michael@0 52 *
michael@0 53 * <pre>
michael@0 54 * 4.8.4.3 Organizer
michael@0 55 *
michael@0 56 * Property Name: ORGANIZER
michael@0 57 *
michael@0 58 * Purpose: The property defines the organizer for a calendar component.
michael@0 59 *
michael@0 60 * Value Type: CAL-ADDRESS
michael@0 61 *
michael@0 62 * Property Parameters: Non-standard, language, common name, directory
michael@0 63 * entry reference, sent by property parameters can be specified on this
michael@0 64 * property.
michael@0 65 *
michael@0 66 * Conformance: This property MUST be specified in an iCalendar object
michael@0 67 * that specifies a group scheduled calendar entity. This property MUST
michael@0 68 * be specified in an iCalendar object that specifies the publication of
michael@0 69 * a calendar user's busy time. This property MUST NOT be specified in
michael@0 70 * an iCalendar object that specifies only a time zone definition or
michael@0 71 * that defines calendar entities that are not group scheduled entities,
michael@0 72 * but are entities only on a single user's calendar.
michael@0 73 *
michael@0 74 * Description: The property is specified within the &quot;VEVENT&quot;, &quot;VTODO&quot;,
michael@0 75 * &quot;VJOURNAL calendar components to specify the organizer of a group
michael@0 76 * scheduled calendar entity. The property is specified within the
michael@0 77 * &quot;VFREEBUSY&quot; calendar component to specify the calendar user
michael@0 78 * requesting the free or busy time. When publishing a &quot;VFREEBUSY&quot;
michael@0 79 * calendar component, the property is used to specify the calendar that
michael@0 80 * the published busy time came from.
michael@0 81 *
michael@0 82 * The property has the property parameters CN, for specifying the
michael@0 83 * common or display name associated with the &quot;Organizer&quot;, DIR, for
michael@0 84 * specifying a pointer to the directory information associated with the
michael@0 85 * &quot;Organizer&quot;, SENT-BY, for specifying another calendar user that is
michael@0 86 * acting on behalf of the &quot;Organizer&quot;. The non-standard parameters may
michael@0 87 * also be specified on this property. If the LANGUAGE property
michael@0 88 * parameter is specified, the identified language applies to the CN
michael@0 89 * parameter value.
michael@0 90 *
michael@0 91 * Format Definition: The property is defined by the following notation:
michael@0 92 *
michael@0 93 * organizer = &quot;ORGANIZER&quot; orgparam &quot;:&quot;
michael@0 94 * cal-address CRLF
michael@0 95 *
michael@0 96 * orgparam = *(
michael@0 97 *
michael@0 98 * ; the following are optional,
michael@0 99 * ; but MUST NOT occur more than once
michael@0 100 *
michael@0 101 * (&quot;;&quot; cnparam) / (&quot;;&quot; dirparam) / (&quot;;&quot; sentbyparam) /
michael@0 102 * (&quot;;&quot; languageparam) /
michael@0 103 *
michael@0 104 * ; the following is optional,
michael@0 105 * ; and MAY occur more than once
michael@0 106 *
michael@0 107 * (&quot;;&quot; xparam)
michael@0 108 *
michael@0 109 * )
michael@0 110 *
michael@0 111 * Example: The following is an example of this property:
michael@0 112 *
michael@0 113 * ORGANIZER;CN=John Smith:MAILTO:jsmith@host1.com
michael@0 114 *
michael@0 115 * The following is an example of this property with a pointer to the
michael@0 116 * directory information associated with the organizer:
michael@0 117 *
michael@0 118 * ORGANIZER;CN=JohnSmith;DIR=&quot;ldap://host.com:6666/o=3DDC%20Associ
michael@0 119 * ates,c=3DUS??(cn=3DJohn%20Smith)&quot;:MAILTO:jsmith@host1.com
michael@0 120 *
michael@0 121 * The following is an example of this property used by another calendar
michael@0 122 * user who is acting on behalf of the organizer, with responses
michael@0 123 * intended to be sent back to the organizer, not the other calendar
michael@0 124 * user:
michael@0 125 *
michael@0 126 * ORGANIZER;SENT-BY=&quot;MAILTO:jane_doe@host.com&quot;:
michael@0 127 * MAILTO:jsmith@host1.com
michael@0 128 * </pre>
michael@0 129 *
michael@0 130 * @author Ben Fortuna
michael@0 131 */
michael@0 132 public class Organizer extends Property {
michael@0 133
michael@0 134 private static final long serialVersionUID = -5216965653165090725L;
michael@0 135
michael@0 136 private URI calAddress;
michael@0 137
michael@0 138 /**
michael@0 139 * Default constructor.
michael@0 140 */
michael@0 141 public Organizer() {
michael@0 142 super(ORGANIZER, PropertyFactoryImpl.getInstance());
michael@0 143 }
michael@0 144
michael@0 145 /**
michael@0 146 * Constructs a new instance with the specified value.
michael@0 147 * @param value an organizer URI
michael@0 148 * @throws URISyntaxException where the specified value is not a valid URI
michael@0 149 */
michael@0 150 public Organizer(String value) throws URISyntaxException {
michael@0 151 super(ORGANIZER, PropertyFactoryImpl.getInstance());
michael@0 152 setValue(value);
michael@0 153 }
michael@0 154
michael@0 155 /**
michael@0 156 * @param aList a list of parameters for this component
michael@0 157 * @param aValue a value string for this component
michael@0 158 * @throws URISyntaxException where the specified value string is not a valid uri
michael@0 159 */
michael@0 160 public Organizer(final ParameterList aList, final String aValue)
michael@0 161 throws URISyntaxException {
michael@0 162 super(ORGANIZER, aList, PropertyFactoryImpl.getInstance());
michael@0 163 setValue(aValue);
michael@0 164 }
michael@0 165
michael@0 166 /**
michael@0 167 * @param aUri a URI representation of a calendar address
michael@0 168 */
michael@0 169 public Organizer(final URI aUri) {
michael@0 170 super(ORGANIZER, PropertyFactoryImpl.getInstance());
michael@0 171 calAddress = aUri;
michael@0 172 }
michael@0 173
michael@0 174 /**
michael@0 175 * @param aList a list of parameters for this component
michael@0 176 * @param aUri a URI representation of a calendar address
michael@0 177 */
michael@0 178 public Organizer(final ParameterList aList, final URI aUri) {
michael@0 179 super(ORGANIZER, aList, PropertyFactoryImpl.getInstance());
michael@0 180 calAddress = aUri;
michael@0 181 }
michael@0 182
michael@0 183 /**
michael@0 184 * {@inheritDoc}
michael@0 185 */
michael@0 186 public final void validate() throws ValidationException {
michael@0 187
michael@0 188 /*
michael@0 189 * ; the following are optional, ; but MUST NOT occur more than once (";" cnparam) / (";" dirparam) / (";"
michael@0 190 * sentbyparam) / (";" languageparam) /
michael@0 191 */
michael@0 192 ParameterValidator.getInstance().assertOneOrLess(Parameter.CN,
michael@0 193 getParameters());
michael@0 194 ParameterValidator.getInstance().assertOneOrLess(Parameter.DIR,
michael@0 195 getParameters());
michael@0 196 ParameterValidator.getInstance().assertOneOrLess(Parameter.SENT_BY,
michael@0 197 getParameters());
michael@0 198 ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
michael@0 199 getParameters());
michael@0 200
michael@0 201 /* schedulestatus added for CalDAV scheduling
michael@0 202 */
michael@0 203 ParameterValidator.getInstance().assertOneOrLess(Parameter.SCHEDULE_STATUS,
michael@0 204 getParameters());
michael@0 205
michael@0 206 /*
michael@0 207 * ; the following is optional, ; and MAY occur more than once (";" xparam)
michael@0 208 */
michael@0 209 }
michael@0 210
michael@0 211 /**
michael@0 212 * @return Returns the calAddress.
michael@0 213 */
michael@0 214 public final URI getCalAddress() {
michael@0 215 return calAddress;
michael@0 216 }
michael@0 217
michael@0 218 /**
michael@0 219 * {@inheritDoc}
michael@0 220 */
michael@0 221 public final void setValue(final String aValue) throws URISyntaxException {
michael@0 222 calAddress = Uris.create(aValue);
michael@0 223 }
michael@0 224
michael@0 225 /**
michael@0 226 * {@inheritDoc}
michael@0 227 */
michael@0 228 public final String getValue() {
michael@0 229 return Uris.decode(Strings.valueOf(getCalAddress()));
michael@0 230 }
michael@0 231
michael@0 232 /**
michael@0 233 * @param calAddress The calAddress to set.
michael@0 234 */
michael@0 235 public final void setCalAddress(final URI calAddress) {
michael@0 236 this.calAddress = calAddress;
michael@0 237 }
michael@0 238 }

mercurial