1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.messageboards.util;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.util.HtmlUtil;
19  import com.liferay.portal.kernel.util.ObjectValuePair;
20  import com.liferay.portal.kernel.util.Validator;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * <a href="MBMailMessage.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Jorge Ferrer
29   */
30  public class MBMailMessage {
31  
32      public void addFile(String fileName, byte[] bytes) {
33          _files.add(new ObjectValuePair<String, byte[]>(fileName, bytes));
34      }
35  
36      public List<ObjectValuePair<String, byte[]>> getFiles() {
37          return _files;
38      }
39  
40      public String getHtmlBody() {
41          return _htmlBody;
42      }
43  
44      public void setHtmlBody(String htmlBody) {
45          _htmlBody = htmlBody;
46      }
47  
48      public String getPlainBody() {
49          return _plainBody;
50      }
51  
52      public void setPlainBody(String plainBody) {
53          _plainBody = plainBody;
54      }
55  
56      public String getBody() {
57          if (Validator.isNotNull(_plainBody)) {
58              return GetterUtil.getString(_plainBody);
59          }
60          else if (Validator.isNotNull(_htmlBody)) {
61              return HtmlUtil.extractText(_htmlBody);
62          }
63          else {
64              return "-";
65          }
66      }
67  
68      private String _htmlBody;
69      private String _plainBody;
70      private List<ObjectValuePair<String, byte[]>> _files =
71          new ArrayList<ObjectValuePair<String, byte[]>>();
72  
73  }