1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.emailcommon.mail; 18 19 import java.util.ArrayList; 20 21 public abstract class Multipart implements Body { 22 protected Part mParent; 23 24 protected ArrayList<BodyPart> mParts = new ArrayList<BodyPart>(); 25 26 protected String mContentType; 27 addBodyPart(BodyPart part)28 public void addBodyPart(BodyPart part) throws MessagingException { 29 mParts.add(part); 30 } 31 addBodyPart(BodyPart part, int index)32 public void addBodyPart(BodyPart part, int index) throws MessagingException { 33 mParts.add(index, part); 34 } 35 getBodyPart(int index)36 public BodyPart getBodyPart(int index) throws MessagingException { 37 return mParts.get(index); 38 } 39 getContentType()40 public String getContentType() throws MessagingException { 41 return mContentType; 42 } 43 getCount()44 public int getCount() throws MessagingException { 45 return mParts.size(); 46 } 47 removeBodyPart(BodyPart part)48 public boolean removeBodyPart(BodyPart part) throws MessagingException { 49 return mParts.remove(part); 50 } 51 removeBodyPart(int index)52 public void removeBodyPart(int index) throws MessagingException { 53 mParts.remove(index); 54 } 55 getParent()56 public Part getParent() throws MessagingException { 57 return mParent; 58 } 59 setParent(Part parent)60 public void setParent(Part parent) throws MessagingException { 61 this.mParent = parent; 62 } 63 } 64