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

Tue, 10 Feb 2015 19:58:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 19:58:00 +0100
changeset 4
45d57ecba757
permissions
-rw-r--r--

Upgrade the upgraded ical4j component to use org.apache.commons.lang3.

     1 /**
     2  * Copyright (c) 2012, Ben Fortuna
     3  * All rights reserved.
     4  *
     5  * Redistribution and use in source and binary forms, with or without
     6  * modification, are permitted provided that the following conditions
     7  * are met:
     8  *
     9  *  o Redistributions of source code must retain the above copyright
    10  * notice, this list of conditions and the following disclaimer.
    11  *
    12  *  o Redistributions in binary form must reproduce the above copyright
    13  * notice, this list of conditions and the following disclaimer in the
    14  * documentation and/or other materials provided with the distribution.
    15  *
    16  *  o Neither the name of Ben Fortuna nor the names of any other contributors
    17  * may be used to endorse or promote products derived from this software
    18  * without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  */
    32 package net.fortuna.ical4j.model.property;
    34 import java.util.StringTokenizer;
    36 import net.fortuna.ical4j.model.Parameter;
    37 import net.fortuna.ical4j.model.ParameterList;
    38 import net.fortuna.ical4j.model.Property;
    39 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    40 import net.fortuna.ical4j.model.ValidationException;
    41 import net.fortuna.ical4j.util.ParameterValidator;
    43 /**
    44  * $Id$
    45  * 
    46  * Created: [Apr 6, 2004]
    47  *
    48  * Defines a REQUEST-STATUS iCalendar component property.
    49  * @author benf
    50  */
    51 public class RequestStatus extends Property {
    53     private static final long serialVersionUID = -3273944031884755345L;
    55     /**
    56      * Preliminary success status.
    57      */
    58     public static final String PRELIM_SUCCESS = "1";
    60     /**
    61      * Success status.
    62      */
    63     public static final String SUCCESS = "2";
    65     /**
    66      * Client error status.
    67      */
    68     public static final String CLIENT_ERROR = "3";
    70     /**
    71      * Scheduling error status.
    72      */
    73     public static final String SCHEDULING_ERROR = "4";
    75     private String statusCode;
    77     private String description;
    79     private String exData;
    81     /**
    82      * Default constructor.
    83      */
    84     public RequestStatus() {
    85         super(REQUEST_STATUS, PropertyFactoryImpl.getInstance());
    86     }
    88     /**
    89      * @param aList a list of parameters for this component
    90      * @param aValue a value string for this component
    91      */
    92     public RequestStatus(final ParameterList aList, final String aValue) {
    93         super(REQUEST_STATUS, aList, PropertyFactoryImpl.getInstance());
    94         setValue(aValue);
    95     }
    97     /**
    98      * @param aStatusCode a string representation of a status code
    99      * @param aDescription a description
   100      * @param data a string representation of extension data
   101      */
   102     public RequestStatus(final String aStatusCode, final String aDescription,
   103             final String data) {
   104         super(REQUEST_STATUS, PropertyFactoryImpl.getInstance());
   105         statusCode = aStatusCode;
   106         description = aDescription;
   107         exData = data;
   108     }
   110     /**
   111      * @param aList a list of parameters for this component
   112      * @param aStatusCode a string representation of a status code
   113      * @param aDescription a description
   114      * @param data a string representation of extension data
   115      */
   116     public RequestStatus(final ParameterList aList, final String aStatusCode,
   117             final String aDescription, final String data) {
   118         super(REQUEST_STATUS, aList, PropertyFactoryImpl.getInstance());
   119         statusCode = aStatusCode;
   120         description = aDescription;
   121         exData = data;
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public final void validate() throws ValidationException {
   129         /*
   130          * ; the following is optional, ; but MUST NOT occur more than once (";" languageparm) /
   131          */
   132         ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
   133                 getParameters());
   135         /*
   136          * ; the following is optional, ; and MAY occur more than once (";" xparam)
   137          */
   138     }
   140     /**
   141      * @return Returns the description.
   142      */
   143     public final String getDescription() {
   144         return description;
   145     }
   147     /**
   148      * @return Returns the exData.
   149      */
   150     public final String getExData() {
   151         return exData;
   152     }
   154     /**
   155      * @return Returns the statusCode.
   156      */
   157     public final String getStatusCode() {
   158         return statusCode;
   159     }
   161     /**
   162      * {@inheritDoc}
   163      */
   164     public final void setValue(final String aValue) {
   165         final StringTokenizer t = new StringTokenizer(aValue, ";");
   167         if (t.hasMoreTokens()) {
   168             statusCode = t.nextToken();
   169         }
   171         if (t.hasMoreTokens()) {
   172             description = t.nextToken();
   173         }
   175         if (t.hasMoreTokens()) {
   176             exData = t.nextToken();
   177         }
   178     }
   180     /**
   181      * {@inheritDoc}
   182      */
   183     public final String getValue() {
   184         final StringBuffer b = new StringBuffer();
   186         if ((getStatusCode() != null)) {
   187             b.append(getStatusCode());
   188         }
   190         if ((getDescription() != null)) {
   191             b.append(';');
   192             b.append(getDescription());
   193         }
   195         if ((getExData() != null)) {
   196             b.append(';');
   197             b.append(getExData());
   198         }
   200         return b.toString();
   201     }
   203     /**
   204      * @param description The description to set.
   205      */
   206     public final void setDescription(final String description) {
   207         this.description = description;
   208     }
   210     /**
   211      * @param exData The exData to set.
   212      */
   213     public final void setExData(final String exData) {
   214         this.exData = exData;
   215     }
   217     /**
   218      * @param statusCode The statusCode to set.
   219      */
   220     public final void setStatusCode(final String statusCode) {
   221         this.statusCode = statusCode;
   222     }
   223 }

mercurial