| 1 | package ezvcard.property; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import ezvcard.SupportedVersions; |
| 6 | import ezvcard.VCardVersion; |
| 7 | import ezvcard.parameter.Pid; |
| 8 | |
| 9 | /* |
| 10 | Copyright (c) 2012-2023, Michael Angstadt |
| 11 | All rights reserved. |
| 12 | |
| 13 | Redistribution and use in source and binary forms, with or without |
| 14 | modification, are permitted provided that the following conditions are met: |
| 15 | |
| 16 | 1. Redistributions of source code must retain the above copyright notice, this |
| 17 | list of conditions and the following disclaimer. |
| 18 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 19 | this list of conditions and the following disclaimer in the documentation |
| 20 | and/or other materials provided with the distribution. |
| 21 | |
| 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 26 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
| 33 | The views and conclusions contained in the software and documentation are those |
| 34 | of the authors and should not be interpreted as representing official policies, |
| 35 | either expressed or implied, of the FreeBSD Project. |
| 36 | */ |
| 37 | |
| 38 | /** |
| 39 | * <p> |
| 40 | * Defines a URL that points to the person's calendar. |
| 41 | * </p> |
| 42 | * |
| 43 | * <p> |
| 44 | * <b>Code sample</b> |
| 45 | * </p> |
| 46 | * |
| 47 | * <pre class="brush:java"> |
| 48 | * VCard vcard = new VCard(); |
| 49 | * |
| 50 | * CalendarUri caluri = new CalendarUri("http://www.ibm.com/janedoe/calendar"); |
| 51 | * vcard.addCalendarUri(caluri); |
| 52 | * </pre> |
| 53 | * |
| 54 | * <p> |
| 55 | * <b>Property name:</b> {@code CALURI} |
| 56 | * </p> |
| 57 | * <p> |
| 58 | * <b>Supported versions:</b> {@code 4.0} |
| 59 | * </p> |
| 60 | * @author Michael Angstadt |
| 61 | * @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350 p.50</a> |
| 62 | */ |
| 63 | @SupportedVersions(VCardVersion.V4_0) |
| 64 | public class CalendarUri extends UriProperty implements HasAltId { |
| 65 | /** |
| 66 | * Creates a calendar URI property. |
| 67 | * @param uri the calendar URI |
| 68 | */ |
| 69 | public CalendarUri(String uri) { |
| 70 | super(uri); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Copy constructor. |
| 75 | * @param original the property to make a copy of |
| 76 | */ |
| 77 | public CalendarUri(CalendarUri original) { |
| 78 | super(original); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Gets the MEDIATYPE parameter. |
| 83 | * <p> |
| 84 | * <b>Supported versions:</b> {@code 4.0} |
| 85 | * </p> |
| 86 | * @return the media type or null if not set |
| 87 | */ |
| 88 | public String getMediaType() { |
| 89 | return parameters.getMediaType(); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Sets the MEDIATYPE parameter. |
| 94 | * <p> |
| 95 | * <b>Supported versions:</b> {@code 4.0} |
| 96 | * </p> |
| 97 | * @param mediaType the media type or null to remove |
| 98 | */ |
| 99 | public void setMediaType(String mediaType) { |
| 100 | parameters.setMediaType(mediaType); |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public List<Pid> getPids() { |
| 105 | return super.getPids(); |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public Integer getPref() { |
| 110 | return super.getPref(); |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public void setPref(Integer pref) { |
| 115 | super.setPref(pref); |
| 116 | } |
| 117 | |
| 118 | //@Override |
| 119 | public String getAltId() { |
| 120 | return parameters.getAltId(); |
| 121 | } |
| 122 | |
| 123 | //@Override |
| 124 | public void setAltId(String altId) { |
| 125 | parameters.setAltId(altId); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Gets the TYPE parameter. |
| 130 | * <p> |
| 131 | * <b>Supported versions:</b> {@code 4.0} |
| 132 | * </p> |
| 133 | * @return the TYPE value (typically, this will be either "work" or "home") |
| 134 | * or null if it doesn't exist |
| 135 | */ |
| 136 | public String getType() { |
| 137 | return parameters.getType(); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Sets the TYPE parameter. |
| 142 | * <p> |
| 143 | * <b>Supported versions:</b> {@code 4.0} |
| 144 | * </p> |
| 145 | * @param type the TYPE value (this should be either "work" or "home") or |
| 146 | * null to remove |
| 147 | */ |
| 148 | public void setType(String type) { |
| 149 | parameters.setType(type); |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public CalendarUri copy() { |
| 154 | return new CalendarUri(this); |
| 155 | } |
| 156 | } |