• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Esmertec AG.
3  * Copyright (C) 2007 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package android.support.v7.mms.pdu;
19 
20 public class GenericPdu {
21     /**
22      * The headers of pdu.
23      */
24     PduHeaders mPduHeaders = null;
25 
26     /**
27      * Constructor.
28      */
GenericPdu()29     public GenericPdu() {
30         mPduHeaders = new PduHeaders();
31     }
32 
33     /**
34      * Constructor.
35      *
36      * @param headers Headers for this PDU.
37      */
GenericPdu(PduHeaders headers)38     GenericPdu(PduHeaders headers) {
39         mPduHeaders = headers;
40     }
41 
42     /**
43      * Get the headers of this PDU.
44      *
45      * @return A PduHeaders of this PDU.
46      */
getPduHeaders()47     PduHeaders getPduHeaders() {
48         return mPduHeaders;
49     }
50 
51     /**
52      * Get X-Mms-Message-Type field value.
53      *
54      * @return the X-Mms-Report-Allowed value
55      */
getMessageType()56     public int getMessageType() {
57         return mPduHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
58     }
59 
60     /**
61      * Set X-Mms-Message-Type field value.
62      *
63      * @param value the value
64      * @throws InvalidHeaderValueException if the value is invalid.
65      *         RuntimeException if field's value is not Octet.
66      */
setMessageType(int value)67     public void setMessageType(int value) throws InvalidHeaderValueException {
68         mPduHeaders.setOctet(value, PduHeaders.MESSAGE_TYPE);
69     }
70 
71     /**
72      * Get X-Mms-MMS-Version field value.
73      *
74      * @return the X-Mms-MMS-Version value
75      */
getMmsVersion()76     public int getMmsVersion() {
77         return mPduHeaders.getOctet(PduHeaders.MMS_VERSION);
78     }
79 
80     /**
81      * Set X-Mms-MMS-Version field value.
82      *
83      * @param value the value
84      * @throws InvalidHeaderValueException if the value is invalid.
85      *         RuntimeException if field's value is not Octet.
86      */
setMmsVersion(int value)87     public void setMmsVersion(int value) throws InvalidHeaderValueException {
88         mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION);
89     }
90 
91     /**
92      * Get From value.
93      * From-value = Value-length
94      *      (Address-present-token Encoded-string-value | Insert-address-token)
95      *
96      * @return the value
97      */
getFrom()98     public EncodedStringValue getFrom() {
99        return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
100     }
101 
102     /**
103      * Set From value.
104      *
105      * @param value the value
106      * @throws NullPointerException if the value is null.
107      */
setFrom(EncodedStringValue value)108     public void setFrom(EncodedStringValue value) {
109         mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
110     }
111 }
112