org.apache.chemistry.opencmis.commons.impl
Class MimeHelper

java.lang.Object
  extended by org.apache.chemistry.opencmis.commons.impl.MimeHelper

public class MimeHelper
extends Object

MIME helper class.


Nested Class Summary
protected static class MimeHelper.HeaderTokenizer
           
protected static class MimeHelper.ParseException
           
protected static class MimeHelper.Token
           
 
Field Summary
static String CONTENT_DISPOSITION
           
static String DISPOSITION_ATTACHMENT
           
static String DISPOSITION_FILENAME
           
 
Method Summary
static String decodeContentDisposition(String value, Map<String,String> params)
          Decodes the Content-Disposition header value according to RFC 2183 and RFC 2231.
static String decodeContentDispositionFilename(String value)
          Decodes a filename from the Content-Disposition header value according to RFC 2183 and RFC 2231.
protected static String decodeRFC2231value(String value)
           
static String encodeContentDisposition(String disposition, String filename)
          Encodes the Content-Disposition header value according to RFC 2183 and RFC 2231.
protected static String encodeRFC2231(String key, String value)
          Encodes a MIME parameter per RFC 2231.
protected static boolean encodeRFC2231value(String value, StringBuilder buf)
          Encodes a value per RFC 2231.
protected static byte[] fromHex(String data)
           
protected static String getJavaCharset(String mimeCharset)
           
protected static Map<String,String> getParameters(String list, Map<String,String> params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_DISPOSITION

public static final String CONTENT_DISPOSITION
See Also:
Constant Field Values

DISPOSITION_ATTACHMENT

public static final String DISPOSITION_ATTACHMENT
See Also:
Constant Field Values

DISPOSITION_FILENAME

public static final String DISPOSITION_FILENAME
See Also:
Constant Field Values
Method Detail

encodeRFC2231value

protected static boolean encodeRFC2231value(String value,
                                            StringBuilder buf)
Encodes a value per RFC 2231.

This is used to pass non-ASCII parameters to MIME parameter lists.

This implementation always uses UTF-8 and no language.

See RFC 2231 for details.

Parameters:
value - the value to encode
buf - the buffer to fill
Returns:
true if an encoding was needed, or false if no encoding was actually needed

encodeRFC2231

protected static String encodeRFC2231(String key,
                                      String value)
Encodes a MIME parameter per RFC 2231.

This implementation always uses UTF-8 and no language.

See RFC 2231 for details.

Parameters:
value - the string to encode
Returns:
the encoded string

encodeContentDisposition

public static String encodeContentDisposition(String disposition,
                                              String filename)
Encodes the Content-Disposition header value according to RFC 2183 and RFC 2231.

See RFC 2231 for details.

Parameters:
disposition - the disposition
filename - the file name
Returns:
the encoded header value

decodeContentDispositionFilename

public static String decodeContentDispositionFilename(String value)
Decodes a filename from the Content-Disposition header value according to RFC 2183 and RFC 2231.

See RFC 2231 for details.

Parameters:
value - the header value to decode
Returns:
the filename

decodeContentDisposition

public static String decodeContentDisposition(String value,
                                              Map<String,String> params)
Decodes the Content-Disposition header value according to RFC 2183 and RFC 2231.

Does not deal with continuation lines.

See RFC 2231 for details.

Parameters:
value - the header value to decode
params - the map of parameters to fill
Returns:
the disposition

getParameters

protected static Map<String,String> getParameters(String list,
                                                  Map<String,String> params)
                                           throws MimeHelper.ParseException
Throws:
MimeHelper.ParseException

decodeRFC2231value

protected static String decodeRFC2231value(String value)

fromHex

protected static byte[] fromHex(String data)

getJavaCharset

protected static String getJavaCharset(String mimeCharset)


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.