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

changeset 0
fb9019fb1bf7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/net/fortuna/ical4j/model/property/Sequence.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,204 @@
     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.property;
    1.36 +
    1.37 +import net.fortuna.ical4j.model.ParameterList;
    1.38 +import net.fortuna.ical4j.model.Property;
    1.39 +import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.40 +import net.fortuna.ical4j.model.ValidationException;
    1.41 +
    1.42 +/**
    1.43 + * $Id$
    1.44 + * 
    1.45 + * Created: [Apr 6, 2004]
    1.46 + *
    1.47 + * Defines a SEQUENCE iCalendar component property.
    1.48 + * 
    1.49 + * <pre>
    1.50 + *     4.8.7.4 Sequence Number
    1.51 + *     
    1.52 + *        Property Name: SEQUENCE
    1.53 + *     
    1.54 + *        Purpose: This property defines the revision sequence number of the
    1.55 + *        calendar component within a sequence of revisions.
    1.56 + *     
    1.57 + *        Value Type: integer
    1.58 + *     
    1.59 + *        Property Parameters: Non-standard property parameters can be
    1.60 + *        specified on this property.
    1.61 + *     
    1.62 + *        Conformance: The property can be specified in &quot;VEVENT&quot;, &quot;VTODO&quot; or
    1.63 + *        &quot;VJOURNAL&quot; calendar component.
    1.64 + *     
    1.65 + *        Description: When a calendar component is created, its sequence
    1.66 + *        number is zero (US-ASCII decimal 48). It is monotonically incremented
    1.67 + *        by the &quot;Organizer's&quot; CUA each time the &quot;Organizer&quot; makes a
    1.68 + *        significant revision to the calendar component. When the &quot;Organizer&quot;
    1.69 + *        makes changes to one of the following properties, the sequence number
    1.70 + *        MUST be incremented:
    1.71 + *     
    1.72 + *          .  &quot;DTSTART&quot;
    1.73 + *     
    1.74 + *          .  &quot;DTEND&quot;
    1.75 + *     
    1.76 + *          .  &quot;DUE&quot;
    1.77 + *     
    1.78 + *          .  &quot;RDATE&quot;
    1.79 + *     
    1.80 + *          .  &quot;RRULE&quot;
    1.81 + *     
    1.82 + *          .  &quot;EXDATE&quot;
    1.83 + *     
    1.84 + *          .  &quot;EXRULE&quot;
    1.85 + *     
    1.86 + *          .  &quot;STATUS&quot;
    1.87 + *     
    1.88 + *        In addition, changes made by the &quot;Organizer&quot; to other properties can
    1.89 + *        also force the sequence number to be incremented. The &quot;Organizer&quot; CUA
    1.90 + *        MUST increment the sequence number when ever it makes changes to
    1.91 + *        properties in the calendar component that the &quot;Organizer&quot; deems will
    1.92 + *        jeopardize the validity of the participation status of the
    1.93 + *        &quot;Attendees&quot;. For example, changing the location of a meeting from one
    1.94 + *        locale to another distant locale could effectively impact the
    1.95 + *        participation status of the &quot;Attendees&quot;.
    1.96 + *     
    1.97 + *        The &quot;Organizer&quot; includes this property in an iCalendar object that it
    1.98 + *        sends to an &quot;Attendee&quot; to specify the current version of the calendar
    1.99 + *        component.
   1.100 + *     
   1.101 + *        The &quot;Attendee&quot; includes this property in an iCalendar object that it
   1.102 + *        sends to the &quot;Organizer&quot; to specify the version of the calendar
   1.103 + *        component that the &quot;Attendee&quot; is referring to.
   1.104 + *     
   1.105 + *        A change to the sequence number is not the mechanism that an
   1.106 + *        &quot;Organizer&quot; uses to request a response from the &quot;Attendees&quot;. The
   1.107 + *        &quot;RSVP&quot; parameter on the &quot;ATTENDEE&quot; property is used by the
   1.108 + *        &quot;Organizer&quot; to indicate that a response from the &quot;Attendees&quot; is
   1.109 + *        requested.
   1.110 + *     
   1.111 + *        Format Definition: This property is defined by the following
   1.112 + *        notation:
   1.113 + *     
   1.114 + *          seq = &quot;SEQUENCE&quot; seqparam &quot;:&quot; integer CRLF
   1.115 + *          ; Default is &quot;0&quot;
   1.116 + *     
   1.117 + *          seqparam   = *(&quot;;&quot; xparam)
   1.118 + *     
   1.119 + *        Example: The following is an example of this property for a calendar
   1.120 + *        component that was just created by the &quot;Organizer&quot;.
   1.121 + *     
   1.122 + *          SEQUENCE:0
   1.123 + *     
   1.124 + *        The following is an example of this property for a calendar component
   1.125 + *        that has been revised two different times by the &quot;Organizer&quot;.
   1.126 + *     
   1.127 + *          SEQUENCE:2
   1.128 + * </pre>
   1.129 + * 
   1.130 + * @author Ben Fortuna
   1.131 + */
   1.132 +public class Sequence extends Property {
   1.133 +
   1.134 +    private static final long serialVersionUID = -1606972893204822853L;
   1.135 +
   1.136 +    private int sequenceNo;
   1.137 +
   1.138 +    /**
   1.139 +     * Default constructor.
   1.140 +     */
   1.141 +    public Sequence() {
   1.142 +        super(SEQUENCE, PropertyFactoryImpl.getInstance());
   1.143 +        sequenceNo = 0;
   1.144 +    }
   1.145 +
   1.146 +    /**
   1.147 +     * @param aValue a value string for this component
   1.148 +     */
   1.149 +    public Sequence(final String aValue) {
   1.150 +        super(SEQUENCE, PropertyFactoryImpl.getInstance());
   1.151 +        setValue(aValue);
   1.152 +    }
   1.153 +
   1.154 +    /**
   1.155 +     * @param aList a list of parameters for this component
   1.156 +     * @param aValue a value string for this component
   1.157 +     */
   1.158 +    public Sequence(final ParameterList aList, final String aValue) {
   1.159 +        super(SEQUENCE, aList, PropertyFactoryImpl.getInstance());
   1.160 +        setValue(aValue);
   1.161 +    }
   1.162 +
   1.163 +    /**
   1.164 +     * @param aSequenceNo a sequence number
   1.165 +     */
   1.166 +    public Sequence(final int aSequenceNo) {
   1.167 +        super(SEQUENCE, PropertyFactoryImpl.getInstance());
   1.168 +        sequenceNo = aSequenceNo;
   1.169 +    }
   1.170 +
   1.171 +    /**
   1.172 +     * @param aList a list of parameters for this component
   1.173 +     * @param aSequenceNo a sequence number
   1.174 +     */
   1.175 +    public Sequence(final ParameterList aList, final int aSequenceNo) {
   1.176 +        super(SEQUENCE, aList, PropertyFactoryImpl.getInstance());
   1.177 +        sequenceNo = aSequenceNo;
   1.178 +    }
   1.179 +
   1.180 +    /**
   1.181 +     * @return Returns the sequenceNo.
   1.182 +     */
   1.183 +    public final int getSequenceNo() {
   1.184 +        return sequenceNo;
   1.185 +    }
   1.186 +
   1.187 +    /**
   1.188 +     * {@inheritDoc}
   1.189 +     */
   1.190 +    public final void setValue(final String aValue) {
   1.191 +        sequenceNo = Integer.parseInt(aValue);
   1.192 +    }
   1.193 +
   1.194 +    /**
   1.195 +     * {@inheritDoc}
   1.196 +     */
   1.197 +    public final String getValue() {
   1.198 +        return String.valueOf(getSequenceNo());
   1.199 +    }
   1.200 +
   1.201 +    /**
   1.202 +     * {@inheritDoc}
   1.203 +     */
   1.204 +    public final void validate() throws ValidationException {
   1.205 +        // TODO: Auto-generated method stub
   1.206 +    }
   1.207 +}

mercurial