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