View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.messagebox.model;
17  
18  import org.fourthline.cling.support.messagebox.parser.MessageElement;
19  
20  /**
21   * Sender and body will only be displayed if display type is set to "Maximum".
22   *
23   * @author Christian Bauer
24   */
25  public class MessageSMS extends Message {
26  
27      final private DateTime receiveTime;
28      final private NumberName receiver;
29      final private NumberName sender;
30      final private String body;
31  
32      public MessageSMS(NumberName receiver, NumberName sender, String body) {
33          this(new DateTime(), receiver, sender, body);
34      }
35  
36      public MessageSMS(DateTime receiveTime, NumberName receiver, NumberName sender, String body) {
37          this(Message.DisplayType.MAXIMUM, receiveTime, receiver, sender, body);
38      }
39  
40      public MessageSMS(DisplayType displayType, DateTime receiveTime, NumberName receiver, NumberName sender, String body) {
41          super(Message.Category.SMS, displayType);
42          this.receiveTime = receiveTime;
43          this.receiver = receiver;
44          this.sender = sender;
45          this.body = body;
46      }
47  
48      public DateTime getReceiveTime() {
49          return receiveTime;
50      }
51  
52      public NumberName getReceiver() {
53          return receiver;
54      }
55  
56      public NumberName getSender() {
57          return sender;
58      }
59  
60      public String getBody() {
61          return body;
62      }
63  
64      public void appendMessageElements(MessageElement parent) {
65          getReceiveTime().appendMessageElements(parent.createChild("ReceiveTime"));
66          getReceiver().appendMessageElements(parent.createChild("Receiver"));
67          getSender().appendMessageElements(parent.createChild("Sender"));
68          parent.createChild("Body").setContent(getBody());
69      }
70      
71  }