src/net/fortuna/ical4j/model/component/Available.java

branch
ICAL4J_EMBED_1
changeset 15
cc93757aeca3
parent 14
5ae3e5665a0b
child 18
6dcaece8ec41
     1.1 --- a/src/net/fortuna/ical4j/model/component/Available.java	Thu Feb 12 18:02:00 2015 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,185 +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.component;
    1.36 -
    1.37 -import net.fortuna.ical4j.model.Component;
    1.38 -import net.fortuna.ical4j.model.Parameter;
    1.39 -import net.fortuna.ical4j.model.Property;
    1.40 -import net.fortuna.ical4j.model.PropertyList;
    1.41 -import net.fortuna.ical4j.model.ValidationException;
    1.42 -import net.fortuna.ical4j.model.parameter.Value;
    1.43 -import net.fortuna.ical4j.model.property.DtEnd;
    1.44 -import net.fortuna.ical4j.model.property.DtStart;
    1.45 -import net.fortuna.ical4j.util.PropertyValidator;
    1.46 -
    1.47 -/**
    1.48 - * $Id$ [05-Apr-2004]
    1.49 - *
    1.50 - * Defines an iCalendar Available component.
    1.51 - *
    1.52 - * <pre>
    1.53 - *
    1.54 - *       availablec  = &quot;BEGIN&quot; &quot;:&quot; &quot;AVAILABLE&quot; CRLF
    1.55 - *
    1.56 - *                    availableprop
    1.57 - *
    1.58 - *                    &quot;END&quot; &quot;:&quot; &quot;AVAILABLE&quot; CRLF
    1.59 - *
    1.60 -          availableprop  = *(
    1.61 -
    1.62 -                         ; the following are REQUIRED,
    1.63 -                         ; but MUST NOT occur more than once
    1.64 -
    1.65 -                         dtstamp / dtstart / uid /
    1.66 -
    1.67 -                         ; either a 'dtend' or a 'duration' is required
    1.68 -                         ; in a 'availableprop', but 'dtend' and
    1.69 -                         ; 'duration' MUST NOT occur in the same
    1.70 -                         ; 'availableprop', and each MUST NOT occur more
    1.71 -                         ; than once
    1.72 -
    1.73 -                         dtend / duration /
    1.74 -
    1.75 -                         ; the following are OPTIONAL,
    1.76 -                         ; but MUST NOT occur more than once
    1.77 -
    1.78 -                         created / last-mod / recurid / rrule /
    1.79 -                         summary /
    1.80 -
    1.81 -                         ; the following are OPTIONAL,
    1.82 -                         ; and MAY occur more than once
    1.83 -
    1.84 -                         categories / comment / contact / exdate /
    1.85 -                         rdate / x-prop
    1.86 -
    1.87 -                         )
    1.88 - * </pre>
    1.89 - *
    1.90 - * @author Ben Fortuna
    1.91 - * @author Mike Douglass
    1.92 - */
    1.93 -public class Available extends Component {
    1.94 -
    1.95 -    private static final long serialVersionUID = -2494710612002978763L;
    1.96 -
    1.97 -    /**
    1.98 -     * Default constructor.
    1.99 -     */
   1.100 -    public Available() {
   1.101 -        super(AVAILABLE);
   1.102 -    }
   1.103 -
   1.104 -    /**
   1.105 -     * Constructor.
   1.106 -     * @param properties a list of properties
   1.107 -     */
   1.108 -    public Available(final PropertyList properties) {
   1.109 -        super(AVAILABLE, properties);
   1.110 -    }
   1.111 -
   1.112 -    /**
   1.113 -     * {@inheritDoc}
   1.114 -     */
   1.115 -    public final void validate(final boolean recurse)
   1.116 -            throws ValidationException {
   1.117 -
   1.118 -        /*
   1.119 -         * ; dtstamp / dtstart / uid are required, but MUST NOT occur more than once /
   1.120 -         */
   1.121 -        PropertyValidator.getInstance().assertOne(Property.DTSTART,
   1.122 -                getProperties());
   1.123 -        PropertyValidator.getInstance().assertOne(Property.DTSTAMP,
   1.124 -                getProperties());
   1.125 -        PropertyValidator.getInstance().assertOne(Property.UID,
   1.126 -                getProperties());
   1.127 -
   1.128 -        /*       If specified, the "DTSTART" and "DTEND" properties in
   1.129 -         *      "VAVAILABILITY" components and "AVAILABLE" sub-components MUST be
   1.130 -         *      "DATE-TIME" values specified as either date with UTC time or date
   1.131 -         *      with local time and a time zone reference.
   1.132 -         */
   1.133 -        final DtStart start = (DtStart) getProperty(Property.DTSTART);
   1.134 -        if (Value.DATE.equals(start.getParameter(Parameter.VALUE))) {
   1.135 -            throw new ValidationException("Property [" + Property.DTSTART
   1.136 -                    + "] must be a " + Value.DATE_TIME);
   1.137 -        }
   1.138 -
   1.139 -        /*
   1.140 -         *                ; the following are optional,
   1.141 -         *                ; but MUST NOT occur more than once
   1.142 -         *
   1.143 -         *               created / last-mod / recurid / rrule /
   1.144 -         *               summary /
   1.145 -         */
   1.146 -        PropertyValidator.getInstance().assertOneOrLess(Property.CREATED,
   1.147 -                getProperties());
   1.148 -        PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED,
   1.149 -                getProperties());
   1.150 -        PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID,
   1.151 -                getProperties());
   1.152 -        PropertyValidator.getInstance().assertOneOrLess(Property.RRULE,
   1.153 -                getProperties());
   1.154 -        PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY,
   1.155 -                getProperties());
   1.156 -
   1.157 -        /*
   1.158 -         ; either a 'dtend' or a 'duration' is required
   1.159 -         ; in a 'availableprop', but 'dtend' and
   1.160 -         ; 'duration' MUST NOT occur in the same
   1.161 -         ; 'availableprop', and each MUST NOT occur more
   1.162 -         ; than once
   1.163 -         */
   1.164 -        if (getProperty(Property.DTEND) != null) {
   1.165 -            PropertyValidator.getInstance().assertOne(Property.DTEND,
   1.166 -                    getProperties());
   1.167 -            /* Must be DATE_TIME */
   1.168 -            final DtEnd end = (DtEnd) getProperty(Property.DTEND);
   1.169 -            if (Value.DATE.equals(end.getParameter(Parameter.VALUE))) {
   1.170 -                throw new ValidationException("Property [" + Property.DTEND
   1.171 -                        + "] must be a " + Value.DATE_TIME);
   1.172 -            }
   1.173 -        } else {
   1.174 -            PropertyValidator.getInstance().assertOne(Property.DURATION,
   1.175 -                    getProperties());
   1.176 -        }
   1.177 -
   1.178 -        /*
   1.179 -         * ; the following are optional, ; and MAY occur more than once
   1.180 -         *               categories / comment / contact / exdate /
   1.181 -         *               rdate / x-prop
   1.182 -         */
   1.183 -
   1.184 -        if (recurse) {
   1.185 -            validateProperties();
   1.186 -        }
   1.187 -    }
   1.188 -}

mercurial