View Javadoc
1   /*
2    * To change this template, choose Tools | Templates
3    * and open the template in the editor.
4    */
5   package net.sf.atmodem4j.core.gsm;
6   
7   /*
8    * #%L
9    * ATModem4J Core
10   * %%
11   * Copyright (C) 2009 - 2014 atmodem4j
12   * %%
13   * atmodem4j - Drivers for the AT modem - http://atmodem4j.sourceforge.net/
14   * Copyright (C) 2009-2014, atmodem4j.sf.net, and individual contributors as indicated
15   * by the @authors tag. See the copyright.txt in the distribution for a
16   * full listing of individual contributors.
17   * 
18   * This is free software; you can redistribute it and/or modify it
19   * under the terms of the GNU General Public License as
20   * published by the Free Software Foundation; either version 3 of
21   * the License, or (at your option) any later version.
22   * 
23   * This software is distributed in the hope that it will be useful,
24   * but WITHOUT ANY WARRANTY; without even the implied warranty of
25   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26   * Lesser General Public License for more details.
27   * 
28   * You should have received a copy of the GNU Lesser General Public
29   * License along with this software; if not, write to the Free
30   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
32   * #L%
33   */
34  
35  /**
36   *
37   * @author aploese
38   */
39  public class Pdu {
40  
41      /**
42       * @return the compressed
43       */
44      public boolean isCompressed() {
45          return compressed;
46      }
47  
48      /**
49       * @param compressed the compressed to set
50       */
51      public void setCompressed(boolean compressed) {
52          this.compressed = compressed;
53      }
54  
55      /**
56       * @return the encoding
57       */
58      public Encoding getEncoding() {
59          return data.getEncoding();
60      }
61  
62      /**
63       * @param encoding the encoding to set
64       */
65      public void setEncoding(Encoding encoding) {
66          switch (encoding) {
67              case TEXT_7BIT:
68                  data = new UserData.Text7Bit();
69                  break;
70              case DATA_8BIT:
71                  data = new UserData.Data8Bit();
72                  break;
73              case TEXT_16BIT:
74                  data = new UserData.Text16Bit();
75                  break;
76          }
77      }
78  
79      /**
80       * @return the smscAddress
81       */
82      public String getSmscAddress() {
83          return smscAddress;
84      }
85  
86      /**
87       * @param smscAddress the smscAddress to set
88       */
89      public void setSmscAddress(String smscAddress) {
90          this.smscAddress = smscAddress;
91      }
92  
93      /**
94       * @return the partIndex
95       */
96      public short getPartIndex() {
97          return partIndex;
98      }
99  
100     /**
101      * @param partIndex the partIndex to set
102      */
103     public void setPartIndex(short partIndex) {
104         this.partIndex = partIndex;
105     }
106 
107     /**
108      * @return the partCount
109      */
110     public short getPartCount() {
111         return partCount;
112     }
113 
114     /**
115      * @param partCount the partCount to set
116      */
117     public void setPartCount(short partCount) {
118         this.partCount = partCount;
119     }
120 
121     /**
122      * @return the msgId
123      */
124     public int getMsgId() {
125         return msgId;
126     }
127 
128     /**
129      * @param msgId the msgId to set
130      */
131     public void setMsgId(int msgId) {
132         this.msgId = msgId;
133     }
134 
135     /**
136      * @return the userData
137      */
138     public UserData getUserData() {
139         return data;
140     }
141 
142     /**
143      * @param userData the userData to set
144      */
145     public void setUserData(byte[] data, int userDataLength, int userDataHeaderLength) {
146         this.data.decodePduData(data, userDataLength, userDataHeaderLength);
147     }
148 
149     public static enum Encoding {
150 
151         TEXT_7BIT, DATA_8BIT, TEXT_16BIT
152     };
153 
154     public static class EncodingException extends Exception {
155         private static final long serialVersionUID = -8158245714142434697L;
156 
157         EncodingException(String message) {
158             super(message);
159         }
160         
161     }
162 
163     public static enum TimeToLife {
164 
165         HOURS, DAYS, WEEKS
166     };
167     
168     private String smscAddress;
169     private boolean compressed;
170     private short partIndex;
171     private short partCount;
172     private int msgId;
173     private UserData data;
174 
175     public String getText() {
176         return data.getText();
177     }
178 
179 }