Tue, 10 Feb 2015 19:58:00 +0100
Upgrade the upgraded ical4j component to use org.apache.commons.lang3.
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; |
michael@0 | 33 | |
michael@0 | 34 | import java.net.URISyntaxException; |
michael@0 | 35 | |
michael@0 | 36 | import net.fortuna.ical4j.model.parameter.Abbrev; |
michael@0 | 37 | import net.fortuna.ical4j.model.parameter.AltRep; |
michael@0 | 38 | import net.fortuna.ical4j.model.parameter.Cn; |
michael@0 | 39 | import net.fortuna.ical4j.model.parameter.CuType; |
michael@0 | 40 | import net.fortuna.ical4j.model.parameter.DelegatedFrom; |
michael@0 | 41 | import net.fortuna.ical4j.model.parameter.DelegatedTo; |
michael@0 | 42 | import net.fortuna.ical4j.model.parameter.Dir; |
michael@0 | 43 | import net.fortuna.ical4j.model.parameter.Encoding; |
michael@0 | 44 | import net.fortuna.ical4j.model.parameter.FbType; |
michael@0 | 45 | import net.fortuna.ical4j.model.parameter.FmtType; |
michael@0 | 46 | import net.fortuna.ical4j.model.parameter.Language; |
michael@0 | 47 | import net.fortuna.ical4j.model.parameter.Member; |
michael@0 | 48 | import net.fortuna.ical4j.model.parameter.PartStat; |
michael@0 | 49 | import net.fortuna.ical4j.model.parameter.Range; |
michael@0 | 50 | import net.fortuna.ical4j.model.parameter.RelType; |
michael@0 | 51 | import net.fortuna.ical4j.model.parameter.Related; |
michael@0 | 52 | import net.fortuna.ical4j.model.parameter.Role; |
michael@0 | 53 | import net.fortuna.ical4j.model.parameter.Rsvp; |
michael@0 | 54 | import net.fortuna.ical4j.model.parameter.ScheduleAgent; |
michael@0 | 55 | import net.fortuna.ical4j.model.parameter.ScheduleStatus; |
michael@0 | 56 | import net.fortuna.ical4j.model.parameter.SentBy; |
michael@0 | 57 | import net.fortuna.ical4j.model.parameter.Type; |
michael@0 | 58 | import net.fortuna.ical4j.model.parameter.TzId; |
michael@0 | 59 | import net.fortuna.ical4j.model.parameter.Value; |
michael@0 | 60 | import net.fortuna.ical4j.model.parameter.Vvenue; |
michael@0 | 61 | import net.fortuna.ical4j.model.parameter.XParameter; |
michael@0 | 62 | import net.fortuna.ical4j.util.Strings; |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * A factory for creating iCalendar parameters. |
michael@0 | 66 | * |
michael@0 | 67 | * $Id $ |
michael@0 | 68 | * |
michael@0 | 69 | * [05-Apr-2004] |
michael@0 | 70 | * |
michael@0 | 71 | * @author Ben Fortuna |
michael@0 | 72 | */ |
michael@0 | 73 | public class ParameterFactoryImpl extends AbstractContentFactory implements ParameterFactory { |
michael@0 | 74 | |
michael@0 | 75 | private static final long serialVersionUID = -4034423507432249165L; |
michael@0 | 76 | |
michael@0 | 77 | private static ParameterFactoryImpl instance = new ParameterFactoryImpl(); |
michael@0 | 78 | |
michael@0 | 79 | protected ParameterFactoryImpl() { |
michael@0 | 80 | registerDefaultFactory(Parameter.ABBREV, new AbbrevFactory()); |
michael@0 | 81 | registerDefaultFactory(Parameter.ALTREP, new AltRepFactory()); |
michael@0 | 82 | registerDefaultFactory(Parameter.CN, new CnFactory()); |
michael@0 | 83 | registerDefaultFactory(Parameter.CUTYPE, new CuTypeFactory()); |
michael@0 | 84 | registerDefaultFactory(Parameter.DELEGATED_FROM, new DelegatedFromFactory()); |
michael@0 | 85 | registerDefaultFactory(Parameter.DELEGATED_TO, new DelegatedToFactory()); |
michael@0 | 86 | registerDefaultFactory(Parameter.DIR, new DirFactory()); |
michael@0 | 87 | registerDefaultFactory(Parameter.ENCODING, new EncodingFactory()); |
michael@0 | 88 | registerDefaultFactory(Parameter.FMTTYPE, new FmtTypeFactory()); |
michael@0 | 89 | registerDefaultFactory(Parameter.FBTYPE, new FbTypeFactory()); |
michael@0 | 90 | registerDefaultFactory(Parameter.LANGUAGE, new LanguageFactory()); |
michael@0 | 91 | registerDefaultFactory(Parameter.MEMBER, new MemberFactory()); |
michael@0 | 92 | registerDefaultFactory(Parameter.PARTSTAT, new PartStatFactory()); |
michael@0 | 93 | registerDefaultFactory(Parameter.RANGE, new RangeFactory()); |
michael@0 | 94 | registerDefaultFactory(Parameter.RELATED, new RelatedFactory()); |
michael@0 | 95 | registerDefaultFactory(Parameter.RELTYPE, new RelTypeFactory()); |
michael@0 | 96 | registerDefaultFactory(Parameter.ROLE, new RoleFactory()); |
michael@0 | 97 | registerDefaultFactory(Parameter.RSVP, new RsvpFactory()); |
michael@0 | 98 | registerDefaultFactory(Parameter.SCHEDULE_AGENT, new ScheduleAgentFactory()); |
michael@0 | 99 | registerDefaultFactory(Parameter.SCHEDULE_STATUS, new ScheduleStatusFactory()); |
michael@0 | 100 | registerDefaultFactory(Parameter.SENT_BY, new SentByFactory()); |
michael@0 | 101 | registerDefaultFactory(Parameter.TYPE, new TypeFactory()); |
michael@0 | 102 | registerDefaultFactory(Parameter.TZID, new TzIdFactory()); |
michael@0 | 103 | registerDefaultFactory(Parameter.VALUE, new ValueFactory()); |
michael@0 | 104 | registerDefaultFactory(Parameter.VVENUE, new VvenueFactory()); |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | /** |
michael@0 | 108 | * @return Returns the instance. |
michael@0 | 109 | */ |
michael@0 | 110 | public static ParameterFactoryImpl getInstance() { |
michael@0 | 111 | return instance; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Creates a parameter. |
michael@0 | 116 | * @param name name of the parameter |
michael@0 | 117 | * @param value a parameter value |
michael@0 | 118 | * @return a component |
michael@0 | 119 | * @throws URISyntaxException thrown when the specified string is not a valid representation of a URI for selected |
michael@0 | 120 | * parameters |
michael@0 | 121 | */ |
michael@0 | 122 | public Parameter createParameter(final String name, final String value) |
michael@0 | 123 | throws URISyntaxException { |
michael@0 | 124 | final ParameterFactory factory = (ParameterFactory) getFactory(name); |
michael@0 | 125 | Parameter parameter = null; |
michael@0 | 126 | if (factory != null) { |
michael@0 | 127 | parameter = factory.createParameter(name, value); |
michael@0 | 128 | } |
michael@0 | 129 | else if (isExperimentalName(name)) { |
michael@0 | 130 | parameter = new XParameter(name, value); |
michael@0 | 131 | } |
michael@0 | 132 | else if (allowIllegalNames()) { |
michael@0 | 133 | parameter = new XParameter(name, value); |
michael@0 | 134 | } |
michael@0 | 135 | else { |
michael@0 | 136 | throw new IllegalArgumentException("Invalid parameter name: " |
michael@0 | 137 | + name); |
michael@0 | 138 | } |
michael@0 | 139 | return parameter; |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * @param name |
michael@0 | 144 | * @return |
michael@0 | 145 | */ |
michael@0 | 146 | private boolean isExperimentalName(final String name) { |
michael@0 | 147 | return name.startsWith(Parameter.EXPERIMENTAL_PREFIX) |
michael@0 | 148 | && name.length() > Parameter.EXPERIMENTAL_PREFIX.length(); |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | private static class AbbrevFactory implements ParameterFactory { |
michael@0 | 152 | private static final long serialVersionUID = 1L; |
michael@0 | 153 | |
michael@0 | 154 | public Parameter createParameter(final String name, final String value) throws URISyntaxException { |
michael@0 | 155 | return new Abbrev(value); |
michael@0 | 156 | } |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | private static class AltRepFactory implements ParameterFactory { |
michael@0 | 160 | private static final long serialVersionUID = 1L; |
michael@0 | 161 | |
michael@0 | 162 | public Parameter createParameter(final String name, final String value) throws URISyntaxException { |
michael@0 | 163 | return new AltRep(value); |
michael@0 | 164 | } |
michael@0 | 165 | } |
michael@0 | 166 | |
michael@0 | 167 | private static class CnFactory implements ParameterFactory { |
michael@0 | 168 | private static final long serialVersionUID = 1L; |
michael@0 | 169 | |
michael@0 | 170 | public Parameter createParameter(final String name, |
michael@0 | 171 | final String value) throws URISyntaxException { |
michael@0 | 172 | return new Cn(value); |
michael@0 | 173 | } |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | private static class CuTypeFactory implements ParameterFactory { |
michael@0 | 177 | private static final long serialVersionUID = 1L; |
michael@0 | 178 | |
michael@0 | 179 | public Parameter createParameter(final String name, final String value) throws URISyntaxException { |
michael@0 | 180 | CuType parameter = new CuType(value); |
michael@0 | 181 | if (CuType.INDIVIDUAL.equals(parameter)) { |
michael@0 | 182 | parameter = CuType.INDIVIDUAL; |
michael@0 | 183 | } |
michael@0 | 184 | else if (CuType.GROUP.equals(parameter)) { |
michael@0 | 185 | parameter = CuType.GROUP; |
michael@0 | 186 | } |
michael@0 | 187 | else if (CuType.RESOURCE.equals(parameter)) { |
michael@0 | 188 | parameter = CuType.RESOURCE; |
michael@0 | 189 | } |
michael@0 | 190 | else if (CuType.ROOM.equals(parameter)) { |
michael@0 | 191 | parameter = CuType.ROOM; |
michael@0 | 192 | } |
michael@0 | 193 | else if (CuType.UNKNOWN.equals(parameter)) { |
michael@0 | 194 | parameter = CuType.UNKNOWN; |
michael@0 | 195 | } |
michael@0 | 196 | return parameter; |
michael@0 | 197 | } |
michael@0 | 198 | } |
michael@0 | 199 | |
michael@0 | 200 | private static class DelegatedFromFactory implements ParameterFactory { |
michael@0 | 201 | private static final long serialVersionUID = 1L; |
michael@0 | 202 | |
michael@0 | 203 | public Parameter createParameter(final String name, |
michael@0 | 204 | final String value) throws URISyntaxException { |
michael@0 | 205 | return new DelegatedFrom(value); |
michael@0 | 206 | } |
michael@0 | 207 | } |
michael@0 | 208 | |
michael@0 | 209 | private static class DelegatedToFactory implements ParameterFactory { |
michael@0 | 210 | private static final long serialVersionUID = 1L; |
michael@0 | 211 | |
michael@0 | 212 | public Parameter createParameter(final String name, |
michael@0 | 213 | final String value) throws URISyntaxException { |
michael@0 | 214 | return new DelegatedTo(value); |
michael@0 | 215 | } |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | private static class DirFactory implements ParameterFactory { |
michael@0 | 219 | private static final long serialVersionUID = 1L; |
michael@0 | 220 | |
michael@0 | 221 | public Parameter createParameter(final String name, |
michael@0 | 222 | final String value) throws URISyntaxException { |
michael@0 | 223 | return new Dir(value); |
michael@0 | 224 | } |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | private static class EncodingFactory implements ParameterFactory { |
michael@0 | 228 | private static final long serialVersionUID = 1L; |
michael@0 | 229 | |
michael@0 | 230 | public Parameter createParameter(final String name, |
michael@0 | 231 | final String value) throws URISyntaxException { |
michael@0 | 232 | Encoding parameter = new Encoding(value); |
michael@0 | 233 | if (Encoding.EIGHT_BIT.equals(parameter)) { |
michael@0 | 234 | parameter = Encoding.EIGHT_BIT; |
michael@0 | 235 | } |
michael@0 | 236 | else if (Encoding.BASE64.equals(parameter)) { |
michael@0 | 237 | parameter = Encoding.BASE64; |
michael@0 | 238 | } |
michael@0 | 239 | return parameter; |
michael@0 | 240 | } |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | private static class FmtTypeFactory implements ParameterFactory { |
michael@0 | 244 | private static final long serialVersionUID = 1L; |
michael@0 | 245 | |
michael@0 | 246 | public Parameter createParameter(final String name, |
michael@0 | 247 | final String value) throws URISyntaxException { |
michael@0 | 248 | return new FmtType(value); |
michael@0 | 249 | } |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | private static class FbTypeFactory implements ParameterFactory { |
michael@0 | 253 | private static final long serialVersionUID = 1L; |
michael@0 | 254 | |
michael@0 | 255 | public Parameter createParameter(final String name, |
michael@0 | 256 | final String value) throws URISyntaxException { |
michael@0 | 257 | FbType parameter = new FbType(value); |
michael@0 | 258 | if (FbType.FREE.equals(parameter)) { |
michael@0 | 259 | parameter = FbType.FREE; |
michael@0 | 260 | } |
michael@0 | 261 | else if (FbType.BUSY.equals(parameter)) { |
michael@0 | 262 | parameter = FbType.BUSY; |
michael@0 | 263 | } |
michael@0 | 264 | else if (FbType.BUSY_TENTATIVE.equals(parameter)) { |
michael@0 | 265 | parameter = FbType.BUSY_TENTATIVE; |
michael@0 | 266 | } |
michael@0 | 267 | else if (FbType.BUSY_UNAVAILABLE.equals(parameter)) { |
michael@0 | 268 | parameter = FbType.BUSY_UNAVAILABLE; |
michael@0 | 269 | } |
michael@0 | 270 | return parameter; |
michael@0 | 271 | } |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | private static class LanguageFactory implements ParameterFactory { |
michael@0 | 275 | private static final long serialVersionUID = 1L; |
michael@0 | 276 | |
michael@0 | 277 | public Parameter createParameter(final String name, |
michael@0 | 278 | final String value) throws URISyntaxException { |
michael@0 | 279 | return new Language(value); |
michael@0 | 280 | } |
michael@0 | 281 | } |
michael@0 | 282 | |
michael@0 | 283 | private static class MemberFactory implements ParameterFactory { |
michael@0 | 284 | private static final long serialVersionUID = 1L; |
michael@0 | 285 | |
michael@0 | 286 | public Parameter createParameter(final String name, |
michael@0 | 287 | final String value) throws URISyntaxException { |
michael@0 | 288 | return new Member(value); |
michael@0 | 289 | } |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | private static class PartStatFactory implements ParameterFactory { |
michael@0 | 293 | private static final long serialVersionUID = 1L; |
michael@0 | 294 | |
michael@0 | 295 | public Parameter createParameter(final String name, |
michael@0 | 296 | final String value) throws URISyntaxException { |
michael@0 | 297 | PartStat parameter = new PartStat(value); |
michael@0 | 298 | if (PartStat.NEEDS_ACTION.equals(parameter)) { |
michael@0 | 299 | parameter = PartStat.NEEDS_ACTION; |
michael@0 | 300 | } |
michael@0 | 301 | else if (PartStat.ACCEPTED.equals(parameter)) { |
michael@0 | 302 | parameter = PartStat.ACCEPTED; |
michael@0 | 303 | } |
michael@0 | 304 | else if (PartStat.DECLINED.equals(parameter)) { |
michael@0 | 305 | parameter = PartStat.DECLINED; |
michael@0 | 306 | } |
michael@0 | 307 | else if (PartStat.TENTATIVE.equals(parameter)) { |
michael@0 | 308 | parameter = PartStat.TENTATIVE; |
michael@0 | 309 | } |
michael@0 | 310 | else if (PartStat.DELEGATED.equals(parameter)) { |
michael@0 | 311 | parameter = PartStat.DELEGATED; |
michael@0 | 312 | } |
michael@0 | 313 | else if (PartStat.COMPLETED.equals(parameter)) { |
michael@0 | 314 | parameter = PartStat.COMPLETED; |
michael@0 | 315 | } |
michael@0 | 316 | else if (PartStat.IN_PROCESS.equals(parameter)) { |
michael@0 | 317 | parameter = PartStat.IN_PROCESS; |
michael@0 | 318 | } |
michael@0 | 319 | return parameter; |
michael@0 | 320 | } |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | private static class RangeFactory implements ParameterFactory { |
michael@0 | 324 | private static final long serialVersionUID = 1L; |
michael@0 | 325 | |
michael@0 | 326 | public Parameter createParameter(final String name, |
michael@0 | 327 | final String value) throws URISyntaxException { |
michael@0 | 328 | Range parameter = new Range(value); |
michael@0 | 329 | if (Range.THISANDFUTURE.equals(parameter)) { |
michael@0 | 330 | parameter = Range.THISANDFUTURE; |
michael@0 | 331 | } |
michael@0 | 332 | else if (Range.THISANDPRIOR.equals(parameter)) { |
michael@0 | 333 | parameter = Range.THISANDPRIOR; |
michael@0 | 334 | } |
michael@0 | 335 | return parameter; |
michael@0 | 336 | } |
michael@0 | 337 | } |
michael@0 | 338 | |
michael@0 | 339 | private static class RelatedFactory implements ParameterFactory { |
michael@0 | 340 | private static final long serialVersionUID = 1L; |
michael@0 | 341 | |
michael@0 | 342 | public Parameter createParameter(final String name, |
michael@0 | 343 | final String value) throws URISyntaxException { |
michael@0 | 344 | Related parameter = new Related(value); |
michael@0 | 345 | if (Related.START.equals(parameter)) { |
michael@0 | 346 | parameter = Related.START; |
michael@0 | 347 | } |
michael@0 | 348 | else if (Related.END.equals(parameter)) { |
michael@0 | 349 | parameter = Related.END; |
michael@0 | 350 | } |
michael@0 | 351 | return parameter; |
michael@0 | 352 | } |
michael@0 | 353 | } |
michael@0 | 354 | |
michael@0 | 355 | private static class RelTypeFactory implements ParameterFactory { |
michael@0 | 356 | private static final long serialVersionUID = 1L; |
michael@0 | 357 | |
michael@0 | 358 | public Parameter createParameter(final String name, |
michael@0 | 359 | final String value) throws URISyntaxException { |
michael@0 | 360 | RelType parameter = new RelType(value); |
michael@0 | 361 | if (RelType.PARENT.equals(parameter)) { |
michael@0 | 362 | parameter = RelType.PARENT; |
michael@0 | 363 | } |
michael@0 | 364 | else if (RelType.CHILD.equals(parameter)) { |
michael@0 | 365 | parameter = RelType.CHILD; |
michael@0 | 366 | } |
michael@0 | 367 | if (RelType.SIBLING.equals(parameter)) { |
michael@0 | 368 | parameter = RelType.SIBLING; |
michael@0 | 369 | } |
michael@0 | 370 | return parameter; |
michael@0 | 371 | } |
michael@0 | 372 | } |
michael@0 | 373 | |
michael@0 | 374 | private static class RoleFactory implements ParameterFactory { |
michael@0 | 375 | private static final long serialVersionUID = 1L; |
michael@0 | 376 | |
michael@0 | 377 | public Parameter createParameter(final String name, |
michael@0 | 378 | final String value) throws URISyntaxException { |
michael@0 | 379 | Role parameter = new Role(value); |
michael@0 | 380 | if (Role.CHAIR.equals(parameter)) { |
michael@0 | 381 | parameter = Role.CHAIR; |
michael@0 | 382 | } |
michael@0 | 383 | else if (Role.REQ_PARTICIPANT.equals(parameter)) { |
michael@0 | 384 | parameter = Role.REQ_PARTICIPANT; |
michael@0 | 385 | } |
michael@0 | 386 | else if (Role.OPT_PARTICIPANT.equals(parameter)) { |
michael@0 | 387 | parameter = Role.OPT_PARTICIPANT; |
michael@0 | 388 | } |
michael@0 | 389 | else if (Role.NON_PARTICIPANT.equals(parameter)) { |
michael@0 | 390 | parameter = Role.NON_PARTICIPANT; |
michael@0 | 391 | } |
michael@0 | 392 | return parameter; |
michael@0 | 393 | } |
michael@0 | 394 | } |
michael@0 | 395 | |
michael@0 | 396 | private static class RsvpFactory implements ParameterFactory { |
michael@0 | 397 | private static final long serialVersionUID = 1L; |
michael@0 | 398 | |
michael@0 | 399 | public Parameter createParameter(final String name, |
michael@0 | 400 | final String value) throws URISyntaxException { |
michael@0 | 401 | Rsvp parameter = new Rsvp(value); |
michael@0 | 402 | if (Rsvp.TRUE.equals(parameter)) { |
michael@0 | 403 | parameter = Rsvp.TRUE; |
michael@0 | 404 | } |
michael@0 | 405 | else if (Rsvp.FALSE.equals(parameter)) { |
michael@0 | 406 | parameter = Rsvp.FALSE; |
michael@0 | 407 | } |
michael@0 | 408 | return parameter; |
michael@0 | 409 | } |
michael@0 | 410 | } |
michael@0 | 411 | |
michael@0 | 412 | private static class ScheduleAgentFactory implements ParameterFactory { |
michael@0 | 413 | public Parameter createParameter(final String name, |
michael@0 | 414 | final String value) throws URISyntaxException { |
michael@0 | 415 | final ScheduleAgent parameter = new ScheduleAgent(value); |
michael@0 | 416 | if (ScheduleAgent.SERVER.equals(parameter)) { |
michael@0 | 417 | return ScheduleAgent.SERVER; |
michael@0 | 418 | } |
michael@0 | 419 | else if (ScheduleAgent.CLIENT.equals(parameter)) { |
michael@0 | 420 | return ScheduleAgent.CLIENT; |
michael@0 | 421 | } |
michael@0 | 422 | else if (ScheduleAgent.NONE.equals(parameter)) { |
michael@0 | 423 | return ScheduleAgent.NONE; |
michael@0 | 424 | } |
michael@0 | 425 | return parameter; |
michael@0 | 426 | } |
michael@0 | 427 | } |
michael@0 | 428 | |
michael@0 | 429 | private static class ScheduleStatusFactory implements ParameterFactory { |
michael@0 | 430 | public Parameter createParameter(final String name, |
michael@0 | 431 | final String value) throws URISyntaxException { |
michael@0 | 432 | return new ScheduleStatus(value); |
michael@0 | 433 | } |
michael@0 | 434 | } |
michael@0 | 435 | |
michael@0 | 436 | private static class SentByFactory implements ParameterFactory { |
michael@0 | 437 | private static final long serialVersionUID = 1L; |
michael@0 | 438 | |
michael@0 | 439 | public Parameter createParameter(final String name, |
michael@0 | 440 | final String value) throws URISyntaxException { |
michael@0 | 441 | return new SentBy(value); |
michael@0 | 442 | } |
michael@0 | 443 | } |
michael@0 | 444 | |
michael@0 | 445 | private static class VvenueFactory implements ParameterFactory { |
michael@0 | 446 | private static final long serialVersionUID = 1L; |
michael@0 | 447 | |
michael@0 | 448 | public Parameter createParameter(final String name, final String value) |
michael@0 | 449 | throws URISyntaxException { |
michael@0 | 450 | return new Vvenue(value); |
michael@0 | 451 | } |
michael@0 | 452 | } |
michael@0 | 453 | |
michael@0 | 454 | private static class TypeFactory implements ParameterFactory { |
michael@0 | 455 | private static final long serialVersionUID = 1L; |
michael@0 | 456 | |
michael@0 | 457 | public Parameter createParameter(final String name, |
michael@0 | 458 | final String value) throws URISyntaxException { |
michael@0 | 459 | return new Type(value); |
michael@0 | 460 | } |
michael@0 | 461 | } |
michael@0 | 462 | |
michael@0 | 463 | private static class TzIdFactory implements ParameterFactory { |
michael@0 | 464 | private static final long serialVersionUID = 1L; |
michael@0 | 465 | |
michael@0 | 466 | public Parameter createParameter(final String name, |
michael@0 | 467 | final String value) throws URISyntaxException { |
michael@0 | 468 | return new TzId(Strings.unescape(value)); |
michael@0 | 469 | } |
michael@0 | 470 | } |
michael@0 | 471 | |
michael@0 | 472 | private static class ValueFactory implements ParameterFactory { |
michael@0 | 473 | private static final long serialVersionUID = 1L; |
michael@0 | 474 | |
michael@0 | 475 | public Parameter createParameter(final String name, |
michael@0 | 476 | final String value) throws URISyntaxException { |
michael@0 | 477 | Value parameter = new Value(value); |
michael@0 | 478 | if (Value.BINARY.equals(parameter)) { |
michael@0 | 479 | parameter = Value.BINARY; |
michael@0 | 480 | } |
michael@0 | 481 | else if (Value.BOOLEAN.equals(parameter)) { |
michael@0 | 482 | parameter = Value.BOOLEAN; |
michael@0 | 483 | } |
michael@0 | 484 | else if (Value.CAL_ADDRESS.equals(parameter)) { |
michael@0 | 485 | parameter = Value.CAL_ADDRESS; |
michael@0 | 486 | } |
michael@0 | 487 | else if (Value.DATE.equals(parameter)) { |
michael@0 | 488 | parameter = Value.DATE; |
michael@0 | 489 | } |
michael@0 | 490 | else if (Value.DATE_TIME.equals(parameter)) { |
michael@0 | 491 | parameter = Value.DATE_TIME; |
michael@0 | 492 | } |
michael@0 | 493 | else if (Value.DURATION.equals(parameter)) { |
michael@0 | 494 | parameter = Value.DURATION; |
michael@0 | 495 | } |
michael@0 | 496 | else if (Value.FLOAT.equals(parameter)) { |
michael@0 | 497 | parameter = Value.FLOAT; |
michael@0 | 498 | } |
michael@0 | 499 | else if (Value.INTEGER.equals(parameter)) { |
michael@0 | 500 | parameter = Value.INTEGER; |
michael@0 | 501 | } |
michael@0 | 502 | else if (Value.PERIOD.equals(parameter)) { |
michael@0 | 503 | parameter = Value.PERIOD; |
michael@0 | 504 | } |
michael@0 | 505 | else if (Value.RECUR.equals(parameter)) { |
michael@0 | 506 | parameter = Value.RECUR; |
michael@0 | 507 | } |
michael@0 | 508 | else if (Value.TEXT.equals(parameter)) { |
michael@0 | 509 | parameter = Value.TEXT; |
michael@0 | 510 | } |
michael@0 | 511 | else if (Value.TIME.equals(parameter)) { |
michael@0 | 512 | parameter = Value.TIME; |
michael@0 | 513 | } |
michael@0 | 514 | else if (Value.URI.equals(parameter)) { |
michael@0 | 515 | parameter = Value.URI; |
michael@0 | 516 | } |
michael@0 | 517 | else if (Value.UTC_OFFSET.equals(parameter)) { |
michael@0 | 518 | parameter = Value.UTC_OFFSET; |
michael@0 | 519 | } |
michael@0 | 520 | return parameter; |
michael@0 | 521 | } |
michael@0 | 522 | } |
michael@0 | 523 | |
michael@0 | 524 | } |