1 /*
2  * Copyright (C) 2015 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 package com.android.phone.common.mail;
17 
18 import java.util.ArrayList;
19 
20 public abstract class Multipart implements Body {
21     protected Part mParent;
22 
23     protected ArrayList<BodyPart> mParts = new ArrayList<BodyPart>();
24 
25     protected String mContentType;
26 
addBodyPart(BodyPart part)27     public void addBodyPart(BodyPart part) throws MessagingException {
28         mParts.add(part);
29     }
30 
addBodyPart(BodyPart part, int index)31     public void addBodyPart(BodyPart part, int index) throws MessagingException {
32         mParts.add(index, part);
33     }
34 
getBodyPart(int index)35     public BodyPart getBodyPart(int index) throws MessagingException {
36         return mParts.get(index);
37     }
38 
getContentType()39     public String getContentType() throws MessagingException {
40         return mContentType;
41     }
42 
getCount()43     public int getCount() throws MessagingException {
44         return mParts.size();
45     }
46 
removeBodyPart(BodyPart part)47     public boolean removeBodyPart(BodyPart part) throws MessagingException {
48         return mParts.remove(part);
49     }
50 
removeBodyPart(int index)51     public void removeBodyPart(int index) throws MessagingException {
52         mParts.remove(index);
53     }
54 
getParent()55     public Part getParent() throws MessagingException {
56         return mParent;
57     }
58 
setParent(Part parent)59     public void setParent(Part parent) throws MessagingException {
60         this.mParent = parent;
61     }
62 }
63