src/net/fortuna/ical4j/model/component/VVenue.java

changeset 0
fb9019fb1bf7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/net/fortuna/ical4j/model/component/VVenue.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,196 @@
     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.component;
    1.36 +
    1.37 +import net.fortuna.ical4j.model.Property;
    1.38 +import net.fortuna.ical4j.model.PropertyList;
    1.39 +import net.fortuna.ical4j.model.ValidationException;
    1.40 +import net.fortuna.ical4j.model.Validator;
    1.41 +import net.fortuna.ical4j.model.property.Method;
    1.42 +import net.fortuna.ical4j.util.PropertyValidator;
    1.43 +import net.fortuna.ical4j.util.Strings;
    1.44 +
    1.45 +/**
    1.46 + * $Id $ [Apr 5, 2004]
    1.47 + *
    1.48 + * Defines an iCalendar VVENUE component.
    1.49 + *
    1.50 + * <pre>
    1.51 + * 4.  Venue Component
    1.52 + *
    1.53 + *    Component Name: "VVENUE"
    1.54 + *
    1.55 + *    Purpose: Provide a grouping of component properties that describe an
    1.56 + *    event venue.
    1.57 + *
    1.58 + *    Format Definition: A "VVENUE" calendar component is defined by the
    1.59 + *    following notation:
    1.60 + *      venuec  = "BEGIN" ":" "VVENUE" CRLF
    1.61 + *              venueprop
    1.62 + *              "END" ":" "VVENUE" CRLF
    1.63 + *
    1.64 + *      venueprop  = *(
    1.65 + *
    1.66 + *                ; the following are all REQUIRED,
    1.67 + *                ; but MUST NOT occur more than once
    1.68 + *
    1.69 + *                uid
    1.70 + *
    1.71 + *                ; the following are optional,
    1.72 + *                ; but MUST NOT occur more than once
    1.73 + *
    1.74 + *                name / description / street-address / extended-address /
    1.75 + *                locality / region / country / postal-code / tzid / geo /
    1.76 + *                location-type / categories
    1.77 + *
    1.78 + *                ; the following are optional,
    1.79 + *                ; and MAY occur more than once
    1.80 + *
    1.81 + *                tel / url
    1.82 + *              )
    1.83 + *
    1.84 + *    Description: A "VVENUE" calendar component is a grouping of component
    1.85 + *    properties that represent a venue where an event occurs.  This
    1.86 + *    extends the "LOCATION" property of "VEVENT" and "TODO" components,
    1.87 + *    providing the ability to specify detailed information about the event
    1.88 + *    venue.
    1.89 + *
    1.90 + * </pre>
    1.91 + *
    1.92 + * @author Ben Fortuna
    1.93 + * @author Mike Douglass
    1.94 + */
    1.95 +public class VVenue extends CalendarComponent {
    1.96 +
    1.97 +	private static final long serialVersionUID = 4502423035501438515L;
    1.98 +
    1.99 +	/**
   1.100 +     * Default constructor.
   1.101 +     */
   1.102 +    public VVenue() {
   1.103 +        super(VVENUE);
   1.104 +    }
   1.105 +
   1.106 +    /**
   1.107 +     * Constructs a new instance containing the specified properties.
   1.108 +     * @param properties a list of properties
   1.109 +     */
   1.110 +    public VVenue(final PropertyList properties) {
   1.111 +        super(VVENUE, properties);
   1.112 +    }
   1.113 +
   1.114 +    /**
   1.115 +     * {@inheritDoc}
   1.116 +     */
   1.117 +    public final String toString() {
   1.118 +        final StringBuffer b = new StringBuffer();
   1.119 +        b.append(BEGIN);
   1.120 +        b.append(':');
   1.121 +        b.append(getName());
   1.122 +        b.append(Strings.LINE_SEPARATOR);
   1.123 +        b.append(getProperties());
   1.124 +        b.append(END);
   1.125 +        b.append(':');
   1.126 +        b.append(getName());
   1.127 +        b.append(Strings.LINE_SEPARATOR);
   1.128 +        return b.toString();
   1.129 +    }
   1.130 +
   1.131 +    /**
   1.132 +     * {@inheritDoc}
   1.133 +     */
   1.134 +    public final void validate(final boolean recurse)
   1.135 +            throws ValidationException {
   1.136 +
   1.137 +        /*
   1.138 +         * ; 'uiid' is required, but MUST NOT occur more ; than once uiid /
   1.139 +         */
   1.140 +        PropertyValidator.getInstance().assertOne(Property.UID,
   1.141 +                getProperties());
   1.142 +
   1.143 +        /*
   1.144 +         *                ; the following are optional,
   1.145 +         *                ; but MUST NOT occur more than once
   1.146 +         *
   1.147 +         *                name / description / street-address / extended-address /
   1.148 +         *                locality / region / country / postal-code / tzid / geo /
   1.149 +         *                location-type / categories /
   1.150 +         *                dtstamp / created / last-modified
   1.151 +         */
   1.152 +        PropertyValidator.getInstance().assertOneOrLess(Property.NAME,
   1.153 +                getProperties());
   1.154 +        PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION,
   1.155 +                getProperties());
   1.156 +        PropertyValidator.getInstance().assertOneOrLess(Property.STREET_ADDRESS,
   1.157 +                getProperties());
   1.158 +        PropertyValidator.getInstance().assertOneOrLess(Property.EXTENDED_ADDRESS,
   1.159 +                getProperties());
   1.160 +        PropertyValidator.getInstance().assertOneOrLess(Property.LOCALITY,
   1.161 +                getProperties());
   1.162 +        PropertyValidator.getInstance().assertOneOrLess(Property.REGION,
   1.163 +                getProperties());
   1.164 +        PropertyValidator.getInstance().assertOneOrLess(Property.COUNTRY,
   1.165 +                getProperties());
   1.166 +        PropertyValidator.getInstance().assertOneOrLess(Property.POSTALCODE,
   1.167 +                getProperties());
   1.168 +        PropertyValidator.getInstance().assertOneOrLess(Property.TZID,
   1.169 +                getProperties());
   1.170 +        PropertyValidator.getInstance().assertOneOrLess(Property.GEO,
   1.171 +                getProperties());
   1.172 +        PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION_TYPE,
   1.173 +                getProperties());
   1.174 +        PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES,
   1.175 +                getProperties());
   1.176 +        PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP,
   1.177 +                getProperties());
   1.178 +        PropertyValidator.getInstance().assertOneOrLess(Property.CREATED,
   1.179 +                getProperties());
   1.180 +        PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED,
   1.181 +                getProperties());
   1.182 +
   1.183 +        /*
   1.184 +         * ; the following is optional, ; and MAY occur more than once tel / url / x-prop
   1.185 +         */
   1.186 +
   1.187 +        if (recurse) {
   1.188 +            validateProperties();
   1.189 +        }
   1.190 +    }
   1.191 +
   1.192 +    /**
   1.193 +     * {@inheritDoc}
   1.194 +     */
   1.195 +    protected Validator getValidator(Method method) {
   1.196 +        // No method validation required.. 
   1.197 +        return EMPTY_VALIDATOR;
   1.198 +    }
   1.199 +}

mercurial