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.android.messaging.mmslib.pdu; 19 20 import com.android.messaging.mmslib.InvalidHeaderValueException; 21 22 public class GenericPdu { 23 /** 24 * The headers of pdu. 25 */ 26 PduHeaders mPduHeaders = null; 27 28 /** 29 * Constructor. 30 */ 31 public GenericPdu() { 32 mPduHeaders = new PduHeaders(); 33 } 34 35 /** 36 * Constructor. 37 * 38 * @param headers Headers for this PDU. 39 */ 40 GenericPdu(PduHeaders headers) { 41 mPduHeaders = headers; 42 } 43 44 /** 45 * Get the headers of this PDU. 46 * 47 * @return A PduHeaders of this PDU. 48 */ 49 PduHeaders getPduHeaders() { 50 return mPduHeaders; 51 } 52 53 /** 54 * Get X-Mms-Message-Type field value. 55 * 56 * @return the X-Mms-Report-Allowed value 57 */ 58 public int getMessageType() { 59 return mPduHeaders.getOctet(PduHeaders.MESSAGE_TYPE); 60 } 61 62 /** 63 * Set X-Mms-Message-Type field value. 64 * 65 * @param value the value 66 * @throws InvalidHeaderValueException if the value is invalid. 67 * @throws RuntimeException if field's value is not Octet. 68 */ 69 public void setMessageType(int value) throws InvalidHeaderValueException { 70 mPduHeaders.setOctet(value, PduHeaders.MESSAGE_TYPE); 71 } 72 73 /** 74 * Get X-Mms-MMS-Version field value. 75 * 76 * @return the X-Mms-MMS-Version value 77 */ 78 public int getMmsVersion() { 79 return mPduHeaders.getOctet(PduHeaders.MMS_VERSION); 80 } 81 82 /** 83 * Set X-Mms-MMS-Version field value. 84 * 85 * @param value the value 86 * @throws InvalidHeaderValueException if the value is invalid. 87 * @throws RuntimeException if field's value is not Octet. 88 */ 89 public void setMmsVersion(int value) throws InvalidHeaderValueException { 90 mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION); 91 } 92 93 /** 94 * Get From value. 95 * From-value = Value-length 96 * (Address-present-token Encoded-string-value | Insert-address-token) 97 * 98 * @return the value 99 */ 100 public EncodedStringValue getFrom() { 101 return mPduHeaders.getEncodedStringValue(PduHeaders.FROM); 102 } 103 104 /** 105 * Set From value. 106 * 107 * @param value the value 108 * @throws NullPointerException if the value is null. 109 */ 110 public void setFrom(EncodedStringValue value) { 111 mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM); 112 } 113 } 114