src/net/fortuna/ical4j/model/property/RequestStatus.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/RequestStatus.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,223 @@
     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.util.StringTokenizer;
    1.38 +
    1.39 +import net.fortuna.ical4j.model.Parameter;
    1.40 +import net.fortuna.ical4j.model.ParameterList;
    1.41 +import net.fortuna.ical4j.model.Property;
    1.42 +import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.43 +import net.fortuna.ical4j.model.ValidationException;
    1.44 +import net.fortuna.ical4j.util.ParameterValidator;
    1.45 +
    1.46 +/**
    1.47 + * $Id$
    1.48 + * 
    1.49 + * Created: [Apr 6, 2004]
    1.50 + *
    1.51 + * Defines a REQUEST-STATUS iCalendar component property.
    1.52 + * @author benf
    1.53 + */
    1.54 +public class RequestStatus extends Property {
    1.55 +
    1.56 +    private static final long serialVersionUID = -3273944031884755345L;
    1.57 +
    1.58 +    /**
    1.59 +     * Preliminary success status.
    1.60 +     */
    1.61 +    public static final String PRELIM_SUCCESS = "1";
    1.62 +
    1.63 +    /**
    1.64 +     * Success status.
    1.65 +     */
    1.66 +    public static final String SUCCESS = "2";
    1.67 +
    1.68 +    /**
    1.69 +     * Client error status.
    1.70 +     */
    1.71 +    public static final String CLIENT_ERROR = "3";
    1.72 +
    1.73 +    /**
    1.74 +     * Scheduling error status.
    1.75 +     */
    1.76 +    public static final String SCHEDULING_ERROR = "4";
    1.77 +
    1.78 +    private String statusCode;
    1.79 +
    1.80 +    private String description;
    1.81 +
    1.82 +    private String exData;
    1.83 +
    1.84 +    /**
    1.85 +     * Default constructor.
    1.86 +     */
    1.87 +    public RequestStatus() {
    1.88 +        super(REQUEST_STATUS, PropertyFactoryImpl.getInstance());
    1.89 +    }
    1.90 +
    1.91 +    /**
    1.92 +     * @param aList a list of parameters for this component
    1.93 +     * @param aValue a value string for this component
    1.94 +     */
    1.95 +    public RequestStatus(final ParameterList aList, final String aValue) {
    1.96 +        super(REQUEST_STATUS, aList, PropertyFactoryImpl.getInstance());
    1.97 +        setValue(aValue);
    1.98 +    }
    1.99 +
   1.100 +    /**
   1.101 +     * @param aStatusCode a string representation of a status code
   1.102 +     * @param aDescription a description
   1.103 +     * @param data a string representation of extension data
   1.104 +     */
   1.105 +    public RequestStatus(final String aStatusCode, final String aDescription,
   1.106 +            final String data) {
   1.107 +        super(REQUEST_STATUS, PropertyFactoryImpl.getInstance());
   1.108 +        statusCode = aStatusCode;
   1.109 +        description = aDescription;
   1.110 +        exData = data;
   1.111 +    }
   1.112 +
   1.113 +    /**
   1.114 +     * @param aList a list of parameters for this component
   1.115 +     * @param aStatusCode a string representation of a status code
   1.116 +     * @param aDescription a description
   1.117 +     * @param data a string representation of extension data
   1.118 +     */
   1.119 +    public RequestStatus(final ParameterList aList, final String aStatusCode,
   1.120 +            final String aDescription, final String data) {
   1.121 +        super(REQUEST_STATUS, aList, PropertyFactoryImpl.getInstance());
   1.122 +        statusCode = aStatusCode;
   1.123 +        description = aDescription;
   1.124 +        exData = data;
   1.125 +    }
   1.126 +
   1.127 +    /**
   1.128 +     * {@inheritDoc}
   1.129 +     */
   1.130 +    public final void validate() throws ValidationException {
   1.131 +
   1.132 +        /*
   1.133 +         * ; the following is optional, ; but MUST NOT occur more than once (";" languageparm) /
   1.134 +         */
   1.135 +        ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
   1.136 +                getParameters());
   1.137 +
   1.138 +        /*
   1.139 +         * ; the following is optional, ; and MAY occur more than once (";" xparam)
   1.140 +         */
   1.141 +    }
   1.142 +
   1.143 +    /**
   1.144 +     * @return Returns the description.
   1.145 +     */
   1.146 +    public final String getDescription() {
   1.147 +        return description;
   1.148 +    }
   1.149 +
   1.150 +    /**
   1.151 +     * @return Returns the exData.
   1.152 +     */
   1.153 +    public final String getExData() {
   1.154 +        return exData;
   1.155 +    }
   1.156 +
   1.157 +    /**
   1.158 +     * @return Returns the statusCode.
   1.159 +     */
   1.160 +    public final String getStatusCode() {
   1.161 +        return statusCode;
   1.162 +    }
   1.163 +
   1.164 +    /**
   1.165 +     * {@inheritDoc}
   1.166 +     */
   1.167 +    public final void setValue(final String aValue) {
   1.168 +        final StringTokenizer t = new StringTokenizer(aValue, ";");
   1.169 +
   1.170 +        if (t.hasMoreTokens()) {
   1.171 +            statusCode = t.nextToken();
   1.172 +        }
   1.173 +
   1.174 +        if (t.hasMoreTokens()) {
   1.175 +            description = t.nextToken();
   1.176 +        }
   1.177 +
   1.178 +        if (t.hasMoreTokens()) {
   1.179 +            exData = t.nextToken();
   1.180 +        }
   1.181 +    }
   1.182 +
   1.183 +    /**
   1.184 +     * {@inheritDoc}
   1.185 +     */
   1.186 +    public final String getValue() {
   1.187 +        final StringBuffer b = new StringBuffer();
   1.188 +
   1.189 +        if ((getStatusCode() != null)) {
   1.190 +            b.append(getStatusCode());
   1.191 +        }
   1.192 +
   1.193 +        if ((getDescription() != null)) {
   1.194 +            b.append(';');
   1.195 +            b.append(getDescription());
   1.196 +        }
   1.197 +
   1.198 +        if ((getExData() != null)) {
   1.199 +            b.append(';');
   1.200 +            b.append(getExData());
   1.201 +        }
   1.202 +
   1.203 +        return b.toString();
   1.204 +    }
   1.205 +
   1.206 +    /**
   1.207 +     * @param description The description to set.
   1.208 +     */
   1.209 +    public final void setDescription(final String description) {
   1.210 +        this.description = description;
   1.211 +    }
   1.212 +
   1.213 +    /**
   1.214 +     * @param exData The exData to set.
   1.215 +     */
   1.216 +    public final void setExData(final String exData) {
   1.217 +        this.exData = exData;
   1.218 +    }
   1.219 +
   1.220 +    /**
   1.221 +     * @param statusCode The statusCode to set.
   1.222 +     */
   1.223 +    public final void setStatusCode(final String statusCode) {
   1.224 +        this.statusCode = statusCode;
   1.225 +    }
   1.226 +}

mercurial