Tue, 10 Feb 2015 18:12:00 +0100
Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.
michael@0 | 1 | /** |
michael@0 | 2 | * Copyright (c) 2012, Ben Fortuna |
michael@0 | 3 | * All rights reserved. |
michael@0 | 4 | * |
michael@0 | 5 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 6 | * modification, are permitted provided that the following conditions |
michael@0 | 7 | * are met: |
michael@0 | 8 | * |
michael@0 | 9 | * o Redistributions of source code must retain the above copyright |
michael@0 | 10 | * notice, this list of conditions and the following disclaimer. |
michael@0 | 11 | * |
michael@0 | 12 | * o Redistributions in binary form must reproduce the above copyright |
michael@0 | 13 | * notice, this list of conditions and the following disclaimer in the |
michael@0 | 14 | * documentation and/or other materials provided with the distribution. |
michael@0 | 15 | * |
michael@0 | 16 | * o Neither the name of Ben Fortuna nor the names of any other contributors |
michael@0 | 17 | * may be used to endorse or promote products derived from this software |
michael@0 | 18 | * without specific prior written permission. |
michael@0 | 19 | * |
michael@0 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
michael@0 | 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
michael@0 | 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
michael@0 | 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
michael@0 | 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 31 | */ |
michael@0 | 32 | package net.fortuna.ical4j.util; |
michael@0 | 33 | |
michael@0 | 34 | import net.fortuna.ical4j.model.Property; |
michael@0 | 35 | import net.fortuna.ical4j.model.property.Action; |
michael@0 | 36 | import net.fortuna.ical4j.model.property.CalScale; |
michael@0 | 37 | import net.fortuna.ical4j.model.property.Clazz; |
michael@0 | 38 | import net.fortuna.ical4j.model.property.Method; |
michael@0 | 39 | import net.fortuna.ical4j.model.property.Priority; |
michael@0 | 40 | import net.fortuna.ical4j.model.property.Status; |
michael@0 | 41 | import net.fortuna.ical4j.model.property.Transp; |
michael@0 | 42 | import net.fortuna.ical4j.model.property.Version; |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * $Id$ |
michael@0 | 46 | * |
michael@0 | 47 | * Created on 5/07/2005 |
michael@0 | 48 | * |
michael@0 | 49 | * Provides some convenience methods for working with constant |
michael@0 | 50 | * parameters and properties. |
michael@0 | 51 | * @author Ben Fortuna |
michael@0 | 52 | */ |
michael@0 | 53 | public final class Constants { |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Constructor made private to enforce static nature. |
michael@0 | 57 | */ |
michael@0 | 58 | private Constants() { |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Returns a constant equivalent to the specified property |
michael@0 | 63 | * if one is applicable. Otherwise will return the specified |
michael@0 | 64 | * property. |
michael@0 | 65 | * @param property a property instance |
michael@0 | 66 | * @return an equivalent constant property, or the specified property if no equivalent |
michael@0 | 67 | * constant exists |
michael@0 | 68 | */ |
michael@0 | 69 | public static Property forProperty(final Property property) { |
michael@0 | 70 | Property retVal = property; |
michael@0 | 71 | if (Action.AUDIO.equals(property)) { |
michael@0 | 72 | retVal = Action.AUDIO; |
michael@0 | 73 | } |
michael@0 | 74 | else if (Action.DISPLAY.equals(property)) { |
michael@0 | 75 | retVal = Action.DISPLAY; |
michael@0 | 76 | } |
michael@0 | 77 | else if (Action.EMAIL.equals(property)) { |
michael@0 | 78 | retVal = Action.EMAIL; |
michael@0 | 79 | } |
michael@0 | 80 | else if (Action.PROCEDURE.equals(property)) { |
michael@0 | 81 | retVal = Action.PROCEDURE; |
michael@0 | 82 | } |
michael@0 | 83 | else if (CalScale.GREGORIAN.equals(property)) { |
michael@0 | 84 | retVal = CalScale.GREGORIAN; |
michael@0 | 85 | } |
michael@0 | 86 | else if (Clazz.CONFIDENTIAL.equals(property)) { |
michael@0 | 87 | retVal = Clazz.CONFIDENTIAL; |
michael@0 | 88 | } |
michael@0 | 89 | else if (Clazz.PRIVATE.equals(property)) { |
michael@0 | 90 | retVal = Clazz.PRIVATE; |
michael@0 | 91 | } |
michael@0 | 92 | else if (Clazz.PUBLIC.equals(property)) { |
michael@0 | 93 | retVal = Clazz.PUBLIC; |
michael@0 | 94 | } |
michael@0 | 95 | else if (Method.ADD.equals(property)) { |
michael@0 | 96 | retVal = Method.ADD; |
michael@0 | 97 | } |
michael@0 | 98 | else if (Method.CANCEL.equals(property)) { |
michael@0 | 99 | retVal = Method.CANCEL; |
michael@0 | 100 | } |
michael@0 | 101 | else if (Method.COUNTER.equals(property)) { |
michael@0 | 102 | retVal = Method.COUNTER; |
michael@0 | 103 | } |
michael@0 | 104 | else if (Method.DECLINE_COUNTER.equals(property)) { |
michael@0 | 105 | retVal = Method.DECLINE_COUNTER; |
michael@0 | 106 | } |
michael@0 | 107 | else if (Method.PUBLISH.equals(property)) { |
michael@0 | 108 | retVal = Method.PUBLISH; |
michael@0 | 109 | } |
michael@0 | 110 | else if (Method.REFRESH.equals(property)) { |
michael@0 | 111 | retVal = Method.REFRESH; |
michael@0 | 112 | } |
michael@0 | 113 | else if (Method.REPLY.equals(property)) { |
michael@0 | 114 | retVal = Method.REPLY; |
michael@0 | 115 | } |
michael@0 | 116 | else if (Method.REQUEST.equals(property)) { |
michael@0 | 117 | retVal = Method.REQUEST; |
michael@0 | 118 | } |
michael@0 | 119 | else if (Priority.HIGH.equals(property)) { |
michael@0 | 120 | retVal = Priority.HIGH; |
michael@0 | 121 | } |
michael@0 | 122 | else if (Priority.LOW.equals(property)) { |
michael@0 | 123 | retVal = Priority.LOW; |
michael@0 | 124 | } |
michael@0 | 125 | else if (Priority.MEDIUM.equals(property)) { |
michael@0 | 126 | retVal = Priority.MEDIUM; |
michael@0 | 127 | } |
michael@0 | 128 | else if (Priority.UNDEFINED.equals(property)) { |
michael@0 | 129 | retVal = Priority.UNDEFINED; |
michael@0 | 130 | } |
michael@0 | 131 | else if (Status.VEVENT_CANCELLED.equals(property)) { |
michael@0 | 132 | retVal = Status.VEVENT_CANCELLED; |
michael@0 | 133 | } |
michael@0 | 134 | else if (Status.VEVENT_CONFIRMED.equals(property)) { |
michael@0 | 135 | retVal = Status.VEVENT_CONFIRMED; |
michael@0 | 136 | } |
michael@0 | 137 | else if (Status.VEVENT_TENTATIVE.equals(property)) { |
michael@0 | 138 | retVal = Status.VEVENT_TENTATIVE; |
michael@0 | 139 | } |
michael@0 | 140 | else if (Status.VJOURNAL_CANCELLED.equals(property)) { |
michael@0 | 141 | retVal = Status.VJOURNAL_CANCELLED; |
michael@0 | 142 | } |
michael@0 | 143 | else if (Status.VJOURNAL_DRAFT.equals(property)) { |
michael@0 | 144 | retVal = Status.VJOURNAL_DRAFT; |
michael@0 | 145 | } |
michael@0 | 146 | else if (Status.VJOURNAL_FINAL.equals(property)) { |
michael@0 | 147 | retVal = Status.VJOURNAL_FINAL; |
michael@0 | 148 | } |
michael@0 | 149 | else if (Status.VTODO_CANCELLED.equals(property)) { |
michael@0 | 150 | retVal = Status.VTODO_CANCELLED; |
michael@0 | 151 | } |
michael@0 | 152 | else if (Status.VTODO_COMPLETED.equals(property)) { |
michael@0 | 153 | retVal = Status.VTODO_COMPLETED; |
michael@0 | 154 | } |
michael@0 | 155 | else if (Status.VTODO_IN_PROCESS.equals(property)) { |
michael@0 | 156 | retVal = Status.VTODO_IN_PROCESS; |
michael@0 | 157 | } |
michael@0 | 158 | else if (Status.VTODO_NEEDS_ACTION.equals(property)) { |
michael@0 | 159 | retVal = Status.VTODO_NEEDS_ACTION; |
michael@0 | 160 | } |
michael@0 | 161 | else if (Transp.OPAQUE.equals(property)) { |
michael@0 | 162 | retVal = Transp.OPAQUE; |
michael@0 | 163 | } |
michael@0 | 164 | else if (Transp.TRANSPARENT.equals(property)) { |
michael@0 | 165 | retVal = Transp.TRANSPARENT; |
michael@0 | 166 | } |
michael@0 | 167 | else if (Version.VERSION_2_0.equals(property)) { |
michael@0 | 168 | retVal = Version.VERSION_2_0; |
michael@0 | 169 | } |
michael@0 | 170 | return retVal; |
michael@0 | 171 | } |
michael@0 | 172 | } |