michael@0: /** michael@0: * Copyright (c) 2012, Ben Fortuna michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * o Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * o Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * o Neither the name of Ben Fortuna nor the names of any other contributors michael@0: * may be used to endorse or promote products derived from this software michael@0: * without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF michael@0: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING michael@0: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@0: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: package net.fortuna.ical4j.model.parameter; michael@0: michael@0: import net.fortuna.ical4j.model.Parameter; michael@0: import net.fortuna.ical4j.model.ParameterFactoryImpl; michael@0: import net.fortuna.ical4j.util.Strings; michael@0: michael@0: /** michael@0: * $Id$ [18-Apr-2004] michael@0: * michael@0: * Defines an Inline Encoding parameter. Constants are provided for all encodings specified in RFC2045. michael@0: * michael@0: *
michael@0: * 4.2.7 Inline Encoding michael@0: * michael@0: * Parameter Name: ENCODING michael@0: * michael@0: * Purpose: To specify an alternate inline encoding for the property michael@0: * value. michael@0: * michael@0: * Format Definition: The property parameter is defined by the following michael@0: * notation: michael@0: * michael@0: * encodingparam = "ENCODING" "=" michael@0: * ("8BIT" michael@0: * ; "8bit" text encoding is defined in [RFC 2045] michael@0: * / "BASE64" michael@0: * ; "BASE64" binary encoding format is defined in [RFC 2045] michael@0: * / iana-token michael@0: * ; Some other IANA registered iCalendar encoding type michael@0: * / x-name) michael@0: * ; A non-standard, experimental encoding type michael@0: * michael@0: * Description: The property parameter identifies the inline encoding michael@0: * used in a property value. The default encoding is "8BIT", michael@0: * corresponding to a property value consisting of text. The "BASE64" michael@0: * encoding type corresponds to a property value encoded using the michael@0: * "BASE64" encoding defined in [RFC 2045]. michael@0: * michael@0: * If the value type parameter is ";VALUE=BINARY", then the inline michael@0: * encoding parameter MUST be specified with the value michael@0: * ";ENCODING=BASE64". michael@0: * michael@0: * Example: michael@0: * michael@0: * ATTACH;FMTYPE=IMAGE/JPEG;ENCODING=BASE64;VALUE=BINARY:MIICajC michael@0: * CAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDA michael@0: * qBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRw michael@0: * <...remainder of "BASE64" encoded binary data...> michael@0: *michael@0: * michael@0: * @author Ben Fortuna michael@0: */ michael@0: public class Encoding extends Parameter { michael@0: michael@0: private static final long serialVersionUID = 7536336461076399077L; michael@0: michael@0: private static final String VALUE_SEVEN_BIT = "7BIT"; michael@0: michael@0: private static final String VALUE_EIGHT_BIT = "8BIT"; michael@0: michael@0: private static final String VALUE_BINARY = "BINARY"; michael@0: michael@0: private static final String VALUE_QUOTED_PRINTABLE = "QUOTED-PRINTABLE"; michael@0: michael@0: private static final String VALUE_BASE64 = "BASE64"; michael@0: michael@0: /** michael@0: * 7 bit encoding. michael@0: */ michael@0: public static final Encoding SEVEN_BIT = new Encoding(VALUE_SEVEN_BIT); michael@0: michael@0: /** michael@0: * 8 bit encoding. michael@0: */ michael@0: public static final Encoding EIGHT_BIT = new Encoding(VALUE_EIGHT_BIT); michael@0: michael@0: /** michael@0: * Binary encoding. michael@0: */ michael@0: public static final Encoding BINARY = new Encoding(VALUE_BINARY); michael@0: michael@0: /** michael@0: * Quoted printable encoding. michael@0: */ michael@0: public static final Encoding QUOTED_PRINTABLE = new Encoding( michael@0: VALUE_QUOTED_PRINTABLE); michael@0: michael@0: /** michael@0: * Base64 encoding. michael@0: */ michael@0: public static final Encoding BASE64 = new Encoding(VALUE_BASE64); michael@0: michael@0: private String value; michael@0: michael@0: /** michael@0: * @param aValue a string representation of an Inline Encoding michael@0: */ michael@0: public Encoding(final String aValue) { michael@0: super(ENCODING, ParameterFactoryImpl.getInstance()); michael@0: this.value = Strings.unquote(aValue); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final String getValue() { michael@0: return value; michael@0: } michael@0: }