src/net/fortuna/ical4j/model/property/Url.java

Tue, 10 Feb 2015 18:12:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 18:12:00 +0100
changeset 0
fb9019fb1bf7
permissions
-rw-r--r--

Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.

     1 /**
     2  * Copyright (c) 2012, Ben Fortuna
     3  * All rights reserved.
     4  *
     5  * Redistribution and use in source and binary forms, with or without
     6  * modification, are permitted provided that the following conditions
     7  * are met:
     8  *
     9  *  o Redistributions of source code must retain the above copyright
    10  * notice, this list of conditions and the following disclaimer.
    11  *
    12  *  o Redistributions in binary form must reproduce the above copyright
    13  * notice, this list of conditions and the following disclaimer in the
    14  * documentation and/or other materials provided with the distribution.
    15  *
    16  *  o Neither the name of Ben Fortuna nor the names of any other contributors
    17  * may be used to endorse or promote products derived from this software
    18  * without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  */
    32 package net.fortuna.ical4j.model.property;
    34 import java.net.URI;
    35 import java.net.URISyntaxException;
    37 import net.fortuna.ical4j.model.ParameterList;
    38 import net.fortuna.ical4j.model.Property;
    39 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    40 import net.fortuna.ical4j.model.ValidationException;
    41 import net.fortuna.ical4j.util.Strings;
    42 import net.fortuna.ical4j.util.Uris;
    44 /**
    45  * $Id$
    46  * 
    47  * Created: [Apr 6, 2004]
    48  *
    49  * Defines a URL iCalendar component property.
    50  * 
    51  * <pre>
    52  *     4.8.4.6 Uniform Resource Locator
    53  *     
    54  *        Property Name: URL
    55  *     
    56  *        Purpose: This property defines a Uniform Resource Locator (URL)
    57  *        associated with the iCalendar object.
    58  *     
    59  *        Value Type: URI
    60  *     
    61  *        Property Parameters: Non-standard property parameters can be
    62  *        specified on this property.
    63  *     
    64  *        Conformance: This property can be specified once in the &quot;VEVENT&quot;,
    65  *        &quot;VTODO&quot;, &quot;VJOURNAL&quot; or &quot;VFREEBUSY&quot; calendar components.
    66  *     
    67  *        Description: This property may be used in a calendar component to
    68  *        convey a location where a more dynamic rendition of the calendar
    69  *        information associated with the calendar component can be found. This
    70  *        memo does not attempt to standardize the form of the URI, nor the
    71  *        format of the resource pointed to by the property value. If the URL
    72  *        property and Content-Location MIME header are both specified, they
    73  *        MUST point to the same resource.
    74  *     
    75  *        Format Definition: The property is defined by the following notation:
    76  *     
    77  *          url        = &quot;URL&quot; urlparam &quot;:&quot; uri CRLF
    78  *     
    79  *          urlparam   = *(&quot;;&quot; xparam)
    80  *     
    81  *        Example: The following is an example of this property:
    82  *     
    83  *          URL:http://abc.com/pub/calendars/jsmith/mytime.ics
    84  * </pre>
    85  * 
    86  * @author Ben Fortuna
    87  */
    88 public class Url extends Property {
    90     private static final long serialVersionUID = 1092576402256525737L;
    92     private URI uri;
    94     /**
    95      * Default constructor.
    96      */
    97     public Url() {
    98         super(URL, PropertyFactoryImpl.getInstance());
    99     }
   101     /**
   102      * @param aList a list of parameters for this component
   103      * @param aValue a value string for this component
   104      * @throws URISyntaxException where the specified value string is not a valid uri
   105      */
   106     public Url(final ParameterList aList, final String aValue)
   107             throws URISyntaxException {
   108         super(URL, aList, PropertyFactoryImpl.getInstance());
   109         setValue(aValue);
   110     }
   112     /**
   113      * @param aUri a URI
   114      */
   115     public Url(final URI aUri) {
   116         super(URL, PropertyFactoryImpl.getInstance());
   117         uri = aUri;
   118     }
   120     /**
   121      * @param aList a list of parameters for this component
   122      * @param aUri a URI
   123      */
   124     public Url(final ParameterList aList, final URI aUri) {
   125         super(URL, aList, PropertyFactoryImpl.getInstance());
   126         uri = aUri;
   127     }
   129     /**
   130      * @return Returns the uri.
   131      */
   132     public final URI getUri() {
   133         return uri;
   134     }
   136     /**
   137      * {@inheritDoc}
   138      */
   139     public final void setValue(final String aValue) throws URISyntaxException {
   140         uri = Uris.create(aValue);
   141     }
   143     /**
   144      * {@inheritDoc}
   145      */
   146     public final String getValue() {
   147         return Uris.decode(Strings.valueOf(getUri()));
   148     }
   150     /**
   151      * @param uri The uri to set.
   152      */
   153     public final void setUri(final URI uri) {
   154         this.uri = uri;
   155     }
   157     /**
   158      * {@inheritDoc}
   159      */
   160     public final void validate() throws ValidationException {
   161         // TODO: Auto-generated method stub
   162     }
   163 }

mercurial