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 public class ReadOrigInd extends GenericPdu {
23     /**
24      * Empty constructor.
25      * Since the Pdu corresponding to this class is constructed
26      * by the Proxy-Relay server, this class is only instantiated
27      * by the Pdu Parser.
28      *
29      * @throws InvalidHeaderValueException if error occurs.
30      */
ReadOrigInd()31     public ReadOrigInd() throws InvalidHeaderValueException {
32         super();
33         setMessageType(PduHeaders.MESSAGE_TYPE_READ_ORIG_IND);
34     }
35 
36     /**
37      * Constructor with given headers.
38      *
39      * @param headers Headers for this PDU.
40      */
ReadOrigInd(PduHeaders headers)41     ReadOrigInd(PduHeaders headers) {
42         super(headers);
43     }
44 
45     /**
46      * Get Date value.
47      *
48      * @return the value
49      */
getDate()50     public long getDate() {
51         return mPduHeaders.getLongInteger(PduHeaders.DATE);
52     }
53 
54     /**
55      * Set Date value.
56      *
57      * @param value the value
58      */
setDate(long value)59     public void setDate(long value) {
60         mPduHeaders.setLongInteger(value, PduHeaders.DATE);
61     }
62 
63     /**
64      * Get From value.
65      * From-value = Value-length
66      *      (Address-present-token Encoded-string-value | Insert-address-token)
67      *
68      * @return the value
69      */
getFrom()70     public EncodedStringValue getFrom() {
71        return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
72     }
73 
74     /**
75      * Set From value.
76      *
77      * @param value the value
78      * @throws NullPointerException if the value is null.
79      */
setFrom(EncodedStringValue value)80     public void setFrom(EncodedStringValue value) {
81         mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
82     }
83 
84     /**
85      * Get Message-ID value.
86      *
87      * @return the value
88      */
getMessageId()89     public byte[] getMessageId() {
90         return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
91     }
92 
93     /**
94      * Set Message-ID value.
95      *
96      * @param value the value
97      * @throws NullPointerException if the value is null.
98      */
setMessageId(byte[] value)99     public void setMessageId(byte[] value) {
100         mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
101     }
102 
103     /**
104      * Get X-MMS-Read-status value.
105      *
106      * @return the value
107      */
getReadStatus()108     public int getReadStatus() {
109         return mPduHeaders.getOctet(PduHeaders.READ_STATUS);
110     }
111 
112     /**
113      * Set X-MMS-Read-status value.
114      *
115      * @param value the value
116      * @throws InvalidHeaderValueException if the value is invalid.
117      */
setReadStatus(int value)118     public void setReadStatus(int value) throws InvalidHeaderValueException {
119         mPduHeaders.setOctet(value, PduHeaders.READ_STATUS);
120     }
121 
122     /**
123      * Get To value.
124      *
125      * @return the value
126      */
getTo()127     public EncodedStringValue[] getTo() {
128         return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
129     }
130 
131     /**
132      * Set To value.
133      *
134      * @param value the value
135      * @throws NullPointerException if the value is null.
136      */
setTo(EncodedStringValue[] value)137     public void setTo(EncodedStringValue[] value) {
138         mPduHeaders.setEncodedStringValues(value, PduHeaders.TO);
139     }
140 
141     /*
142      * Optional, not supported header fields:
143      *
144      *     public byte[] getApplicId() {return null;}
145      *     public void setApplicId(byte[] value) {}
146      *
147      *     public byte[] getAuxApplicId() {return null;}
148      *     public void getAuxApplicId(byte[] value) {}
149      *
150      *     public byte[] getReplyApplicId() {return 0x00;}
151      *     public void setReplyApplicId(byte[] value) {}
152      */
153 }
154