FileDocCategorySizeDatePackage
MimeHeader.javaAPI DocAndroid 1.5 API4211Wed May 06 22:42:46 BST 2009com.android.email.mail.internet

MimeHeader

public class MimeHeader extends Object

Fields Summary
public static final String
HEADER_ANDROID_ATTACHMENT_STORE_DATA
Application specific header that contains Store specific information about an attachment. In IMAP this contains the IMAP BODYSTRUCTURE part id so that the ImapStore can later retrieve the attachment at will from the server. The info is recorded from this header on LocalStore.appendMessages and is put back into the MIME data by LocalStore.fetch.
public static final String
HEADER_CONTENT_TYPE
public static final String
HEADER_CONTENT_TRANSFER_ENCODING
public static final String
HEADER_CONTENT_DISPOSITION
public static final String
HEADER_CONTENT_ID
private static final String[]
writeOmitFields
Fields that should be omitted when writing the header using writeTo()
protected ArrayList
mFields
Constructors Summary
Methods Summary
public voidaddHeader(java.lang.String name, java.lang.String value)

        mFields.add(new Field(name, MimeUtility.foldAndEncode(value)));
    
public voidclear()


       
        mFields.clear();
    
public java.lang.StringgetFirstHeader(java.lang.String name)

        String[] header = getHeader(name);
        if (header == null) {
            return null;
        }
        return header[0];
    
public java.lang.String[]getHeader(java.lang.String name)

        ArrayList<String> values = new ArrayList<String>();
        for (Field field : mFields) {
            if (field.name.equalsIgnoreCase(name)) {
                values.add(field.value);
            }
        }
        if (values.size() == 0) {
            return null;
        }
        return values.toArray(new String[] {});
    
public voidremoveHeader(java.lang.String name)

        ArrayList<Field> removeFields = new ArrayList<Field>();
        for (Field field : mFields) {
            if (field.name.equalsIgnoreCase(name)) {
                removeFields.add(field);
            }
        }
        mFields.removeAll(removeFields);
    
public voidsetHeader(java.lang.String name, java.lang.String value)

        if (name == null || value == null) {
            return;
        }
        removeHeader(name);
        addHeader(name, value);
    
public voidwriteTo(java.io.OutputStream out)

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
        for (Field field : mFields) {
            if (!Utility.arrayContains(writeOmitFields, field.name)) {
                writer.write(field.name + ": " + field.value + "\r\n");
            }
        }
        writer.flush();