1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }