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

changeset 0
fb9019fb1bf7
child 3
73bdfa70b04e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/net/fortuna/ical4j/model/property/Categories.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,176 @@
     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 net.fortuna.ical4j.model.TextList;
    1.38 +import net.fortuna.ical4j.model.Parameter;
    1.39 +import net.fortuna.ical4j.model.ParameterList;
    1.40 +import net.fortuna.ical4j.model.Property;
    1.41 +import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.42 +import net.fortuna.ical4j.model.ValidationException;
    1.43 +import net.fortuna.ical4j.util.ParameterValidator;
    1.44 +
    1.45 +/**
    1.46 + * $Id$
    1.47 + * 
    1.48 + * Created: [Apr 6, 2004]
    1.49 + *
    1.50 + * Defines a CATEGORIES iCalendar component property.
    1.51 + * <pre>
    1.52 + *     4.8.1.2 Categories
    1.53 + *     
    1.54 + *        Property Name: CATEGORIES
    1.55 + *     
    1.56 + *        Purpose: This property defines the categories for a calendar
    1.57 + *        component.
    1.58 + *     
    1.59 + *        Value Type: TEXT
    1.60 + *     
    1.61 + *        Property Parameters: Non-standard and language property parameters
    1.62 + *        can be specified on this property.
    1.63 + *     
    1.64 + *        Conformance: The property can be specified within "VEVENT", "VTODO"
    1.65 + *        or "VJOURNAL" calendar components.
    1.66 + *     
    1.67 + *        Description: This property is used to specify categories or subtypes
    1.68 + *        of the calendar component. The categories are useful in searching for
    1.69 + *        a calendar component of a particular type and category. Within the
    1.70 + *        "VEVENT", "VTODO" or "VJOURNAL" calendar components, more than one
    1.71 + *        category can be specified as a list of categories separated by the
    1.72 + *        COMMA character (US-ASCII decimal 44).
    1.73 + *     
    1.74 + *        Format Definition: The property is defined by the following notation:
    1.75 + *     
    1.76 + *          categories = "CATEGORIES" catparam ":" text *("," text)
    1.77 + *                       CRLF
    1.78 + *     
    1.79 + *          catparam   = *(
    1.80 + *     
    1.81 + *                     ; the following is optional,
    1.82 + *                     ; but MUST NOT occur more than once
    1.83 + *     
    1.84 + *                     (";" languageparam ) /
    1.85 + *     
    1.86 + *                     ; the following is optional,
    1.87 + *                     ; and MAY occur more than once
    1.88 + *     
    1.89 + *                     (";" xparam)
    1.90 + *     
    1.91 + *                     )
    1.92 + * </pre>
    1.93 + * @author benf
    1.94 + */
    1.95 +public class Categories extends Property {
    1.96 +
    1.97 +    private static final long serialVersionUID = -7769987073466681634L;
    1.98 +
    1.99 +    private TextList categories;
   1.100 +
   1.101 +    /**
   1.102 +     * Default constructor.
   1.103 +     */
   1.104 +    public Categories() {
   1.105 +        super(CATEGORIES, PropertyFactoryImpl.getInstance());
   1.106 +        categories = new TextList();
   1.107 +    }
   1.108 +
   1.109 +    /**
   1.110 +     * @param aValue a value string for this component
   1.111 +     */
   1.112 +    public Categories(final String aValue) {
   1.113 +        super(CATEGORIES, PropertyFactoryImpl.getInstance());
   1.114 +        setValue(aValue);
   1.115 +    }
   1.116 +
   1.117 +    /**
   1.118 +     * @param aList a list of parameters for this component
   1.119 +     * @param aValue a value string for this component
   1.120 +     */
   1.121 +    public Categories(final ParameterList aList, final String aValue) {
   1.122 +        super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
   1.123 +        setValue(aValue);
   1.124 +    }
   1.125 +
   1.126 +    /**
   1.127 +     * @param cList a list of categories
   1.128 +     */
   1.129 +    public Categories(final TextList cList) {
   1.130 +        super(CATEGORIES, PropertyFactoryImpl.getInstance());
   1.131 +        categories = cList;
   1.132 +    }
   1.133 +
   1.134 +    /**
   1.135 +     * @param aList a list of parameters for this component
   1.136 +     * @param cList a list of categories
   1.137 +     */
   1.138 +    public Categories(final ParameterList aList, final TextList cList) {
   1.139 +        super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
   1.140 +        categories = cList;
   1.141 +    }
   1.142 +
   1.143 +    /**
   1.144 +     * {@inheritDoc}
   1.145 +     */
   1.146 +    public final void setValue(final String aValue) {
   1.147 +        categories = new TextList(aValue);
   1.148 +    }
   1.149 +
   1.150 +    /**
   1.151 +     * {@inheritDoc}
   1.152 +     */
   1.153 +    public final void validate() throws ValidationException {
   1.154 +
   1.155 +        /*
   1.156 +         * ; the following is optional, ; but MUST NOT occur more than once (";" languageparam ) /
   1.157 +         */
   1.158 +        ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
   1.159 +                getParameters());
   1.160 +
   1.161 +        /*
   1.162 +         * ; the following is optional, ; and MAY occur more than once (";" xparam)
   1.163 +         */
   1.164 +    }
   1.165 +
   1.166 +    /**
   1.167 +     * @return Returns the categories.
   1.168 +     */
   1.169 +    public final TextList getCategories() {
   1.170 +        return categories;
   1.171 +    }
   1.172 +
   1.173 +    /**
   1.174 +     * {@inheritDoc}
   1.175 +     */
   1.176 +    public final String getValue() {
   1.177 +        return getCategories().toString();
   1.178 +    }
   1.179 +}

mercurial