michael@3: /** michael@3: * Copyright (c) 2012, Ben Fortuna michael@3: * All rights reserved. michael@3: * michael@3: * Redistribution and use in source and binary forms, with or without michael@3: * modification, are permitted provided that the following conditions michael@3: * are met: michael@3: * michael@3: * o Redistributions of source code must retain the above copyright michael@3: * notice, this list of conditions and the following disclaimer. michael@3: * michael@3: * o Redistributions in binary form must reproduce the above copyright michael@3: * notice, this list of conditions and the following disclaimer in the michael@3: * documentation and/or other materials provided with the distribution. michael@3: * michael@3: * o Neither the name of Ben Fortuna nor the names of any other contributors michael@3: * may be used to endorse or promote products derived from this software michael@3: * without specific prior written permission. michael@3: * michael@3: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@3: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@3: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@3: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@3: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@3: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@3: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@3: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF michael@3: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING michael@3: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@3: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@3: */ michael@3: package net.fortuna.ical4j.model.property; michael@3: michael@3: import net.fortuna.ical4j.model.TextList; michael@3: import net.fortuna.ical4j.model.Parameter; michael@3: import net.fortuna.ical4j.model.ParameterList; michael@3: import net.fortuna.ical4j.model.Property; michael@3: import net.fortuna.ical4j.model.PropertyFactoryImpl; michael@3: import net.fortuna.ical4j.model.ValidationException; michael@3: import net.fortuna.ical4j.util.ParameterValidator; michael@3: michael@3: /** michael@3: * $Id$ michael@3: * michael@3: * Created: [Apr 6, 2004] michael@3: * michael@3: * Defines a CATEGORIES iCalendar component property. michael@3: *
michael@3:  *     4.8.1.2 Categories
michael@3:  *     
michael@3:  *        Property Name: CATEGORIES
michael@3:  *     
michael@3:  *        Purpose: This property defines the categories for a calendar
michael@3:  *        component.
michael@3:  *     
michael@3:  *        Value Type: TEXT
michael@3:  *     
michael@3:  *        Property Parameters: Non-standard and language property parameters
michael@3:  *        can be specified on this property.
michael@3:  *     
michael@3:  *        Conformance: The property can be specified within "VEVENT", "VTODO"
michael@3:  *        or "VJOURNAL" calendar components.
michael@3:  *     
michael@3:  *        Description: This property is used to specify categories or subtypes
michael@3:  *        of the calendar component. The categories are useful in searching for
michael@3:  *        a calendar component of a particular type and category. Within the
michael@3:  *        "VEVENT", "VTODO" or "VJOURNAL" calendar components, more than one
michael@3:  *        category can be specified as a list of categories separated by the
michael@3:  *        COMMA character (US-ASCII decimal 44).
michael@3:  *     
michael@3:  *        Format Definition: The property is defined by the following notation:
michael@3:  *     
michael@3:  *          categories = "CATEGORIES" catparam ":" text *("," text)
michael@3:  *                       CRLF
michael@3:  *     
michael@3:  *          catparam   = *(
michael@3:  *     
michael@3:  *                     ; the following is optional,
michael@3:  *                     ; but MUST NOT occur more than once
michael@3:  *     
michael@3:  *                     (";" languageparam ) /
michael@3:  *     
michael@3:  *                     ; the following is optional,
michael@3:  *                     ; and MAY occur more than once
michael@3:  *     
michael@3:  *                     (";" xparam)
michael@3:  *     
michael@3:  *                     )
michael@3:  * 
michael@3: * @author benf michael@3: */ michael@3: public class Categories extends Property { michael@3: michael@3: private static final long serialVersionUID = -7769987073466681634L; michael@3: michael@3: private TextList categories; michael@3: michael@3: /** michael@3: * Default constructor. michael@3: */ michael@3: public Categories() { michael@3: super(CATEGORIES, PropertyFactoryImpl.getInstance()); michael@3: categories = new TextList(); michael@3: } michael@3: michael@3: /** michael@3: * @param aValue a value string for this component michael@3: */ michael@3: public Categories(final String aValue) { michael@3: super(CATEGORIES, PropertyFactoryImpl.getInstance()); michael@3: setValue(aValue); michael@3: } michael@3: michael@3: /** michael@3: * @param aList a list of parameters for this component michael@3: * @param aValue a value string for this component michael@3: */ michael@3: public Categories(final ParameterList aList, final String aValue) { michael@3: super(CATEGORIES, aList, PropertyFactoryImpl.getInstance()); michael@3: setValue(aValue); michael@3: } michael@3: michael@3: /** michael@3: * @param cList a list of categories michael@3: */ michael@3: public Categories(final TextList cList) { michael@3: super(CATEGORIES, PropertyFactoryImpl.getInstance()); michael@3: categories = cList; michael@3: } michael@3: michael@3: /** michael@3: * @param aList a list of parameters for this component michael@3: * @param cList a list of categories michael@3: */ michael@3: public Categories(final ParameterList aList, final TextList cList) { michael@3: super(CATEGORIES, aList, PropertyFactoryImpl.getInstance()); michael@3: categories = cList; michael@3: } michael@3: michael@3: /** michael@3: * {@inheritDoc} michael@3: */ michael@3: public final void setValue(final String aValue) { michael@3: categories = new TextList(aValue); michael@3: } michael@3: michael@3: /** michael@3: * {@inheritDoc} michael@3: */ michael@3: public final void validate() throws ValidationException { michael@3: michael@3: /* michael@3: * ; the following is optional, ; but MUST NOT occur more than once (";" languageparam ) / michael@3: */ michael@3: ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE, michael@3: getParameters()); michael@3: michael@3: /* michael@3: * ; the following is optional, ; and MAY occur more than once (";" xparam) michael@3: */ michael@3: } michael@3: michael@3: /** michael@3: * @return Returns the categories. michael@3: */ michael@3: public final TextList getCategories() { michael@3: return categories; michael@3: } michael@3: michael@3: /** michael@3: * {@inheritDoc} michael@3: */ michael@3: public final String getValue() { michael@3: return getCategories().toString(); michael@3: } michael@3: }