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

Tue, 10 Feb 2015 18:12:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 18:12:00 +0100
changeset 0
fb9019fb1bf7
child 3
73bdfa70b04e
permissions
-rw-r--r--

Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.

     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 net.fortuna.ical4j.model.TextList;
    35 import net.fortuna.ical4j.model.Parameter;
    36 import net.fortuna.ical4j.model.ParameterList;
    37 import net.fortuna.ical4j.model.Property;
    38 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    39 import net.fortuna.ical4j.model.ValidationException;
    40 import net.fortuna.ical4j.util.ParameterValidator;
    42 /**
    43  * $Id$
    44  * 
    45  * Created: [Apr 6, 2004]
    46  *
    47  * Defines a CATEGORIES iCalendar component property.
    48  * <pre>
    49  *     4.8.1.2 Categories
    50  *     
    51  *        Property Name: CATEGORIES
    52  *     
    53  *        Purpose: This property defines the categories for a calendar
    54  *        component.
    55  *     
    56  *        Value Type: TEXT
    57  *     
    58  *        Property Parameters: Non-standard and language property parameters
    59  *        can be specified on this property.
    60  *     
    61  *        Conformance: The property can be specified within "VEVENT", "VTODO"
    62  *        or "VJOURNAL" calendar components.
    63  *     
    64  *        Description: This property is used to specify categories or subtypes
    65  *        of the calendar component. The categories are useful in searching for
    66  *        a calendar component of a particular type and category. Within the
    67  *        "VEVENT", "VTODO" or "VJOURNAL" calendar components, more than one
    68  *        category can be specified as a list of categories separated by the
    69  *        COMMA character (US-ASCII decimal 44).
    70  *     
    71  *        Format Definition: The property is defined by the following notation:
    72  *     
    73  *          categories = "CATEGORIES" catparam ":" text *("," text)
    74  *                       CRLF
    75  *     
    76  *          catparam   = *(
    77  *     
    78  *                     ; the following is optional,
    79  *                     ; but MUST NOT occur more than once
    80  *     
    81  *                     (";" languageparam ) /
    82  *     
    83  *                     ; the following is optional,
    84  *                     ; and MAY occur more than once
    85  *     
    86  *                     (";" xparam)
    87  *     
    88  *                     )
    89  * </pre>
    90  * @author benf
    91  */
    92 public class Categories extends Property {
    94     private static final long serialVersionUID = -7769987073466681634L;
    96     private TextList categories;
    98     /**
    99      * Default constructor.
   100      */
   101     public Categories() {
   102         super(CATEGORIES, PropertyFactoryImpl.getInstance());
   103         categories = new TextList();
   104     }
   106     /**
   107      * @param aValue a value string for this component
   108      */
   109     public Categories(final String aValue) {
   110         super(CATEGORIES, PropertyFactoryImpl.getInstance());
   111         setValue(aValue);
   112     }
   114     /**
   115      * @param aList a list of parameters for this component
   116      * @param aValue a value string for this component
   117      */
   118     public Categories(final ParameterList aList, final String aValue) {
   119         super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
   120         setValue(aValue);
   121     }
   123     /**
   124      * @param cList a list of categories
   125      */
   126     public Categories(final TextList cList) {
   127         super(CATEGORIES, PropertyFactoryImpl.getInstance());
   128         categories = cList;
   129     }
   131     /**
   132      * @param aList a list of parameters for this component
   133      * @param cList a list of categories
   134      */
   135     public Categories(final ParameterList aList, final TextList cList) {
   136         super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
   137         categories = cList;
   138     }
   140     /**
   141      * {@inheritDoc}
   142      */
   143     public final void setValue(final String aValue) {
   144         categories = new TextList(aValue);
   145     }
   147     /**
   148      * {@inheritDoc}
   149      */
   150     public final void validate() throws ValidationException {
   152         /*
   153          * ; the following is optional, ; but MUST NOT occur more than once (";" languageparam ) /
   154          */
   155         ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
   156                 getParameters());
   158         /*
   159          * ; the following is optional, ; and MAY occur more than once (";" xparam)
   160          */
   161     }
   163     /**
   164      * @return Returns the categories.
   165      */
   166     public final TextList getCategories() {
   167         return categories;
   168     }
   170     /**
   171      * {@inheritDoc}
   172      */
   173     public final String getValue() {
   174         return getCategories().toString();
   175     }
   176 }

mercurial