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 com.example.android.mmslib.pdu;
19 
20 import com.example.android.mmslib.InvalidHeaderValueException;
21 
22 /**
23  * M-Delivery.Ind Pdu.
24  */
25 public class DeliveryInd extends GenericPdu {
26     /**
27      * Empty constructor.
28      * Since the Pdu corresponding to this class is constructed
29      * by the Proxy-Relay server, this class is only instantiated
30      * by the Pdu Parser.
31      *
32      * @throws InvalidHeaderValueException if error occurs.
33      */
DeliveryInd()34     public DeliveryInd() throws InvalidHeaderValueException {
35         super();
36         setMessageType(PduHeaders.MESSAGE_TYPE_DELIVERY_IND);
37     }
38 
39     /**
40      * Constructor with given headers.
41      *
42      * @param headers Headers for this PDU.
43      */
DeliveryInd(PduHeaders headers)44     DeliveryInd(PduHeaders headers) {
45         super(headers);
46     }
47 
48     /**
49      * Get Date value.
50      *
51      * @return the value
52      */
getDate()53     public long getDate() {
54         return mPduHeaders.getLongInteger(PduHeaders.DATE);
55     }
56 
57     /**
58      * Set Date value.
59      *
60      * @param value the value
61      */
setDate(long value)62     public void setDate(long value) {
63         mPduHeaders.setLongInteger(value, PduHeaders.DATE);
64     }
65 
66     /**
67      * Get Message-ID value.
68      *
69      * @return the value
70      */
getMessageId()71     public byte[] getMessageId() {
72         return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
73     }
74 
75     /**
76      * Set Message-ID value.
77      *
78      * @param value the value, should not be null
79      * @throws NullPointerException if the value is null.
80      */
setMessageId(byte[] value)81     public void setMessageId(byte[] value) {
82         mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
83     }
84 
85     /**
86      * Get Status value.
87      *
88      * @return the value
89      */
getStatus()90     public int getStatus() {
91         return mPduHeaders.getOctet(PduHeaders.STATUS);
92     }
93 
94     /**
95      * Set Status value.
96      *
97      * @param value the value
98      * @throws InvalidHeaderValueException if the value is invalid.
99      */
setStatus(int value)100     public void setStatus(int value) throws InvalidHeaderValueException {
101         mPduHeaders.setOctet(value, PduHeaders.STATUS);
102     }
103 
104     /**
105      * Get To value.
106      *
107      * @return the value
108      */
getTo()109     public EncodedStringValue[] getTo() {
110         return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
111     }
112 
113     /**
114      * set To value.
115      *
116      * @param value the value
117      * @throws NullPointerException if the value is null.
118      */
setTo(EncodedStringValue[] value)119     public void setTo(EncodedStringValue[] value) {
120         mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
121     }
122 
123     /*
124      * Optional, not supported header fields:
125      *
126      *     public byte[] getApplicId() {return null;}
127      *     public void setApplicId(byte[] value) {}
128      *
129      *     public byte[] getAuxApplicId() {return null;}
130      *     public void getAuxApplicId(byte[] value) {}
131      *
132      *     public byte[] getReplyApplicId() {return 0x00;}
133      *     public void setReplyApplicId(byte[] value) {}
134      *
135      *     public EncodedStringValue getStatusText() {return null;}
136      *     public void setStatusText(EncodedStringValue value) {}
137      */
138 }
139