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.util; michael@0: michael@0: import net.fortuna.ical4j.model.Property; michael@0: import net.fortuna.ical4j.model.property.Action; michael@0: import net.fortuna.ical4j.model.property.CalScale; michael@0: import net.fortuna.ical4j.model.property.Clazz; michael@0: import net.fortuna.ical4j.model.property.Method; michael@0: import net.fortuna.ical4j.model.property.Priority; michael@0: import net.fortuna.ical4j.model.property.Status; michael@0: import net.fortuna.ical4j.model.property.Transp; michael@0: import net.fortuna.ical4j.model.property.Version; michael@0: michael@0: /** michael@0: * $Id$ michael@0: * michael@0: * Created on 5/07/2005 michael@0: * michael@0: * Provides some convenience methods for working with constant michael@0: * parameters and properties. michael@0: * @author Ben Fortuna michael@0: */ michael@0: public final class Constants { michael@0: michael@0: /** michael@0: * Constructor made private to enforce static nature. michael@0: */ michael@0: private Constants() { michael@0: } michael@0: michael@0: /** michael@0: * Returns a constant equivalent to the specified property michael@0: * if one is applicable. Otherwise will return the specified michael@0: * property. michael@0: * @param property a property instance michael@0: * @return an equivalent constant property, or the specified property if no equivalent michael@0: * constant exists michael@0: */ michael@0: public static Property forProperty(final Property property) { michael@0: Property retVal = property; michael@0: if (Action.AUDIO.equals(property)) { michael@0: retVal = Action.AUDIO; michael@0: } michael@0: else if (Action.DISPLAY.equals(property)) { michael@0: retVal = Action.DISPLAY; michael@0: } michael@0: else if (Action.EMAIL.equals(property)) { michael@0: retVal = Action.EMAIL; michael@0: } michael@0: else if (Action.PROCEDURE.equals(property)) { michael@0: retVal = Action.PROCEDURE; michael@0: } michael@0: else if (CalScale.GREGORIAN.equals(property)) { michael@0: retVal = CalScale.GREGORIAN; michael@0: } michael@0: else if (Clazz.CONFIDENTIAL.equals(property)) { michael@0: retVal = Clazz.CONFIDENTIAL; michael@0: } michael@0: else if (Clazz.PRIVATE.equals(property)) { michael@0: retVal = Clazz.PRIVATE; michael@0: } michael@0: else if (Clazz.PUBLIC.equals(property)) { michael@0: retVal = Clazz.PUBLIC; michael@0: } michael@0: else if (Method.ADD.equals(property)) { michael@0: retVal = Method.ADD; michael@0: } michael@0: else if (Method.CANCEL.equals(property)) { michael@0: retVal = Method.CANCEL; michael@0: } michael@0: else if (Method.COUNTER.equals(property)) { michael@0: retVal = Method.COUNTER; michael@0: } michael@0: else if (Method.DECLINE_COUNTER.equals(property)) { michael@0: retVal = Method.DECLINE_COUNTER; michael@0: } michael@0: else if (Method.PUBLISH.equals(property)) { michael@0: retVal = Method.PUBLISH; michael@0: } michael@0: else if (Method.REFRESH.equals(property)) { michael@0: retVal = Method.REFRESH; michael@0: } michael@0: else if (Method.REPLY.equals(property)) { michael@0: retVal = Method.REPLY; michael@0: } michael@0: else if (Method.REQUEST.equals(property)) { michael@0: retVal = Method.REQUEST; michael@0: } michael@0: else if (Priority.HIGH.equals(property)) { michael@0: retVal = Priority.HIGH; michael@0: } michael@0: else if (Priority.LOW.equals(property)) { michael@0: retVal = Priority.LOW; michael@0: } michael@0: else if (Priority.MEDIUM.equals(property)) { michael@0: retVal = Priority.MEDIUM; michael@0: } michael@0: else if (Priority.UNDEFINED.equals(property)) { michael@0: retVal = Priority.UNDEFINED; michael@0: } michael@0: else if (Status.VEVENT_CANCELLED.equals(property)) { michael@0: retVal = Status.VEVENT_CANCELLED; michael@0: } michael@0: else if (Status.VEVENT_CONFIRMED.equals(property)) { michael@0: retVal = Status.VEVENT_CONFIRMED; michael@0: } michael@0: else if (Status.VEVENT_TENTATIVE.equals(property)) { michael@0: retVal = Status.VEVENT_TENTATIVE; michael@0: } michael@0: else if (Status.VJOURNAL_CANCELLED.equals(property)) { michael@0: retVal = Status.VJOURNAL_CANCELLED; michael@0: } michael@0: else if (Status.VJOURNAL_DRAFT.equals(property)) { michael@0: retVal = Status.VJOURNAL_DRAFT; michael@0: } michael@0: else if (Status.VJOURNAL_FINAL.equals(property)) { michael@0: retVal = Status.VJOURNAL_FINAL; michael@0: } michael@0: else if (Status.VTODO_CANCELLED.equals(property)) { michael@0: retVal = Status.VTODO_CANCELLED; michael@0: } michael@0: else if (Status.VTODO_COMPLETED.equals(property)) { michael@0: retVal = Status.VTODO_COMPLETED; michael@0: } michael@0: else if (Status.VTODO_IN_PROCESS.equals(property)) { michael@0: retVal = Status.VTODO_IN_PROCESS; michael@0: } michael@0: else if (Status.VTODO_NEEDS_ACTION.equals(property)) { michael@0: retVal = Status.VTODO_NEEDS_ACTION; michael@0: } michael@0: else if (Transp.OPAQUE.equals(property)) { michael@0: retVal = Transp.OPAQUE; michael@0: } michael@0: else if (Transp.TRANSPARENT.equals(property)) { michael@0: retVal = Transp.TRANSPARENT; michael@0: } michael@0: else if (Version.VERSION_2_0.equals(property)) { michael@0: retVal = Version.VERSION_2_0; michael@0: } michael@0: return retVal; michael@0: } michael@0: }