src/net/fortuna/ical4j/model/parameter/Encoding.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.parameter;
    34 import net.fortuna.ical4j.model.Parameter;
    35 import net.fortuna.ical4j.model.ParameterFactoryImpl;
    36 import net.fortuna.ical4j.util.Strings;
    38 /**
    39  * $Id$ [18-Apr-2004]
    40  *
    41  * Defines an Inline Encoding parameter. Constants are provided for all encodings specified in <a
    42  * href="http://www.ietf.org/rfc/rfc2045.txt">RFC2045</a>.
    43  *
    44  * <pre>
    45  *  4.2.7 Inline Encoding
    46  *
    47  *     Parameter Name: ENCODING
    48  *
    49  *     Purpose: To specify an alternate inline encoding for the property
    50  *     value.
    51  *
    52  *     Format Definition: The property parameter is defined by the following
    53  *     notation:
    54  *
    55  *       encodingparam      = &quot;ENCODING&quot; &quot;=&quot;
    56  *                            (&quot;8BIT&quot;
    57  *          ; &quot;8bit&quot; text encoding is defined in [RFC 2045]
    58  *                          / &quot;BASE64&quot;
    59  *          ; &quot;BASE64&quot; binary encoding format is defined in [RFC 2045]
    60  *                          / iana-token
    61  *          ; Some other IANA registered iCalendar encoding type
    62  *                          / x-name)
    63  *          ; A non-standard, experimental encoding type
    64  *
    65  *     Description: The property parameter identifies the inline encoding
    66  *     used in a property value. The default encoding is &quot;8BIT&quot;,
    67  *     corresponding to a property value consisting of text. The &quot;BASE64&quot;
    68  *     encoding type corresponds to a property value encoded using the
    69  *     &quot;BASE64&quot; encoding defined in [RFC 2045].
    70  *
    71  *     If the value type parameter is &quot;;VALUE=BINARY&quot;, then the inline
    72  *     encoding parameter MUST be specified with the value
    73  *     &quot;;ENCODING=BASE64&quot;.
    74  *
    75  *     Example:
    76  *
    77  *       ATTACH;FMTYPE=IMAGE/JPEG;ENCODING=BASE64;VALUE=BINARY:MIICajC
    78  *        CAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDA
    79  *        qBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRw
    80  *        &lt;...remainder of &quot;BASE64&quot; encoded binary data...&gt;
    81  * </pre>
    82  *
    83  * @author Ben Fortuna
    84  */
    85 public class Encoding extends Parameter {
    87     private static final long serialVersionUID = 7536336461076399077L;
    89     private static final String VALUE_SEVEN_BIT = "7BIT";
    91     private static final String VALUE_EIGHT_BIT = "8BIT";
    93     private static final String VALUE_BINARY = "BINARY";
    95     private static final String VALUE_QUOTED_PRINTABLE = "QUOTED-PRINTABLE";
    97     private static final String VALUE_BASE64 = "BASE64";
    99     /**
   100      * 7 bit encoding.
   101      */
   102     public static final Encoding SEVEN_BIT = new Encoding(VALUE_SEVEN_BIT);
   104     /**
   105      * 8 bit encoding.
   106      */
   107     public static final Encoding EIGHT_BIT = new Encoding(VALUE_EIGHT_BIT);
   109     /**
   110      * Binary encoding.
   111      */
   112     public static final Encoding BINARY = new Encoding(VALUE_BINARY);
   114     /**
   115      * Quoted printable encoding.
   116      */
   117     public static final Encoding QUOTED_PRINTABLE = new Encoding(
   118             VALUE_QUOTED_PRINTABLE);
   120     /**
   121      * Base64 encoding.
   122      */
   123     public static final Encoding BASE64 = new Encoding(VALUE_BASE64);
   125     private String value;
   127     /**
   128      * @param aValue a string representation of an Inline Encoding
   129      */
   130     public Encoding(final String aValue) {
   131         super(ENCODING, ParameterFactoryImpl.getInstance());
   132         this.value = Strings.unquote(aValue);
   133     }
   135     /**
   136      * {@inheritDoc}
   137      */
   138     public final String getValue() {
   139         return value;
   140     }
   141 }

mercurial