001 package ezvcard.types; 002 003 import java.util.List; 004 005 /* 006 Copyright (c) 2013, Michael Angstadt 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without 010 modification, are permitted provided that the following conditions are met: 011 012 1. Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 2. Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 019 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 020 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 022 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 024 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 025 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 026 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 027 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 028 029 The views and conclusions contained in the software and documentation are those 030 of the authors and should not be interpreted as representing official policies, 031 either expressed or implied, of the FreeBSD Project. 032 */ 033 034 /** 035 * A URL pointing to the person's homepage or business website. 036 * 037 * <p> 038 * <b>Code sample</b> 039 * </p> 040 * 041 * <pre> 042 * VCard vcard = new VCard(); 043 * UrlType url = new UrlType("http://www.company.com"); 044 * vcard.addUrl(url); 045 * </pre> 046 * 047 * <p> 048 * <b>Property name:</b> <code>URL</code> 049 * </p> 050 * <p> 051 * <b>Supported versions:</b> <code>2.1, 3.0, 4.0</code> 052 * </p> 053 * @author Michael Angstadt 054 */ 055 public class UrlType extends UriType implements HasAltId { 056 public static final String NAME = "URL"; 057 058 /** 059 * Creates an empty URL property. 060 */ 061 public UrlType() { 062 this(null); 063 } 064 065 /** 066 * Creates a URL property. 067 * @param url the URL (e.g. "http://example.com") 068 */ 069 public UrlType(String url) { 070 super(NAME, url); 071 } 072 073 /** 074 * Gets the MEDIATYPE parameter. 075 * <p> 076 * <b>Supported versions:</b> <code>4.0</code> 077 * </p> 078 * @return the media type or null if not set 079 */ 080 public String getMediaType() { 081 return subTypes.getMediaType(); 082 } 083 084 /** 085 * Sets the MEDIATYPE parameter. 086 * <p> 087 * <b>Supported versions:</b> <code>4.0</code> 088 * </p> 089 * @param mediaType the media type or null to remove 090 */ 091 public void setMediaType(String mediaType) { 092 subTypes.setMediaType(mediaType); 093 } 094 095 @Override 096 public List<Integer[]> getPids() { 097 return super.getPids(); 098 } 099 100 @Override 101 public void addPid(int localId, int clientPidMapRef) { 102 super.addPid(localId, clientPidMapRef); 103 } 104 105 @Override 106 public void removePids() { 107 super.removePids(); 108 } 109 110 @Override 111 public Integer getPref() { 112 return super.getPref(); 113 } 114 115 @Override 116 public void setPref(Integer pref) { 117 super.setPref(pref); 118 } 119 120 //@Override 121 public String getAltId() { 122 return subTypes.getAltId(); 123 } 124 125 //@Override 126 public void setAltId(String altId) { 127 subTypes.setAltId(altId); 128 } 129 130 /** 131 * Gets the TYPE parameter. 132 * <p> 133 * <b>Supported versions:</b> <code>4.0*</code> 134 * </p> 135 * 136 * <p> 137 * <i>* Some mail clients will add this parameter to URL types in 2.1 and 138 * 3.0 vCards, however.</i> 139 * </p> 140 * 141 * @return the TYPE value (typically, this will be either "work" or "home") 142 * or null if it doesn't exist 143 */ 144 public String getType() { 145 return subTypes.getType(); 146 } 147 148 /** 149 * Sets the TYPE parameter. 150 * <p> 151 * <b>Supported versions:</b> <code>4.0*</code> 152 * </p> 153 * 154 * <p> 155 * <i>* Some mail clients will add this parameter to URL types in 2.1 and 156 * 3.0 vCards, however.</i> 157 * </p> 158 * @param type the TYPE value (this should be either "work" or "home") or 159 * null to remove 160 */ 161 public void setType(String type) { 162 subTypes.setType(type); 163 } 164 }