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

branch
ICAL4J_EMBED_1
changeset 15
cc93757aeca3
parent 14
5ae3e5665a0b
child 18
6dcaece8ec41
     1.1 --- a/src/net/fortuna/ical4j/model/property/DateListProperty.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.property;
    1.36 -
    1.37 -import java.io.IOException;
    1.38 -import java.net.URISyntaxException;
    1.39 -import java.text.ParseException;
    1.40 -
    1.41 -import net.fortuna.ical4j.model.DateList;
    1.42 -import net.fortuna.ical4j.model.Parameter;
    1.43 -import net.fortuna.ical4j.model.ParameterList;
    1.44 -import net.fortuna.ical4j.model.Property;
    1.45 -import net.fortuna.ical4j.model.PropertyFactory;
    1.46 -import net.fortuna.ical4j.model.TimeZone;
    1.47 -import net.fortuna.ical4j.model.parameter.TzId;
    1.48 -import net.fortuna.ical4j.model.parameter.Value;
    1.49 -import net.fortuna.ical4j.util.Strings;
    1.50 -
    1.51 -/**
    1.52 - * $Id$
    1.53 - *
    1.54 - * Created on 11/08/2005
    1.55 - *
    1.56 - * Base class for properties with a list of dates as a value.
    1.57 - * @author Ben Fortuna
    1.58 - */
    1.59 -public abstract class DateListProperty extends Property {
    1.60 -
    1.61 -    /**
    1.62 -     * 
    1.63 -     */
    1.64 -    private static final long serialVersionUID = 5233773091972759919L;
    1.65 -
    1.66 -    private DateList dates;
    1.67 -
    1.68 -    private TimeZone timeZone;
    1.69 -
    1.70 -    /**
    1.71 -     * @param name the property name
    1.72 -     */
    1.73 -    public DateListProperty(final String name, PropertyFactory factory) {
    1.74 -        this(name, new DateList(Value.DATE_TIME), factory);
    1.75 -    }
    1.76 -
    1.77 -    /**
    1.78 -     * @param name the property name
    1.79 -     * @param parameters property parameters
    1.80 -     */
    1.81 -    public DateListProperty(final String name, final ParameterList parameters, PropertyFactory factory) {
    1.82 -        super(name, parameters, factory);
    1.83 -    }
    1.84 -
    1.85 -    /**
    1.86 -     * @param name the property name
    1.87 -     * @param dates a list of initial dates for the property
    1.88 -     */
    1.89 -    public DateListProperty(final String name, final DateList dates, PropertyFactory factory) {
    1.90 -        this(name, new ParameterList(), dates, factory);
    1.91 -    }
    1.92 -
    1.93 -    /**
    1.94 -     * @param name the property name
    1.95 -     * @param parameters property parameters
    1.96 -     * @param dates a list of initial dates for the property
    1.97 -     */
    1.98 -    public DateListProperty(final String name, final ParameterList parameters, final DateList dates,
    1.99 -            PropertyFactory factory) {
   1.100 -        super(name, parameters, factory);
   1.101 -        this.dates = dates;
   1.102 -        if (dates != null && !Value.DATE_TIME.equals(dates.getType())) {
   1.103 -            getParameters().replace(dates.getType());
   1.104 -        }
   1.105 -    }
   1.106 -
   1.107 -    /**
   1.108 -     * @return Returns the dates.
   1.109 -     */
   1.110 -    public final DateList getDates() {
   1.111 -        return dates;
   1.112 -    }
   1.113 -
   1.114 -    /**
   1.115 -     * {@inheritDoc}
   1.116 -     */
   1.117 -    public void setValue(final String aValue) throws ParseException {
   1.118 -        dates = new DateList(aValue, (Value) getParameter(Parameter.VALUE),
   1.119 -                timeZone);
   1.120 -    }
   1.121 -
   1.122 -    /**
   1.123 -     * {@inheritDoc}
   1.124 -     */
   1.125 -    public String getValue() {
   1.126 -        return Strings.valueOf(dates);
   1.127 -    }
   1.128 -
   1.129 -    /**
   1.130 -     * Sets the timezone associated with this property.
   1.131 -     * @param timezone a timezone to associate with this property
   1.132 -     */
   1.133 -    public void setTimeZone(final TimeZone timezone) {
   1.134 -        if (dates == null) {
   1.135 -            throw new UnsupportedOperationException(
   1.136 -                    "TimeZone is not applicable to current value");
   1.137 -        }
   1.138 -        this.timeZone = timezone;
   1.139 -        if (timezone != null) {
   1.140 -            if (!Value.DATE_TIME.equals(getDates().getType())) {
   1.141 -                throw new UnsupportedOperationException(
   1.142 -                        "TimeZone is not applicable to current value");
   1.143 -            }
   1.144 -            dates.setTimeZone(timezone);
   1.145 -            getParameters().remove(getParameter(Parameter.TZID));
   1.146 -            final TzId tzId = new TzId(timezone.getID());
   1.147 -            getParameters().replace(tzId);
   1.148 -        }
   1.149 -        else {
   1.150 -            // use setUtc() to reset timezone..
   1.151 -            setUtc(false);
   1.152 -        }
   1.153 -    }
   1.154 -
   1.155 -    /**
   1.156 -     * @return the timezone
   1.157 -     */
   1.158 -    public final TimeZone getTimeZone() {
   1.159 -        return timeZone;
   1.160 -    }
   1.161 -
   1.162 -    /**
   1.163 -     * Resets the timezone associated with the property. If utc is true, any TZID parameters are removed and the Java
   1.164 -     * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the
   1.165 -     * default timezone (i.e. represents a "floating" local time)
   1.166 -     * @param utc the UTC value
   1.167 -     */
   1.168 -    public final void setUtc(final boolean utc) {
   1.169 -        if (dates == null || !Value.DATE_TIME.equals(dates.getType())) {
   1.170 -            throw new UnsupportedOperationException(
   1.171 -                    "TimeZone is not applicable to current value");
   1.172 -        }
   1.173 -        dates.setUtc(utc);
   1.174 -        getParameters().remove(getParameter(Parameter.TZID));
   1.175 -    }
   1.176 -
   1.177 -    /**
   1.178 -     * {@inheritDoc}
   1.179 -     */
   1.180 -    public final Property copy() throws IOException, URISyntaxException, ParseException {
   1.181 -        final Property copy = super.copy();
   1.182 -        
   1.183 -       ((DateListProperty) copy).timeZone = timeZone;
   1.184 -       ((DateListProperty) copy).setValue(getValue());
   1.185 -
   1.186 -        return copy;
   1.187 -    }
   1.188 -}

mercurial