michael@0: /** michael@0: * Copyright (c) 2012, Ben Fortuna michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * o Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * o Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * o Neither the name of Ben Fortuna nor the names of any other contributors michael@0: * may be used to endorse or promote products derived from this software michael@0: * without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF michael@0: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING michael@0: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@0: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: package net.fortuna.ical4j.model.component; michael@0: michael@0: import net.fortuna.ical4j.model.Property; michael@0: import net.fortuna.ical4j.model.PropertyList; michael@0: import net.fortuna.ical4j.model.ValidationException; michael@0: import net.fortuna.ical4j.model.Validator; michael@0: import net.fortuna.ical4j.model.property.Method; michael@0: import net.fortuna.ical4j.util.PropertyValidator; michael@0: import net.fortuna.ical4j.util.Strings; michael@0: michael@0: /** michael@0: * $Id $ [Apr 5, 2004] michael@0: * michael@0: * Defines an iCalendar VVENUE component. michael@0: * michael@0: *
michael@0: * 4. Venue Component michael@0: * michael@0: * Component Name: "VVENUE" michael@0: * michael@0: * Purpose: Provide a grouping of component properties that describe an michael@0: * event venue. michael@0: * michael@0: * Format Definition: A "VVENUE" calendar component is defined by the michael@0: * following notation: michael@0: * venuec = "BEGIN" ":" "VVENUE" CRLF michael@0: * venueprop michael@0: * "END" ":" "VVENUE" CRLF michael@0: * michael@0: * venueprop = *( michael@0: * michael@0: * ; the following are all REQUIRED, michael@0: * ; but MUST NOT occur more than once michael@0: * michael@0: * uid michael@0: * michael@0: * ; the following are optional, michael@0: * ; but MUST NOT occur more than once michael@0: * michael@0: * name / description / street-address / extended-address / michael@0: * locality / region / country / postal-code / tzid / geo / michael@0: * location-type / categories michael@0: * michael@0: * ; the following are optional, michael@0: * ; and MAY occur more than once michael@0: * michael@0: * tel / url michael@0: * ) michael@0: * michael@0: * Description: A "VVENUE" calendar component is a grouping of component michael@0: * properties that represent a venue where an event occurs. This michael@0: * extends the "LOCATION" property of "VEVENT" and "TODO" components, michael@0: * providing the ability to specify detailed information about the event michael@0: * venue. michael@0: * michael@0: *michael@0: * michael@0: * @author Ben Fortuna michael@0: * @author Mike Douglass michael@0: */ michael@0: public class VVenue extends CalendarComponent { michael@0: michael@0: private static final long serialVersionUID = 4502423035501438515L; michael@0: michael@0: /** michael@0: * Default constructor. michael@0: */ michael@0: public VVenue() { michael@0: super(VVENUE); michael@0: } michael@0: michael@0: /** michael@0: * Constructs a new instance containing the specified properties. michael@0: * @param properties a list of properties michael@0: */ michael@0: public VVenue(final PropertyList properties) { michael@0: super(VVENUE, properties); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final String toString() { michael@0: final StringBuffer b = new StringBuffer(); michael@0: b.append(BEGIN); michael@0: b.append(':'); michael@0: b.append(getName()); michael@0: b.append(Strings.LINE_SEPARATOR); michael@0: b.append(getProperties()); michael@0: b.append(END); michael@0: b.append(':'); michael@0: b.append(getName()); michael@0: b.append(Strings.LINE_SEPARATOR); michael@0: return b.toString(); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final void validate(final boolean recurse) michael@0: throws ValidationException { michael@0: michael@0: /* michael@0: * ; 'uiid' is required, but MUST NOT occur more ; than once uiid / michael@0: */ michael@0: PropertyValidator.getInstance().assertOne(Property.UID, michael@0: getProperties()); michael@0: michael@0: /* michael@0: * ; the following are optional, michael@0: * ; but MUST NOT occur more than once michael@0: * michael@0: * name / description / street-address / extended-address / michael@0: * locality / region / country / postal-code / tzid / geo / michael@0: * location-type / categories / michael@0: * dtstamp / created / last-modified michael@0: */ michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.NAME, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.STREET_ADDRESS, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.EXTENDED_ADDRESS, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.LOCALITY, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.REGION, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.COUNTRY, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.POSTALCODE, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.TZID, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.GEO, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION_TYPE, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, michael@0: getProperties()); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, michael@0: getProperties()); michael@0: michael@0: /* michael@0: * ; the following is optional, ; and MAY occur more than once tel / url / x-prop michael@0: */ michael@0: michael@0: if (recurse) { michael@0: validateProperties(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: protected Validator getValidator(Method method) { michael@0: // No method validation required.. michael@0: return EMPTY_VALIDATOR; michael@0: } michael@0: }