NotSynchronousException is thrown when
15 | * Session's (synchronous) method receive is called when
16 | * the Receiver is in asynchronous state, i.e when all PDUs received
17 | * from the SMSC are passed to an instance of implementation of
18 | * ServerPDUListener class.
19 |
20 | * @author Logica Mobile Networks SMPP Open Source Team
21 | * @version $Revision: 1.2 $
22 | */
23 |
24 | public class NotSynchronousException extends SmppException {
25 | private static final long serialVersionUID = -2785891348929001265L;
26 | private Session session = null;
27 |
28 | public NotSynchronousException() {
29 | }
30 |
31 | public NotSynchronousException(Session session) {
32 | this.session = session;
33 | }
34 |
35 | public Session getSession() {
36 | return session;
37 | }
38 |
39 | }
40 | /*
41 | * $Log: not supported by cvs2svn $
42 | * Revision 1.1 2003/07/23 00:28:39 sverkera
43 | * Imported
44 | *
45 | */
46 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/OutbindEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import org.smpp.pdu.Outbind;
14 |
15 | /**
16 | * Created when outbind pdu is received from smsc.
17 | * This event is created and passed to the OutbindEventListener by
18 | * the OutbindReceiver.
19 | *
20 | * @author Logica Mobile Networks SMPP Open Source Team
21 | * @version $Revision: 1.2 $
22 | * @see OutbindReceiver
23 | * @see OutbindEventListener
24 | */
25 |
26 | /*
27 | 21-08-01 ticp@logica.com now derived from common ReceivedPDUEvent
28 | and functionality covered by new parent
29 | removed from this class
30 | */
31 |
32 | public class OutbindEvent extends ReceivedPDUEvent {
33 | private static final long serialVersionUID = 1808913846085130877L;
34 |
35 | /**
36 | * Construct event for outbind pdu received over conection
37 | * belonging to the outbind receiver.
38 | */
39 | public OutbindEvent(OutbindReceiver source, Connection connection, Outbind outbindPDU) {
40 | super(source, connection, outbindPDU);
41 | }
42 |
43 | /**
44 | * Returns the outbind receiver thru which was received the outbind pdu
45 | * this event relates to.
46 | */
47 | public OutbindReceiver getReceiver() {
48 | return (OutbindReceiver) getSource();
49 | }
50 |
51 | /**
52 | * Returns the outbind pdu.
53 | */
54 | public Outbind getOutbindPDU() {
55 | return (Outbind) getPDU();
56 | }
57 |
58 | }
59 | /*
60 | * $Log: not supported by cvs2svn $
61 | * Revision 1.1 2003/07/23 00:28:39 sverkera
62 | * Imported
63 | *
64 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/OutbindEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import java.util.EventListener;
14 |
15 | /**
16 | * Callback interface for Outbind requests received from SMSC.
17 | * The only method of this interface, handleOutbind, is called
18 | * whenever an outbind request is received from SMSC.handleOutbind method is called
20 | * from the receiver's thread context, so the implementation of the listener
21 | * should ensure that there is no deadloock, or at least not too much
22 | * time spent in the method.
23 | *
24 | * @author Logica Mobile Networks SMPP Open Source Team
25 | * @version $Revision: 1.1 $
26 | * @see OutbindReceiver
27 | */
28 |
29 | public interface OutbindEventListener extends EventListener {
30 | public void handleOutbind(OutbindEvent outbind);
31 | }
32 | /*
33 | * $Log: not supported by cvs2svn $
34 | *
35 | * Old changelog:
36 | * 02-10-01 ticp@logica.com comments added
37 | */
38 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/ReceivedPDUEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import java.util.EventObject;
14 |
15 | import org.smpp.pdu.PDU;
16 |
17 | /**
18 | * The base class for events representing receiving a pdu by
19 | * receiver.
20 | *
21 | * @author Logica Mobile Networks SMPP Open Source Team
22 | * @version $Revision: 1.2 $
23 | */
24 | public class ReceivedPDUEvent extends EventObject {
25 | private static final long serialVersionUID = 2888578757849035826L;
26 |
27 | /**
28 | * The connection over which was the pdu received.
29 | */
30 | private transient Connection connection = null;
31 |
32 | /**
33 | * The received pdu.
34 | */
35 | private transient PDU pdu = null;
36 |
37 | /**
38 | * Construct event for pdu received over connection belonging
39 | * to the receiver.
40 | */
41 | public ReceivedPDUEvent(ReceiverBase source, Connection connection, PDU pdu) {
42 | super(source);
43 | this.connection = connection;
44 | this.pdu = pdu;
45 | }
46 |
47 | /**
48 | * Return the connection over which the pdu was received.
49 | */
50 | public Connection getConnection() {
51 | return connection;
52 | }
53 |
54 | /**
55 | * Return the received pdu.
56 | */
57 | public PDU getPDU() {
58 | return pdu;
59 | }
60 |
61 | }
62 | /*
63 | * $Log: not supported by cvs2svn $
64 | * Revision 1.1 2003/07/23 00:28:39 sverkera
65 | * Imported
66 | *
67 | *
68 | * Old changelog:
69 | * 10-10-01 ticp@logica.com connection and pdu carried by the event made transient
70 | * (they are non-serializable)
71 | */
72 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/SSLConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on 2004-jul-12
3 | *
4 | * To change the template for this generated file go to
5 | * Window - Preferences - Java - Code Generation - Code and Comments
6 | */
7 | package org.smpp;
8 |
9 | import java.io.IOException;
10 |
11 | import javax.net.ServerSocketFactory;
12 | import javax.net.SocketFactory;
13 | import javax.net.ssl.SSLServerSocketFactory;
14 | import javax.net.ssl.SSLSocket;
15 | import javax.net.ssl.SSLSocketFactory;
16 |
17 | /**
18 | * @author Sverker Abrahamsson
19 | *
20 | * To change the template for this generated type comment go to
21 | * Window - Preferences - Java - Code Generation - Code and Comments
22 | */
23 | public class SSLConnection extends TCPIPConnection {
24 |
25 | /**
26 | * Override the superclass SocketFactory with a SSLSocketFactory
27 | */
28 | protected SocketFactory socketFactory = SSLSocketFactory.getDefault();
29 |
30 | /**
31 | * Override the superclass ServerSocketFactory with a SSLServerSocketFactory
32 | */
33 | protected ServerSocketFactory serverSocketFactory = SSLServerSocketFactory.getDefault();
34 |
35 | /**
36 | * Initialises the connection with port only, which means that
37 | * the connection will serve as connection receiving server.
38 | * The accepting of the connection must be invoked explicitly by
39 | * calling of accept method.
40 | *
41 | * @param port the port number to listen on
42 | */
43 | public SSLConnection(int port) {
44 | super(port);
45 | }
46 |
47 | /**
48 | * Initialises the connection for client communication.
49 | *
50 | * @param address the address of the remote end
51 | * of the socket
52 | * @param port the port number on the remote host
53 | */
54 | public SSLConnection(String address, int port) {
55 | super(address, port);
56 | }
57 |
58 | /**
59 | * Initialises the connection with existing socket.
60 | * It's intended for use with one server connection which generates
61 | * new sockets and creates connections with the sockets.
62 | *
63 | * @param sslsocket the socket to use for communication
64 | * @see #accept()
65 | * @throws IOException
66 | */
67 | public SSLConnection(SSLSocket sslsocket) throws IOException {
68 | super(sslsocket);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/ServerPDUEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import org.smpp.pdu.PDU;
14 |
15 | /**
16 | * Instance of this class is created and passed to
17 | * the ServerPDUEventListener by the Receiver.
18 | *
19 | * @author Logica Mobile Networks SMPP Open Source Team
20 | * @version $Revision: 1.2 $
21 | */
22 | public class ServerPDUEvent extends ReceivedPDUEvent {
23 | private static final long serialVersionUID = 8400363453588829420L;
24 |
25 | /**
26 | * Creates event for provided Receiver and
27 | * Connection with the received PDU.
28 | */
29 | public ServerPDUEvent(Receiver source, Connection connection, PDU pdu) {
30 | super(source, connection, pdu);
31 | }
32 |
33 | /**
34 | * Returns the receiver thru which was received the PDU this
35 | * event relates to.
36 | */
37 | public Receiver getReceiver() {
38 | return (Receiver) getSource();
39 | }
40 |
41 | }
42 | /*
43 | * $Log: not supported by cvs2svn $
44 | * Revision 1.1 2003/07/23 00:28:39 sverkera
45 | * Imported
46 | *
47 | */
48 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/ServerPDUEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import java.util.EventListener;
14 |
15 | /**
16 | * The interface ServerPDUEventListener defines method for processing
17 | * of PDUs received by the Receiver from the SMSC.
18 | * Implementation of this interface is used when the communication with
19 | * the SMSC is asynchronous. The asynchronous communication means that
20 | * the Session after sending a request to the SMSC doesn't wait for
21 | * a response to the request sent, instead it returns null. All PDUs received from the SMSC,
22 | * i.e both responses to the sent requests and requests sent on behalf of
23 | * the SMSC, are passed to the instance of ServerPDUEventListener
24 | * implementation class. Users of the library are expected to implement
25 | * the listener.
26 | * handleEvent method is called
27 | * from the receiver's thread context, so the implementation of the listener
28 | * should ensure that there is no deadloock, or at least not too much
29 | * time spent in the method.
30 | *
31 | * @author Logica Mobile Networks SMPP Open Source Team
32 | * @version $Revision: 1.2 $
33 | * @see Receiver#setServerPDUEventListener(ServerPDUEventListener)
34 | * @see Session#setServerPDUEventListener(ServerPDUEventListener)
35 | */
36 | public interface ServerPDUEventListener extends EventListener {
37 | /**
38 | * Meant to process PDUs received from the SMSC.
39 | * This method is called by the Receiver whenever a
40 | * PDU is received from the SMSC.
41 | * @param event the event received from the SMSC
42 | */
43 | public abstract void handleEvent(ServerPDUEvent event);
44 |
45 | }
46 | /*
47 | * $Log: not supported by cvs2svn $
48 | * Revision 1.1 2003/07/23 00:28:39 sverkera
49 | * Imported
50 | *
51 | */
52 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/SmppException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | /**
14 | * Class SmppException is the root of all SMPP Library
15 | * exceptions. Every exception defined in the library SmppException
16 | * as a superclass -- this way class SmppException
17 | * provides single class for catch clause.
18 | *
19 | * @author Logica Mobile Networks SMPP Open Source Team
20 | * @version $Id: SmppException.java 72 2008-07-15 19:43:00Z sverkera $
21 | */
22 |
23 | public class SmppException extends Exception {
24 | private static final long serialVersionUID = 3108928509613380097L;
25 |
26 | /**
27 | * Constructs a SmppException with no specified detail
28 | * message.
29 | */
30 | public SmppException() {
31 | super();
32 | }
33 |
34 | /**
35 | * Constructs a SmppException with a nested exception.
36 | *
37 | * @param e The nested exception
38 | */
39 | public SmppException(Exception e) {
40 | super(e);
41 | }
42 |
43 | /**
44 | * Constructs a SmppException with the specified detail
45 | * message.
46 | *
47 | * @param s the detail message.
48 | */
49 | public SmppException(String s) {
50 | super(s);
51 | }
52 |
53 | /**
54 | * Constructs a SmppException with the specified detail
55 | * message and a nested exception
56 | *
57 | * @param s the detail message.
58 | * @param e The nested exception
59 | */
60 | public SmppException(String s, Exception e) {
61 | super(s, e);
62 | }
63 | }
64 | /*
65 | * $Log: not supported by cvs2svn $
66 | * Revision 1.2 2003/07/24 14:32:21 sverkera
67 | * Added support for nested exception
68 | *
69 | * Revision 1.1 2003/07/23 00:28:39 sverkera
70 | * Imported
71 | *
72 | */
73 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/TimeoutException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | /**
14 | * Thrown when only a part of PDU was received and the rest of the PDU
15 | * hasn't been received for too long time.
16 | *
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.2 $
19 | */
20 | public class TimeoutException extends SmppException {
21 | private static final long serialVersionUID = 4873432724200896611L;
22 |
23 | /** The expired timeout. */
24 | public long timeout = 0;
25 |
26 | /** The expected bytes. */
27 | public int expected = 0;
28 |
29 | /** The received bytes. */
30 | public int received = 0;
31 |
32 | /** Don't allow default constructor */
33 | @SuppressWarnings("unused")
34 | private TimeoutException() {
35 | }
36 |
37 | /**
38 | * Construct with provided timeout and expected and received amount
39 | * of data.
40 | */
41 | public TimeoutException(long timeout, int expected, int received) {
42 | super(
43 | "The rest of pdu not received for "
44 | + (timeout / 1000)
45 | + " seconds. "
46 | + "Expected "
47 | + expected
48 | + " bytes, received "
49 | + received
50 | + " bytes.");
51 | this.timeout = timeout;
52 | this.expected = expected;
53 | this.received = received;
54 | }
55 |
56 | }
57 | /*
58 | * $Log: not supported by cvs2svn $
59 | * Revision 1.1 2003/07/23 00:28:39 sverkera
60 | * Imported
61 | *
62 | *
63 | * Old changelog:
64 | * 01-10-01 ticp@logica.com javadoc wording improved
65 | */
66 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/Transmitter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp;
12 |
13 | import java.io.IOException;
14 |
15 | import org.smpp.pdu.*;
16 |
17 | /**
18 | * Class Transmitter transmits PDUs over connection.
19 | * It is used by Session.
20 | *
21 | * @author Logica Mobile Networks SMPP Open Source Team
22 | * @version $Revision: 1.2 $
23 | * @see Connection
24 | * @see Receiver
25 | * @see Session
26 | */
27 | public class Transmitter extends SmppObject {
28 | /**
29 | * The connection object. It is used for transmitting the PDUs. It's
30 | * created outside of the Transmitter and passed to
31 | * transmitter as a constructor parameter.
32 | * @see Connection
33 | */
34 | private Connection connection = null;
35 |
36 | /**
37 | * Default constructor made protected as it's not desirable to
38 | * allow creation of Transmitter without providing
39 | * Connection.
40 | */
41 | protected Transmitter() {
42 | }
43 |
44 | /**
45 | * Creates Transmitter which uses provided
46 | * Connection. Typically the connection
47 | * parameter will be an instance of TCPIPConnection class.
48 | *
49 | * @param c connection used for transmitting the PDUs
50 | */
51 | public Transmitter(Connection c) {
52 | connection = c;
53 | }
54 |
55 | /**
56 | * Assigns unique sequence number to PDU, if necessary, and sends its
57 | * data over connection.
58 | *
59 | * @param pdu the PDU to send
60 | *
61 | * @exception IOException exception during communication
62 | * @exception ValueNotSetException optional param not set but requested
63 | */
64 | public void send(PDU pdu) throws ValueNotSetException, IOException {
65 | debug.enter(DCOM, this, "send");
66 | pdu.assignSequenceNumber();
67 | try {
68 | debug.write(DCOM, "going to send pdu's data over connection");
69 | connection.send(pdu.getData());
70 | debug.write(DCOM, "successfully sent pdu's data over connection");
71 | } finally {
72 | debug.exit(DCOM, this);
73 | }
74 | }
75 |
76 | }
77 | /*
78 | * $Log: not supported by cvs2svn $
79 | * Revision 1.1 2003/07/23 00:28:39 sverkera
80 | * Imported
81 | *
82 | *
83 | * Old changelog:
84 | * 28-09-01 ticp@logica.com traces added
85 | */
86 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/debug/Debug.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.debug;
12 |
13 | /**
14 | * The interface Debug is an interface to application specific
15 | * debug information trace facility. Users of the SMPP library can either
16 | * use one of the two implementations of the Debug interface --
17 | * DefaultDebug or FileDebug or they can implement
18 | * their own class or create an adapter to their legacy trace facility.
19 | * The SMPP library's root class, SmppObject contains
20 | * object of type Debug so that all descendants of the
21 | * SmppObject class can write trace lines.
22 | * Debug interface which writes
15 | * the trace lines to the System.out and provides simple
16 | * indentation. This is the class whose instance is assigned as a default
17 | * debug class to the SmppObject's debug object.
18 | *
19 | * @see Debug
20 | * @see org.smpp.SmppObject
21 | *
22 | * @author Logica Mobile Networks SMPP Open Source Team
23 | * @version $Revision: 1.1 $
24 | */
25 | public class DefaultDebug implements Debug {
26 | private int indent = 0;
27 | private boolean active = false;
28 |
29 | public void enter(int group, Object from, String name) {
30 | enter(from, name);
31 | }
32 |
33 | public void enter(Object from, String name) {
34 | if (active) {
35 | System.out.println(getDelimiter(true, from, name));
36 | indent++;
37 | }
38 | }
39 |
40 | public void write(int group, String msg) {
41 | write(msg);
42 | }
43 |
44 | public void write(String msg) {
45 | if (active) {
46 | System.out.println(getIndent() + " " + msg);
47 | }
48 | }
49 |
50 | public void exit(int group, Object from) {
51 | exit(from);
52 | }
53 |
54 | public void exit(Object from) {
55 | if (active) {
56 | indent--;
57 | if (indent < 0) {
58 | // it's your fault :-)
59 | indent = 0;
60 | }
61 | System.out.println(getDelimiter(false, from, ""));
62 | }
63 | }
64 |
65 | public void activate() {
66 | active = true;
67 | }
68 | public void activate(int group) {
69 | }
70 | public void deactivate() {
71 | active = false;
72 | }
73 | public void deactivate(int group) {
74 | }
75 |
76 | public boolean active(int group) {
77 | return true;
78 | }
79 |
80 | private String getDelimiter(boolean start, Object from, String name) {
81 | String indentStr = getIndent();
82 | if (start) {
83 | indentStr += "-> ";
84 | } else {
85 | indentStr += "<- ";
86 | }
87 | return indentStr + from.toString() + (name == "" ? "" : " " + name);
88 | }
89 |
90 | private String getIndent() {
91 | String result = new String("");
92 | for (int i = 0; i < indent; i++) {
93 | result += " ";
94 | }
95 | return result;
96 | }
97 | }
98 | /*
99 | * $Log: not supported by cvs2svn $
100 | *
101 | * Old changelog:
102 | * 25-09-01 ticp@logica.com added functions for grouping althoug grouping not
103 | * supported
104 | * 16-10-01 ticp@logica.com added method active(group)
105 | */
106 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/debug/DefaultEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.debug;
12 |
13 | import java.io.StringWriter;
14 | import java.io.PrintWriter;
15 |
16 | /**
17 | * Simple implementation of Event interface which writes
18 | * the event information to the System.out. This is the class
19 | * whose instance is assigned as a default event class to the
20 | * SmppObject's event object.
21 | *
22 | * @author Logica Mobile Networks SMPP Open Source Team
23 | * @version $Revision: 1.1 $
24 | */
25 | public class DefaultEvent implements Event {
26 | private boolean active = false;
27 |
28 | public void write(String msg) {
29 | if (active) {
30 | System.out.println(msg);
31 | }
32 | }
33 |
34 | public void write(Exception e, String msg) {
35 | if (active) {
36 | StringWriter stackOutString = new StringWriter();
37 | PrintWriter stackOut = new PrintWriter(stackOutString);
38 | e.printStackTrace(stackOut);
39 | try {
40 | write("Exception: " + stackOutString.toString() + " " + msg);
41 | } catch (Exception ex) {
42 | System.err.println("Event log failure " + ex);
43 | }
44 | }
45 | }
46 |
47 | public void activate() {
48 | active = true;
49 | }
50 | public void deactivate() {
51 | active = false;
52 | }
53 | }
54 | /*
55 | * $Log: not supported by cvs2svn $
56 | *
57 | * Old changelog:
58 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces
59 | */
60 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/debug/Event.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.debug;
12 |
13 | /**
14 | * The interface Event is an interface to application specific
15 | * event trace facility. It is used in the library to notify about
16 | * like exception. Implementors are expected either to use one of the
17 | * predefined implementations DefaultEvent or
18 | * FileEvent or that the will write an implementation
19 | * which will adapt this interface to their legacy tracing facility.
20 | *
21 | * @author Logica Mobile Networks SMPP Open Source Team
22 | * @version $Revision: 1.1 $
23 | */
24 | public interface Event {
25 | /** Sends a message to the event object. */
26 | public void write(String msg);
27 |
28 | /** Sends an information about exception to the event object. */
29 | public void write(Exception e, String msg);
30 |
31 | /** Activates the event tracing. */
32 | public void activate();
33 |
34 | /** Deactivates the event tracing. */
35 | public void deactivate();
36 | }
37 | /*
38 | * $Log: not supported by cvs2svn $
39 | *
40 | * Old changelog:
41 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces
42 | */
43 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/debug/FileEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.debug;
12 |
13 | import java.io.StringWriter;
14 | import java.io.PrintWriter;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class FileEvent implements Event {
21 | private FileLog log = null;
22 |
23 | public FileEvent(String dir, String name) {
24 | log = new FileLog(dir, name);
25 | activate();
26 | }
27 |
28 | public void write(String msg) {
29 | if (isActive()) {
30 | log.genericWrite(msg == null ? "" : msg);
31 | }
32 | }
33 |
34 | public void write(Exception e, String msg) {
35 | if (isActive()) {
36 | StringWriter stackOutString = new StringWriter();
37 | PrintWriter stackOut = new PrintWriter(stackOutString);
38 | e.printStackTrace(stackOut);
39 | try {
40 | if (msg != null) {
41 | write(msg);
42 | }
43 | write("Exception: " + stackOutString.toString());
44 | } catch (Exception ex) {
45 | System.err.println("Event log failure " + ex);
46 | }
47 | }
48 | }
49 |
50 | public void activate() {
51 | if (log != null)
52 | log.activate();
53 | }
54 | public void deactivate() {
55 | if (log != null)
56 | log.deactivate();
57 | }
58 | public boolean isActive() {
59 | return (log != null) ? log.isActive() : false;
60 | }
61 | }
62 | /*
63 | * $Log: not supported by cvs2svn $
64 | *
65 | * Old changelog:
66 | * 01-10-01 ticp@logica.com message passed to write methods can be null now
67 | * 09-10-01 ticp@logica.com when logging exception with extra text message
68 | * message is written on separate line now
69 | */
70 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/debug/LoggerDebug.java:
--------------------------------------------------------------------------------
1 | package org.smpp.debug;
2 |
3 | import java.util.logging.Level;
4 | import java.util.logging.Logger;
5 |
6 | /**
7 | * Implementation of Debug interface which uses log4j
8 | * logger
9 | *
10 | * @see Debug
11 | * @see org.smpp.SmppObject
12 | *
13 | * @author Sverker Abrahamsson, LimeTransit AB
14 | * @version $Revision: 1.1 $
15 | */
16 |
17 | public class LoggerDebug implements Debug {
18 | private Logger logger;
19 | private boolean active = false;
20 | private int indent = 0;
21 |
22 | public LoggerDebug(String category) {
23 | // get logger instance
24 | logger = Logger.getLogger(category);
25 | }
26 |
27 | public LoggerDebug(Logger logger) {
28 | this.logger = logger;
29 | }
30 |
31 | public void enter(int group, Object from, String name) {
32 | enter(from, name);
33 | }
34 |
35 | public void enter(Object from, String name) {
36 | if (active && logger.isLoggable(Level.FINE)) {
37 | logger.fine(getDelimiter(true, from, name));
38 | indent++;
39 | }
40 | }
41 |
42 | public void write(int group, String msg) {
43 | write(msg);
44 | }
45 |
46 | public void write(String msg) {
47 | if (active && logger.isLoggable(Level.FINE)) {
48 | logger.fine(getIndent() + " " + msg);
49 | }
50 | }
51 |
52 | public void exit(int group, Object from) {
53 | exit(from);
54 | }
55 |
56 | public void exit(Object from) {
57 | if (active) {
58 | indent--;
59 | if (indent < 0) {
60 | // it's your fault :-)
61 | indent = 0;
62 | }
63 | logger.fine(getDelimiter(false, from, ""));
64 | }
65 | }
66 |
67 | public void activate() {
68 | active = true;
69 | }
70 | public void activate(int group) {
71 | }
72 | public void deactivate() {
73 | active = false;
74 | }
75 | public void deactivate(int group) {
76 | }
77 |
78 | public boolean active(int group) {
79 | return true;
80 | }
81 |
82 | private String getDelimiter(boolean start, Object from, String name) {
83 | String indentStr = getIndent();
84 | if (start) {
85 | indentStr += "-> ";
86 | } else {
87 | indentStr += "<- ";
88 | }
89 | return indentStr + from.toString() + (name == "" ? "" : " " + name);
90 | }
91 |
92 | private String getIndent() {
93 | String result = new String("");
94 | for (int i = 0; i < indent; i++) {
95 | result += " ";
96 | }
97 | return result;
98 | }
99 | }
100 | /*
101 | * $Log: not supported by cvs2svn $
102 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/AddressRange.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class AddressRange extends ByteData {
21 | private byte ton = Data.getDefaultTon();
22 | private byte npi = Data.getDefaultNpi();
23 | private String addressRange = Data.DFLT_ADDR_RANGE;
24 |
25 | public AddressRange() {
26 | super();
27 | setTon(Data.getDefaultTon());
28 | setNpi(Data.getDefaultNpi());
29 | }
30 |
31 | public AddressRange(String addressRange) throws WrongLengthOfStringException {
32 | super();
33 | setTon(Data.getDefaultTon());
34 | setNpi(Data.getDefaultNpi());
35 | setAddressRange(addressRange);
36 | }
37 |
38 | public AddressRange(byte ton, byte npi, String addressRange) throws WrongLengthOfStringException {
39 | setTon(ton);
40 | setNpi(npi);
41 | setAddressRange(addressRange);
42 | }
43 |
44 | public void setData(ByteBuffer buffer)
45 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException {
46 | byte ton = buffer.removeByte();
47 | byte npi = buffer.removeByte();
48 | String addressRange = buffer.removeCString();
49 | setAddressRange(addressRange);
50 | setTon(ton);
51 | setNpi(npi);
52 | }
53 |
54 | public ByteBuffer getData() {
55 | ByteBuffer addressBuf = new ByteBuffer();
56 | addressBuf.appendByte(getTon());
57 | addressBuf.appendByte(getNpi());
58 | addressBuf.appendCString(getAddressRange());
59 | return addressBuf;
60 | }
61 |
62 | public void setTon(byte t) {
63 | ton = t;
64 | }
65 | public void setNpi(byte n) {
66 | npi = n;
67 | }
68 | public void setAddressRange(String a) throws WrongLengthOfStringException {
69 | checkCString(a, Data.SM_ADDR_RANGE_LEN);
70 | addressRange = a;
71 | }
72 |
73 | public byte getTon() {
74 | return ton;
75 | }
76 | public byte getNpi() {
77 | return npi;
78 | }
79 | public String getAddressRange() {
80 | return addressRange;
81 | }
82 |
83 | public String debugString() {
84 | String dbgs = "(addrrang: ";
85 | dbgs += super.debugString();
86 | dbgs += Integer.toString(getTon());
87 | dbgs += " ";
88 | dbgs += Integer.toString(getNpi());
89 | dbgs += " ";
90 | dbgs += getAddressRange();
91 | dbgs += ") ";
92 | return dbgs;
93 | }
94 | }
95 | /*
96 | * $Log: not supported by cvs2svn $
97 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/AlertNotification.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class AlertNotification extends Request {
21 | public AlertNotification() {
22 | super(Data.ALERT_NOTIFICATION);
23 | }
24 |
25 | protected Response createResponse() {
26 | return null;
27 | }
28 |
29 | public boolean canResponse() {
30 | return false;
31 | }
32 |
33 | public void setBody(ByteBuffer buffer)
34 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
35 | }
36 |
37 | public ByteBuffer getBody() {
38 | return null;
39 | }
40 |
41 | public String debugString() {
42 | String dbgs = "(alertnotification: ";
43 | dbgs += super.debugString();
44 | dbgs += ") ";
45 | return dbgs;
46 | }
47 | }
48 | /*
49 | * $Log: not supported by cvs2svn $
50 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 |
20 | public class BindReceiver extends BindRequest {
21 | public BindReceiver() {
22 | super(Data.BIND_RECEIVER);
23 | }
24 |
25 | protected Response createResponse() {
26 | return new BindReceiverResp();
27 | }
28 |
29 | public boolean isTransmitter() {
30 | return false;
31 | }
32 |
33 | public boolean isReceiver() {
34 | return true;
35 | }
36 | }
37 | /*
38 | * $Log: not supported by cvs2svn $
39 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindReceiverResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 |
20 | public class BindReceiverResp extends BindResponse {
21 | public BindReceiverResp() {
22 | super(Data.BIND_RECEIVER_RESP);
23 | }
24 | }
25 | /*
26 | * $Log: not supported by cvs2svn $
27 | */
28 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public abstract class BindRequest extends Request {
21 | private String systemId = Data.DFLT_SYSID;
22 | private String password = Data.DFLT_PASS;
23 | private String systemType = Data.DFLT_SYSTYPE;
24 | private AddressRange addressRange = new AddressRange();
25 | private byte interfaceVersion = Data.SMPP_V34;
26 |
27 | public abstract boolean isTransmitter();
28 | public abstract boolean isReceiver();
29 |
30 | public BindRequest(int commandId) {
31 | super(commandId);
32 | }
33 |
34 | public void setBody(ByteBuffer buffer)
35 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
36 | setSystemId(buffer.removeCString());
37 | setPassword(buffer.removeCString());
38 | setSystemType(buffer.removeCString());
39 | setInterfaceVersion(buffer.removeByte());
40 | addressRange.setData(buffer);
41 | }
42 |
43 | public ByteBuffer getBody() {
44 | ByteBuffer buffer = new ByteBuffer();
45 | buffer.appendCString(getSystemId());
46 | buffer.appendCString(getPassword());
47 | buffer.appendCString(getSystemType());
48 | buffer.appendByte(getInterfaceVersion());
49 | buffer.appendBuffer(getAddressRange().getData());
50 | return buffer;
51 | }
52 |
53 | public void setSystemId(String sysId) throws WrongLengthOfStringException {
54 | checkString(sysId, Data.SM_SYSID_LEN);
55 | systemId = sysId;
56 | }
57 |
58 | public void setPassword(String pwd) throws WrongLengthOfStringException {
59 | checkString(pwd, Data.SM_PASS_LEN);
60 | password = pwd;
61 | }
62 |
63 | public void setSystemType(String type) throws WrongLengthOfStringException {
64 | checkString(type, Data.SM_SYSTYPE_LEN);
65 | systemType = type;
66 | }
67 |
68 | public void setInterfaceVersion(byte vers) {
69 | interfaceVersion = vers;
70 | }
71 | public void setAddressRange(AddressRange adr) {
72 | addressRange = adr;
73 | }
74 | public void setAddressRange(String rangeString) throws WrongLengthOfStringException {
75 | setAddressRange(new AddressRange(rangeString));
76 | }
77 | public void setAddressRange(byte ton, byte npi, String rangeString) throws WrongLengthOfStringException {
78 | setAddressRange(new AddressRange(ton, npi, rangeString));
79 | }
80 |
81 | public String getSystemId() {
82 | return systemId;
83 | }
84 | public String getPassword() {
85 | return password;
86 | }
87 | public String getSystemType() {
88 | return systemType;
89 | }
90 | public byte getInterfaceVersion() {
91 | return interfaceVersion;
92 | }
93 | public AddressRange getAddressRange() {
94 | return addressRange;
95 | }
96 |
97 | public String debugString() {
98 | String dbgs = "(bindreq: ";
99 | dbgs += super.debugString();
100 | dbgs += getSystemId();
101 | dbgs += " ";
102 | dbgs += getPassword();
103 | dbgs += " ";
104 | dbgs += getSystemType();
105 | dbgs += " ";
106 | dbgs += Integer.toString(getInterfaceVersion());
107 | dbgs += " ";
108 | dbgs += getAddressRange().debugString();
109 | dbgs += ") ";
110 | return dbgs;
111 | }
112 | }
113 | /*
114 | * $Log: not supported by cvs2svn $
115 | */
116 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.pdu.tlv.*;
15 | import org.smpp.util.*;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.2 $
20 | */
21 | public abstract class BindResponse extends Response {
22 |
23 | // mandatory parameters
24 | private String systemId = Data.DFLT_SYSID;
25 |
26 | // optional parameters
27 | private TLVByte scInterfaceVersion = new TLVByte(Data.OPT_PAR_SC_IF_VER);
28 |
29 | public BindResponse(int commandId) {
30 | super(commandId);
31 |
32 | registerOptional(scInterfaceVersion);
33 | }
34 |
35 | public void setBody(ByteBuffer buffer)
36 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
37 | if (getCommandStatus() == 0) { // ok => have body
38 | setSystemId(buffer.removeCString());
39 | }
40 | }
41 |
42 | public ByteBuffer getBody() {
43 | ByteBuffer buffer = new ByteBuffer();
44 | //if (getCommandStatus() == 0) { // ok => append body
45 | buffer.appendCString(getSystemId());
46 | //}
47 | return buffer;
48 | }
49 |
50 | public void setSystemId(String sysId) throws WrongLengthOfStringException {
51 | checkString(sysId, Data.SM_SYSID_LEN);
52 | systemId = sysId;
53 | }
54 |
55 | public String getSystemId() {
56 | return systemId;
57 | }
58 |
59 | public boolean hasScInterfaceVersion() {
60 | return scInterfaceVersion.hasValue();
61 | }
62 |
63 | public void setScInterfaceVersion(byte value) {
64 | scInterfaceVersion.setValue(value);
65 | }
66 |
67 | public byte getScInterfaceVersion() throws ValueNotSetException {
68 | return scInterfaceVersion.getValue();
69 | }
70 |
71 | public String debugString() {
72 | String dbgs = "(bindresp: ";
73 | dbgs += super.debugString();
74 | dbgs += getSystemId();
75 | if (hasScInterfaceVersion()) {
76 | dbgs += " ";
77 | try {
78 | dbgs += getScInterfaceVersion();
79 | } catch (Exception e) {
80 | // don't want to throw exception in debug code!
81 | }
82 | }
83 | dbgs += ") ";
84 | return dbgs;
85 | }
86 | }
87 | /*
88 | * $Log: not supported by cvs2svn $
89 | * Revision 1.1 2003/07/23 00:28:39 sverkera
90 | * Imported
91 | *
92 | *
93 | * Old changelog:
94 | * 09-10-01 ticp@logica.com ID changed to Id in getSystemID and setSystemID
95 | */
96 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindTransciever.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class BindTransciever extends BindRequest {
20 | public BindTransciever() {
21 | super(Data.BIND_TRANSCEIVER);
22 | }
23 |
24 | protected Response createResponse() {
25 | return new BindTranscieverResp();
26 | }
27 |
28 | public boolean isTransmitter() {
29 | return true;
30 | }
31 |
32 | public boolean isReceiver() {
33 | return true;
34 | }
35 | }
36 | /*
37 | * $Log: not supported by cvs2svn $
38 | */
39 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindTranscieverResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class BindTranscieverResp extends BindResponse {
20 | public BindTranscieverResp() {
21 | super(Data.BIND_TRANSCEIVER_RESP);
22 | }
23 | }
24 | /*
25 | * $Log: not supported by cvs2svn $
26 | */
27 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindTransmitter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class BindTransmitter extends BindRequest {
20 | public BindTransmitter() {
21 | super(Data.BIND_TRANSMITTER);
22 | }
23 |
24 | protected Response createResponse() {
25 | return new BindTransmitterResp();
26 | }
27 |
28 | public boolean isTransmitter() {
29 | return true;
30 | }
31 |
32 | public boolean isReceiver() {
33 | return false;
34 | }
35 | }
36 | /*
37 | * $Log: not supported by cvs2svn $
38 | */
39 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/BindTransmitterResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class BindTransmitterResp extends BindResponse {
20 | public BindTransmitterResp() {
21 | super(Data.BIND_TRANSMITTER_RESP);
22 | }
23 | }
24 | /*
25 | * $Log: not supported by cvs2svn $
26 | */
27 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/ByteDataList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import java.util.Vector;
14 |
15 | import org.smpp.util.*;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.1 $
20 | */
21 | public abstract class ByteDataList extends ByteData {
22 |
23 | public final static byte BYTE_SIZE = 1;
24 | public final static byte SHORT_SIZE = 2;
25 | public final static byte INT_SIZE = 4;
26 |
27 | public abstract ByteData createValue();
28 |
29 | private Vectorsuper(THE_COMMAND_ID)
33 | * where the THE_COMMAND_ID is the command id of the
34 | * PDU the derived class represents.
35 | */
36 | public Request(int commandId) {
37 | super(commandId);
38 | }
39 |
40 | /**
41 | * This method is used to create generate a response corresponding to
42 | * this request. It creates the response using createResponse
43 | * and then sets the sequence number of the response to the sequence
44 | * number of this request. This way is ensured automatic matching
45 | * of the response to the request.
46 | * The created response is set this as the original request.
47 | * @see #createResponse()
48 | * @see Response#setOriginalRequest(Request)
49 | */
50 | public Response getResponse() {
51 | Response response = createResponse();
52 | response.setSequenceNumber(getSequenceNumber());
53 | response.setOriginalRequest(this);
54 | return response;
55 | }
56 |
57 | /**
58 | * Returns the command id of the corresponing response.
59 | */
60 | public int getResponseCommandId() {
61 | Response response = createResponse();
62 | return response.getCommandId();
63 | }
64 |
65 | /**
66 | * Returns true. If the derived class cannot respond, then it must
67 | * overwrite this function to return false.
68 | * @see PDU#canResponse()
69 | */
70 | public boolean canResponse() {
71 | return true;
72 | }
73 |
74 | /**
75 | * Returns true.
76 | * @see PDU#isRequest()
77 | */
78 | public boolean isRequest() {
79 | return true;
80 | }
81 |
82 | /** Returns false.
83 | * @see PDU#isResponse()
84 | */
85 | public boolean isResponse() {
86 | return false;
87 | }
88 | }
89 | /*
90 | * $Log: not supported by cvs2svn $
91 | *
92 | * Old changelog:
93 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces
94 | * 09-10-01 ticp@logica.com added registration of the request as original request
95 | * to the response created by getResponse
96 | */
97 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/Response.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.pdu.PDU;
14 |
15 | /**
16 | * Represents a PDU response. All classes which are used as SMPP response are
17 | * derived from this class.
18 | *
19 | * @author Logica Mobile Networks SMPP Open Source Team
20 | * @version $Revision: 1.1 $
21 | */
22 | public abstract class Response extends PDU {
23 | /**
24 | * The original request which this response relates to.
25 | * @see Request#getResponse()
26 | */
27 | private Request originalRequest = null;
28 |
29 | /** Create a request PDU with default parameters. */
30 | public Response() {
31 | }
32 |
33 | /**
34 | * Create response PDU with given command id.
35 | * Derived classes usually uses super(THE_COMMAND_ID)
36 | * where the THE_COMMAND_ID is the command id of the
37 | * PDU the derived class represents.
38 | */
39 | public Response(int commandId) {
40 | super(commandId);
41 | }
42 |
43 | /**
44 | * Returns false as there can be no response to a response.
45 | * @see PDU#canResponse()
46 | */
47 | public boolean canResponse() {
48 | return false;
49 | }
50 |
51 | /**
52 | * Returns false.
53 | * @see PDU#isRequest()
54 | */
55 | public boolean isRequest() {
56 | return false;
57 | }
58 |
59 | /**
60 | * Returns true.
61 | * @see PDU#isResponse()
62 | */
63 | public boolean isResponse() {
64 | return true;
65 | }
66 |
67 | /**
68 | * Sets the original Request which this Response
69 | * was created from.
70 | * @see Request#getResponse()
71 | */
72 | public void setOriginalRequest(Request originalRequest) {
73 | this.originalRequest = originalRequest;
74 | }
75 |
76 | /**
77 | * Returns the original Request which this Response
78 | * was created from.
79 | * @see Request#getResponse()
80 | */
81 | public Request getOriginalRequest() {
82 | return originalRequest;
83 | }
84 |
85 | }
86 | /*
87 | * $Log: not supported by cvs2svn $
88 | *
89 | * Old changelog:
90 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces
91 | * 09-10-01 ticp@logica.com added registration of original request if the response
92 | * was created from Request by getResponse
93 | */
94 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/SubmitMultiSMResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class SubmitMultiSMResp extends Response {
21 | private String messageId = Data.DFLT_MSGID;
22 | private UnsuccessSMEsList unsuccessSMEs = new UnsuccessSMEsList();
23 |
24 | public SubmitMultiSMResp() {
25 | super(Data.SUBMIT_MULTI_RESP);
26 | }
27 |
28 | public void setBody(ByteBuffer buffer)
29 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
30 | setMessageId(buffer.removeCString());
31 | unsuccessSMEs.setData(buffer);
32 | }
33 |
34 | public ByteBuffer getBody() throws ValueNotSetException {
35 | ByteBuffer buffer = new ByteBuffer();
36 | buffer.appendCString(messageId);
37 | buffer.appendBuffer(unsuccessSMEs.getData());
38 | return buffer;
39 | }
40 |
41 | public void setMessageId(String value) throws WrongLengthOfStringException {
42 | checkString(value, Data.SM_MSGID_LEN);
43 | messageId = value;
44 | }
45 |
46 | public void addUnsuccessSME(UnsuccessSME unsuccessSME) throws TooManyValuesException {
47 | unsuccessSMEs.addValue(unsuccessSME);
48 | }
49 |
50 | public String getMessageId() {
51 | return messageId;
52 | }
53 | public short getNoUnsuccess() {
54 | return (short) unsuccessSMEs.getCount();
55 | }
56 | public UnsuccessSME getUnsuccessSME(int i) {
57 | return (UnsuccessSME) unsuccessSMEs.getValue(i);
58 | }
59 |
60 | public String debugString() {
61 | String dbgs = "(submitmulti_resp: ";
62 | dbgs += super.debugString();
63 | dbgs += getMessageId();
64 | dbgs += " ";
65 | dbgs += unsuccessSMEs.debugString();
66 | dbgs += " ";
67 | dbgs += debugStringOptional();
68 | dbgs += ") ";
69 | return dbgs;
70 | }
71 |
72 | private class UnsuccessSMEsList extends ByteDataList {
73 | public UnsuccessSMEsList() {
74 | super(Data.SM_MAX_CNT_DEST_ADDR, 1);
75 | }
76 |
77 | public ByteData createValue() {
78 | return new UnsuccessSME();
79 | }
80 |
81 | public String debugString() {
82 | return "(unsuccess_addr_list: " + super.debugString() + ")";
83 | }
84 | }
85 | }
86 | /*
87 | * $Log: not supported by cvs2svn $
88 | *
89 | * Old changelog:
90 | * 01-11-01 ticp@logica.com number of unsuccessfull destination addresses now
91 | * stored correctly (octet > 127 problem) as ByteDataList
92 | * was fixed
93 | */
94 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/SubmitSMResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.pdu.Response;
15 | import org.smpp.util.*;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Id: SubmitSMResp.java 72 2008-07-15 19:43:00Z sverkera $
20 | */
21 | public class SubmitSMResp extends Response {
22 |
23 | private String messageId = Data.DFLT_MSGID;
24 |
25 | public SubmitSMResp() {
26 | super(Data.SUBMIT_SM_RESP);
27 | }
28 |
29 | public void setBody(ByteBuffer buffer)
30 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException, InvalidPDUException {
31 |
32 | if (getCommandStatus() == 0) {
33 | setMessageId(buffer.removeCString());
34 | return;
35 | }
36 |
37 | if (buffer.length() > 0) {
38 | // This is broken in so many implementations that it's not practical
39 | // to be so pedantic about it, so we now just accept it.
40 | // throw new InvalidPDUException(this,"command_status non-zero, but body was present");
41 | debug.enter(this,"setBody");
42 | debug.write("invalid SubmitSMResp: command_status non-zero, but body was present (ignoring body)");
43 | debug.exit(this);
44 | event.write("invalid SubmitSMResp sequenceNumber ["+getSequenceNumber()+"]: command_status non-zero, but body was present (ignoring body)");
45 | buffer.removeBytes(buffer.length()); // discard body
46 | }
47 | }
48 |
49 | public ByteBuffer getBody() {
50 | ByteBuffer buffer = new ByteBuffer();
51 | if (getCommandStatus() == 0) buffer.appendCString(messageId);
52 | return buffer;
53 | }
54 |
55 | public void setMessageId(String value) throws WrongLengthOfStringException {
56 | checkString(value, Data.SM_MSGID_LEN);
57 | messageId = value;
58 | }
59 |
60 | public String getMessageId() {
61 | return messageId;
62 | }
63 |
64 | public String debugString() {
65 | String dbgs = "(submit_resp: ";
66 | dbgs += super.debugString();
67 | dbgs += getMessageId();
68 | dbgs += " ";
69 | dbgs += debugStringOptional();
70 | dbgs += ") ";
71 | return dbgs;
72 | }
73 | }
74 | /*
75 | * $Log: not supported by cvs2svn $
76 | * Revision 1.2 2004/09/04 08:10:56 paoloc
77 | * Changes to enforce this statement from SMPP spec (v3.4 p. 67): "The submit_sm_resp PDU Body is not returned if the command_status field contains a non-zero value".
78 | *
79 | * Revision 1.1 2003/07/23 00:28:39 sverkera
80 | * Imported
81 | *
82 | */
83 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/TooManyValuesException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class TooManyValuesException extends PDUException {
20 | private static final long serialVersionUID = -2777016699062489252L;
21 |
22 | public TooManyValuesException() {
23 | setErrorCode(Data.ESME_RINVPARAM);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/Unbind.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class Unbind extends Request {
21 | public Unbind() {
22 | super(Data.UNBIND);
23 | }
24 |
25 | protected Response createResponse() {
26 | return new UnbindResp();
27 | }
28 |
29 | public void setBody(ByteBuffer buffer)
30 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
31 | }
32 |
33 | public ByteBuffer getBody() {
34 | return null;
35 | }
36 |
37 | public String debugString() {
38 | String dbgs = "(unbind: ";
39 | dbgs += super.debugString();
40 | dbgs += ") ";
41 | return dbgs;
42 | }
43 | }
44 | /*
45 | * $Log: not supported by cvs2svn $
46 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/UnbindResp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class UnbindResp extends Response {
21 | public UnbindResp() {
22 | super(Data.UNBIND_RESP);
23 | }
24 |
25 | public void setBody(ByteBuffer buffer)
26 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
27 | }
28 |
29 | public ByteBuffer getBody() {
30 | return null;
31 | }
32 |
33 | public String debugString() {
34 | String dbgs = "(unbind_resp: ";
35 | dbgs += super.debugString();
36 | dbgs += ") ";
37 | return dbgs;
38 | }
39 | }
40 | /*
41 | * $Log: not supported by cvs2svn $
42 | */
43 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/UnexpectedOptionalParameterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class UnexpectedOptionalParameterException extends PDUException {
20 | private static final long serialVersionUID = -1284359967986779783L;
21 | private int tag = 0;
22 |
23 | public UnexpectedOptionalParameterException() {
24 | super("The optional parameter wasn't expected for the PDU.");
25 | setErrorCode(Data.ESME_ROPTPARNOTALLWD);
26 | }
27 |
28 | public UnexpectedOptionalParameterException(short tag) {
29 | super("The optional parameter wasn't expected for the PDU:" + " tag=" + tag + ".");
30 | this.tag = tag;
31 | setErrorCode(Data.ESME_ROPTPARNOTALLWD);
32 | }
33 |
34 | public void setTag(int tag) {
35 | this.tag = tag;
36 | }
37 |
38 | public int getTag() {
39 | return tag;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/UnknownCommandIdException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | /**
14 | * @author Logica Mobile Networks SMPP Open Source Team
15 | * @version $Revision: 1.1 $
16 | */
17 | public class UnknownCommandIdException extends PDUException {
18 | /**
19 | *
20 | */
21 | private static final long serialVersionUID = -5091873576710864441L;
22 | private transient PDUHeader header = null;
23 |
24 | public UnknownCommandIdException() {
25 | }
26 |
27 | public UnknownCommandIdException(PDUHeader header) {
28 | this.header = header;
29 | }
30 |
31 | public int getCommandLength() {
32 | return header == null ? 0 : header.getCommandLength();
33 | }
34 |
35 | public int getCommandId() {
36 | return header == null ? 0 : header.getCommandId();
37 | }
38 |
39 | public int getCommandStatus() {
40 | return header == null ? 0 : header.getCommandStatus();
41 | }
42 |
43 | public int getSequenceNumber() {
44 | return header == null ? 0 : header.getSequenceNumber();
45 | }
46 | }
47 | /*
48 | * $Log: not supported by cvs2svn $
49 | *
50 | * Old changelog:
51 | * 10-10-01 ticp@logica.com pdu header carried by the exception made transient
52 | * (it is not serializable)
53 | */
54 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/UnsuccessSME.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 | import org.smpp.util.*;
15 |
16 | /**
17 | * @author Logica Mobile Networks SMPP Open Source Team
18 | * @version $Revision: 1.1 $
19 | */
20 | public class UnsuccessSME extends Address {
21 | public int errorStatusCode = Data.ESME_ROK;
22 |
23 | public UnsuccessSME() {
24 | }
25 |
26 | public UnsuccessSME(String address, int err) throws WrongLengthOfStringException {
27 | super(address);
28 | setErrorStatusCode(err);
29 | }
30 |
31 | public UnsuccessSME(byte ton, byte npi, String address, int err) throws WrongLengthOfStringException {
32 | super(ton, npi, address);
33 | setErrorStatusCode(err);
34 | }
35 |
36 | public void setData(ByteBuffer buffer)
37 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException {
38 | super.setData(buffer);
39 | setErrorStatusCode(buffer.removeInt());
40 | }
41 |
42 | public ByteBuffer getData() {
43 | ByteBuffer buffer = super.getData();
44 | buffer.appendInt(getErrorStatusCode());
45 | return buffer;
46 | }
47 |
48 | public void setErrorStatusCode(int sc) {
49 | errorStatusCode = sc;
50 | }
51 | public int getErrorStatusCode() {
52 | return errorStatusCode;
53 | }
54 |
55 | public String debugString() {
56 | String dbgs = "(unsucsme: ";
57 | dbgs += super.debugString();
58 | dbgs += Integer.toString(getErrorStatusCode());
59 | dbgs += ") ";
60 | return dbgs;
61 | }
62 | }
63 | /*
64 | * $Log: not supported by cvs2svn $
65 | */
66 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/ValueNotSetException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * optional's parameter's value was requested but the optional parameter
17 | * wasn't present in the PDU
18 | *
19 | * @author Logica Mobile Networks SMPP Open Source Team
20 | * @version $Revision: 1.1 $
21 | */
22 | public class ValueNotSetException extends PDUException {
23 | private static final long serialVersionUID = -4595064103809398438L;
24 |
25 | public ValueNotSetException() {
26 | setErrorCode(Data.ESME_RMISSINGOPTPARAM);
27 | }
28 | }
29 | /*
30 | * $Log: not supported by cvs2svn $
31 | */
32 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/WrongDateFormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class WrongDateFormatException extends PDUException {
20 | private static final long serialVersionUID = 5831937612139037591L;
21 |
22 | public WrongDateFormatException() {
23 | super("Date must be either null or of format YYMMDDhhmmsstnnp");
24 | setErrorCode(Data.ESME_RINVPARAM);
25 | }
26 |
27 | public WrongDateFormatException(String dateStr) {
28 | super("Date must be either null or of format YYMMDDhhmmsstnnp and not " + dateStr + ".");
29 | setErrorCode(Data.ESME_RINVPARAM);
30 | }
31 |
32 | public WrongDateFormatException(String dateStr, String msg) {
33 | super("Invalid date " + dateStr + ": " + msg);
34 | setErrorCode(Data.ESME_RINVPARAM);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/WrongDestFlagException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class WrongDestFlagException extends PDUException {
20 | private static final long serialVersionUID = 6266749651012701472L;
21 |
22 | public WrongDestFlagException() {
23 | setErrorCode(Data.ESME_RINVPARAM);
24 | }
25 |
26 | public WrongDestFlagException(PDU pdu) {
27 | super(pdu);
28 | setErrorCode(Data.ESME_RINVPARAM);
29 | }
30 |
31 | public WrongDestFlagException(String s) {
32 | super(s);
33 | setErrorCode(Data.ESME_RINVPARAM);
34 | }
35 |
36 | public WrongDestFlagException(PDU pdu, String s) {
37 | super(pdu, s);
38 | setErrorCode(Data.ESME_RINVPARAM);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/WrongLengthOfStringException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu;
12 |
13 | import org.smpp.Data;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.1 $
18 | */
19 | public class WrongLengthOfStringException extends PDUException {
20 | private static final long serialVersionUID = 8604133584902790266L;
21 |
22 | public WrongLengthOfStringException() {
23 | super("The string is shorter or longer than required.");
24 | setErrorCode(Data.ESME_RINVPARAM);
25 | }
26 |
27 | public WrongLengthOfStringException(int min, int max, int actual) {
28 | super(
29 | "The string is shorter or longer than required: "
30 | + " min="
31 | + min
32 | + " max="
33 | + max
34 | + " actual="
35 | + actual
36 | + ".");
37 | setErrorCode(Data.ESME_RINVPARAM);
38 | }
39 | }
40 | /*
41 | * $Log: not supported by cvs2svn $
42 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVByte.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.ValueNotSetException;
14 | import org.smpp.util.ByteBuffer;
15 | import org.smpp.util.NotEnoughDataInByteBufferException;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.1 $
20 | */
21 | public class TLVByte extends TLV {
22 | private byte value = 0;
23 |
24 | public TLVByte() {
25 | super(1, 1);
26 | }
27 |
28 | public TLVByte(short p_tag) {
29 | super(p_tag, 1, 1);
30 | }
31 |
32 | public TLVByte(short p_tag, byte p_value) {
33 | super(p_tag, 1, 1);
34 | value = p_value;
35 | markValueSet();
36 | }
37 |
38 | protected void setValueData(ByteBuffer buffer) throws TLVException {
39 | checkLength(buffer);
40 | try {
41 | value = buffer.removeByte();
42 | } catch (NotEnoughDataInByteBufferException e) {
43 | // can't happen as the size is already checked by checkLength()
44 | }
45 | markValueSet();
46 | }
47 |
48 | protected ByteBuffer getValueData() throws ValueNotSetException {
49 | ByteBuffer valueBuf = new ByteBuffer();
50 | valueBuf.appendByte(getValue());
51 | return valueBuf;
52 | }
53 |
54 | public void setValue(byte p_value) {
55 | value = p_value;
56 | markValueSet();
57 | }
58 |
59 | public byte getValue() throws ValueNotSetException {
60 | if (hasValue()) {
61 | return value;
62 | } else {
63 | throw new ValueNotSetException();
64 | }
65 | }
66 |
67 | public String debugString() {
68 | String dbgs = "(byte: ";
69 | dbgs += super.debugString();
70 | dbgs += value;
71 | dbgs += ") ";
72 | return dbgs;
73 | }
74 | }
75 | /*
76 | * $Log: not supported by cvs2svn $
77 | */
78 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVEmpty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.ValueNotSetException;
14 | import org.smpp.pdu.tlv.WrongLengthException;
15 | import org.smpp.util.ByteBuffer;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.1 $
20 | */
21 | public class TLVEmpty extends TLV {
22 | private boolean present = false;
23 |
24 | public TLVEmpty() {
25 | super(0, 0);
26 | }
27 |
28 | public TLVEmpty(short p_tag) {
29 | super(p_tag, 0, 0);
30 | }
31 |
32 | public TLVEmpty(short p_tag, boolean p_present) {
33 | super(p_tag, 0, 0);
34 | present = p_present;
35 | markValueSet();
36 | }
37 |
38 | public ByteBuffer getValueData() {
39 | // nothing, just present or not
40 | return null;
41 | }
42 |
43 | public void setValueData(ByteBuffer buffer) throws WrongLengthException {
44 | // nothing, just set presence
45 | checkLength(buffer);
46 | setValue(true);
47 | }
48 |
49 | public void setValue(boolean p_present) {
50 | present = p_present;
51 | markValueSet();
52 | }
53 |
54 | public boolean getValue() throws ValueNotSetException {
55 | if (hasValue()) {
56 | return present;
57 | } else {
58 | throw new ValueNotSetException();
59 | }
60 | }
61 |
62 | public String debugString() {
63 | String dbgs = "(empty: ";
64 | dbgs += super.debugString();
65 | dbgs += ") ";
66 | return dbgs;
67 | }
68 | }
69 | /*
70 | * $Log: not supported by cvs2svn $
71 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.PDUException;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.2 $
18 | */
19 | public class TLVException extends PDUException {
20 | private static final long serialVersionUID = -6659626685298184198L;
21 |
22 | public TLVException() {
23 | super();
24 | }
25 |
26 | public TLVException(String s) {
27 | super(s);
28 | }
29 | }
30 | /*
31 | * $Log: not supported by cvs2svn $
32 | * Revision 1.1 2003/07/23 00:28:39 sverkera
33 | * Imported
34 | *
35 | */
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVInt.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.ValueNotSetException;
14 | import org.smpp.util.ByteBuffer;
15 | import org.smpp.util.NotEnoughDataInByteBufferException;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.1 $
20 | */
21 | public class TLVInt extends TLV {
22 | private int value = 0;
23 |
24 | public TLVInt() {
25 | super(4, 4);
26 | }
27 |
28 | public TLVInt(short p_tag) {
29 | super(p_tag, 4, 4);
30 | }
31 |
32 | public TLVInt(short p_tag, int p_value) {
33 | super(p_tag, 4, 4);
34 | value = p_value;
35 | markValueSet();
36 | }
37 |
38 | protected void setValueData(ByteBuffer buffer) throws TLVException {
39 | checkLength(buffer);
40 | try {
41 | value = buffer.removeInt();
42 | } catch (NotEnoughDataInByteBufferException e) {
43 | // can't happen as the size is already checked by checkLength()
44 | }
45 | markValueSet();
46 | }
47 |
48 | protected ByteBuffer getValueData() throws ValueNotSetException {
49 | ByteBuffer valueBuf = new ByteBuffer();
50 | valueBuf.appendInt(getValue());
51 | return valueBuf;
52 | }
53 |
54 | public void setValue(int p_value) {
55 | value = p_value;
56 | markValueSet();
57 | }
58 |
59 | public int getValue() throws ValueNotSetException {
60 | if (hasValue()) {
61 | return value;
62 | } else {
63 | throw new ValueNotSetException();
64 | }
65 | }
66 |
67 | public String debugString() {
68 | String dbgs = "(int: ";
69 | dbgs += super.debugString();
70 | dbgs += value;
71 | dbgs += ") ";
72 | return dbgs;
73 | }
74 | }
75 | /*
76 | * $Log: not supported by cvs2svn $
77 | */
78 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVOctets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import java.lang.Error;
14 |
15 | import org.smpp.pdu.ValueNotSetException;
16 | import org.smpp.util.ByteBuffer;
17 | import org.smpp.util.NotEnoughDataInByteBufferException;
18 |
19 | /**
20 | * @author Logica Mobile Networks SMPP Open Source Team
21 | * @version $Revision: 1.1 $
22 | */
23 | public class TLVOctets extends TLV {
24 | private ByteBuffer value = null;
25 |
26 | public TLVOctets() {
27 | super();
28 | }
29 |
30 | public TLVOctets(short p_tag) {
31 | super(p_tag);
32 | }
33 |
34 | public TLVOctets(short p_tag, int min, int max) {
35 | super(p_tag, min, max);
36 | }
37 |
38 | public TLVOctets(short p_tag, ByteBuffer p_value) throws TLVException {
39 | super(p_tag);
40 | setValueData(p_value);
41 | }
42 |
43 | public TLVOctets(short p_tag, int min, int max, ByteBuffer p_value) throws TLVException {
44 | super(p_tag, min, max);
45 | setValueData(p_value);
46 | }
47 |
48 | protected void setValueData(ByteBuffer buffer) throws TLVException {
49 | checkLength(buffer);
50 | if (buffer != null) {
51 | try {
52 | value = buffer.removeBuffer(buffer.length());
53 | } catch (NotEnoughDataInByteBufferException e) {
54 | throw new Error(
55 | "Removing buf.length() data from ByteBuffer buf "
56 | + "reported too little data in buf, which shouldn't happen.");
57 | }
58 | } else {
59 | value = null;
60 | }
61 | markValueSet();
62 | }
63 |
64 | protected ByteBuffer getValueData() throws ValueNotSetException {
65 | ByteBuffer valueBuf = new ByteBuffer();
66 | valueBuf.appendBuffer(getValue());
67 | return valueBuf;
68 | }
69 |
70 | public void setValue(ByteBuffer p_value) {
71 | if (p_value != null) {
72 | try {
73 | value = p_value.removeBuffer(p_value.length());
74 | } catch (NotEnoughDataInByteBufferException e) {
75 | throw new Error(
76 | "Removing buf.length() data from ByteBuffer buf "
77 | + "reported too little data in buf, which shouldn't happen.");
78 | }
79 | } else {
80 | value = null;
81 | }
82 | markValueSet();
83 | }
84 |
85 | public ByteBuffer getValue() throws ValueNotSetException {
86 | if (hasValue()) {
87 | return value;
88 | } else {
89 | throw new ValueNotSetException();
90 | }
91 | }
92 |
93 | public String debugString() {
94 | String dbgs = "(oct: ";
95 | dbgs += super.debugString();
96 | dbgs += value == null ? "" : value.getHexDump();
97 | dbgs += ") ";
98 | return dbgs;
99 | }
100 |
101 | }
102 | /*
103 | * $Log: not supported by cvs2svn $
104 | *
105 | * Old changelog:
106 | * 26-09-01 ticp@logica.com debugString() now prints hex dump of the buffer data
107 | * instead of the object reference of it
108 | */
109 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVShort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.ValueNotSetException;
14 | import org.smpp.util.ByteBuffer;
15 | import org.smpp.util.NotEnoughDataInByteBufferException;
16 |
17 | /**
18 | * @author Logica Mobile Networks SMPP Open Source Team
19 | * @version $Revision: 1.1 $
20 | */
21 | public class TLVShort extends TLV {
22 | private short value = 0;
23 |
24 | public TLVShort() {
25 | super(2, 2);
26 | }
27 |
28 | public TLVShort(short p_tag) {
29 | super(p_tag, 2, 2);
30 | }
31 |
32 | public TLVShort(short p_tag, short p_value) {
33 | super(p_tag, 2, 2);
34 | value = p_value;
35 | markValueSet();
36 | }
37 |
38 | protected void setValueData(ByteBuffer buffer) throws TLVException {
39 | checkLength(buffer);
40 | try {
41 | value = buffer.removeShort();
42 | } catch (NotEnoughDataInByteBufferException e) {
43 | // can't happen as the size is already checked by checkLength()
44 | }
45 | markValueSet();
46 | }
47 |
48 | protected ByteBuffer getValueData() throws ValueNotSetException {
49 | ByteBuffer valueBuf = new ByteBuffer();
50 | valueBuf.appendShort(getValue());
51 | return valueBuf;
52 | }
53 |
54 | public void setValue(short p_value) {
55 | value = p_value;
56 | markValueSet();
57 | }
58 |
59 | public short getValue() throws ValueNotSetException {
60 | if (hasValue()) {
61 | return value;
62 | } else {
63 | throw new ValueNotSetException();
64 | }
65 | }
66 |
67 | public String debugString() {
68 | String dbgs = "(short: ";
69 | dbgs += super.debugString();
70 | dbgs += value;
71 | dbgs += ") ";
72 | return dbgs;
73 | }
74 | }
75 | /*
76 | * $Log: not supported by cvs2svn $
77 | */
78 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.ValueNotSetException;
14 | import org.smpp.util.ByteBuffer;
15 | import org.smpp.util.NotEnoughDataInByteBufferException;
16 | import org.smpp.util.TerminatingZeroNotFoundException;
17 |
18 | /**
19 | * @author Logica Mobile Networks SMPP Open Source Team
20 | * @version $Revision: 1.1 $
21 | */
22 | public class TLVString extends TLV {
23 | private String value;
24 |
25 | public TLVString() {
26 | super();
27 | }
28 |
29 | public TLVString(short tag) {
30 | super(tag);
31 | }
32 |
33 | public TLVString(short tag, int min, int max) {
34 | super(tag, min, max);
35 | }
36 |
37 | public TLVString(short tag, String value) throws TLVException {
38 | super(tag);
39 | setValue(value);
40 | }
41 |
42 | public TLVString(short tag, int min, int max, String value) throws TLVException {
43 | super(tag, min, max);
44 | setValue(value);
45 | }
46 |
47 | public void setValueData(ByteBuffer buffer) throws TLVException {
48 | checkLength(buffer);
49 | if (buffer != null) {
50 | try {
51 | value = buffer.removeCString();
52 | } catch (NotEnoughDataInByteBufferException e) {
53 | throw new TLVException("Not enough data for string in the buffer.");
54 | } catch (TerminatingZeroNotFoundException e) {
55 | throw new TLVException("String terminating zero not found in the buffer.");
56 | }
57 | } else {
58 | value = new String("");
59 | }
60 | markValueSet();
61 | }
62 |
63 | public ByteBuffer getValueData() throws ValueNotSetException {
64 | ByteBuffer valueBuf = new ByteBuffer();
65 | valueBuf.appendCString(getValue());
66 | return valueBuf;
67 | }
68 |
69 | public void setValue(String value) throws WrongLengthException {
70 | checkLength(value.length() + 1);
71 | this.value = value;
72 | markValueSet();
73 | }
74 |
75 | public String getValue() throws ValueNotSetException {
76 | if (hasValue()) {
77 | return value;
78 | } else {
79 | throw new ValueNotSetException();
80 | }
81 | }
82 |
83 | public String debugString() {
84 | String dbgs = "(str: ";
85 | dbgs += super.debugString();
86 | dbgs += value;
87 | dbgs += ") ";
88 | return dbgs;
89 | }
90 |
91 | }
92 | /*
93 | * $Log: not supported by cvs2svn $
94 | *
95 | * Old changelog:
96 | * 20-11-01 ticp@logica.com setValue() now sets flag that the value was set
97 | */
98 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/TLVUByte.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | import org.smpp.pdu.IntegerOutOfRangeException;
14 | import org.smpp.pdu.ValueNotSetException;
15 | import org.smpp.util.ByteBuffer;
16 | import org.smpp.util.NotEnoughDataInByteBufferException;
17 |
18 | /**
19 | * TLV carrying unsigned byte (octet).
20 | *
21 | * @author Logica Mobile Networks SMPP Open Source Team
22 | * @version $Revision: 1.1 $
23 | */
24 | public class TLVUByte extends TLV {
25 | /** The value of the TLV. Stored as short (two byte) as byte
26 | * can't carry full unsigned octet.
27 | */
28 | private short value = 0;
29 |
30 | /**
31 | * Initialises the TLV with default values.
32 | */
33 | public TLVUByte() {
34 | super(1, 1);
35 | }
36 |
37 | /**
38 | * Initialises the TLV with provided tag.
39 | * @param p_tag the tag of this TLV
40 | */
41 | public TLVUByte(short p_tag) {
42 | super(p_tag, 1, 1);
43 | }
44 |
45 | /**
46 | * Reads 1 octet from buffer and interprets it as unsigned byte.
47 | * @param buffer the buffer to read the unsigned byte from
48 | */
49 | protected void setValueData(ByteBuffer buffer) throws TLVException {
50 | checkLength(buffer);
51 | try {
52 | value = decodeUnsigned(buffer.removeByte());
53 | } catch (NotEnoughDataInByteBufferException e) {
54 | // can't happen as the size is already checked by checkLength()
55 | }
56 | markValueSet();
57 | }
58 |
59 | /**
60 | * Creates byt buffer containing one unsigned byte.
61 | * @return the byte buffer with one unsingned byte
62 | */
63 | protected ByteBuffer getValueData() throws ValueNotSetException {
64 | ByteBuffer valueBuf = new ByteBuffer();
65 | valueBuf.appendByte(encodeUnsigned(getValue()));
66 | return valueBuf;
67 | }
68 |
69 | /**
70 | * Sets the value of the TLV to the new value.
71 | * @param value the new value of the TLV
72 | */
73 | public void setValue(short value) throws IntegerOutOfRangeException {
74 | checkRange(0, value, 255);
75 | this.value = value;
76 | markValueSet();
77 | }
78 |
79 | /**
80 | * Returns the current value of the TLV
81 | * @return the curent value of the TLV
82 | * @throws ValueNotSetException if value hasn't been set
83 | */
84 | public short getValue() throws ValueNotSetException {
85 | if (hasValue()) {
86 | return value;
87 | } else {
88 | throw new ValueNotSetException();
89 | }
90 | }
91 |
92 | public String debugString() {
93 | String dbgs = "(byte: ";
94 | dbgs += super.debugString();
95 | dbgs += value;
96 | dbgs += ") ";
97 | return dbgs;
98 | }
99 | }
100 | /*
101 | * $Log: not supported by cvs2svn $
102 | */
103 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/pdu/tlv/WrongLengthException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.pdu.tlv;
12 |
13 | /**
14 | * @author Logica Mobile Networks SMPP Open Source Team
15 | * @version $Revision: 1.2 $
16 | */
17 | public class WrongLengthException extends TLVException {
18 | private static final long serialVersionUID = 7935018427341458286L;
19 |
20 | public WrongLengthException() {
21 | super("The TLV is shorter or longer than allowed.");
22 | }
23 |
24 | public WrongLengthException(int min, int max, int actual) {
25 | super(
26 | "The TLV is shorter or longer than allowed: " + " min=" + min + " max=" + max + " actual=" + actual + ".");
27 | }
28 | }
29 | /*
30 | * $Log: not supported by cvs2svn $
31 | * Revision 1.1 2003/07/23 00:28:39 sverkera
32 | * Imported
33 | *
34 | */
35 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/util/DataCodingCharsetHandler.java:
--------------------------------------------------------------------------------
1 | package org.smpp.util;
2 |
3 | import org.smpp.Data;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | /**
9 | * Handles charset handling based on data_coding parameter, see
10 | * SMPP 3.4 specification, paragraph 5.2.19
11 | */
12 | public class DataCodingCharsetHandler {
13 | private static final Mapdata_coding parameter.
23 | * If none is found it defaults to X-Gsm7Bit.
24 | *
25 | * @param dataCoding
26 | * @return encoding name
27 | */
28 | public static String getCharsetName(byte dataCoding) {
29 | return getCharsetName(dataCoding, Data.ENC_GSM7BIT);
30 | }
31 |
32 | /**
33 | * Return the correct charset given the data_coding parameter.
34 | *
35 | * @param dataCoding
36 | * @param defaultEncoding
37 | * @return encoding name
38 | */
39 | public static String getCharsetName(byte dataCoding, String defaultEncoding) {
40 | String encoding = DATA_CODING_CHARSET.get(dataCoding);
41 | return encoding != null ? encoding : defaultEncoding;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/util/DefaultServerPDUEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.util;
12 |
13 | import org.smpp.ServerPDUEvent;
14 | import org.smpp.ServerPDUEventListener;
15 | import org.smpp.SmppObject;
16 | import org.smpp.pdu.PDU;
17 |
18 | /**
19 | * Simple listener processing PDUs received from SMSC by the
20 | * Receiver in asynchronous mode.
21 | *
22 | * @author Logica Mobile Networks SMPP Open Source Team
23 | * @version $Revision: 1.1 $
24 | * @see ServerPDUEventListener
25 | */
26 | public class DefaultServerPDUEventListener extends SmppObject implements ServerPDUEventListener {
27 | /**
28 | * "Handles" the event generated for received PDUs -- just logs
29 | * the event and throws it away.
30 | */
31 | public void handleEvent(ServerPDUEvent event) {
32 | PDU pdu = event.getPDU();
33 | if (pdu != null) {
34 | if (pdu.isRequest()) {
35 | debug.write(DUTL, "receiver listener: handling request " + pdu.debugString());
36 | } else if (pdu.isResponse()) {
37 | debug.write(DUTL, "receiver listener: handling response " + pdu.debugString());
38 | } else {
39 | debug.write(DUTL, "receiver listener: handling strange pdu " + pdu.debugString());
40 | }
41 | }
42 | }
43 | }
44 | /*
45 | * $Log: not supported by cvs2svn $
46 | */
47 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/util/NotEnoughDataInByteBufferException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.util;
12 |
13 | import org.smpp.SmppException;
14 |
15 | /**
16 | * @author Logica Mobile Networks SMPP Open Source Team
17 | * @version $Revision: 1.2 $
18 | */
19 | public class NotEnoughDataInByteBufferException extends SmppException {
20 | private static final long serialVersionUID = -3720107899765064964L;
21 | private int available;
22 | private int expected;
23 |
24 | public NotEnoughDataInByteBufferException(int p_available, int p_expected) {
25 | super("Not enough data in byte buffer. " + "Expected " + p_expected + ", available: " + p_available + ".");
26 | available = p_available;
27 | expected = p_expected;
28 | }
29 |
30 | public NotEnoughDataInByteBufferException(String s) {
31 | super(s);
32 | available = 0;
33 | expected = 0;
34 | }
35 |
36 | public int getAvailable() {
37 | return available;
38 | }
39 |
40 | public int getExpected() {
41 | return expected;
42 | }
43 | }
44 | /*
45 | * $Log: not supported by cvs2svn $
46 | * Revision 1.1 2003/07/23 00:28:39 sverkera
47 | * Imported
48 | *
49 | */
50 |
--------------------------------------------------------------------------------
/core/src/main/java/org/smpp/util/Queue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1996-2001
3 | * Logica Mobile Networks Limited
4 | * All rights reserved.
5 | *
6 | * This software is distributed under Logica Open Source License Version 1.0
7 | * ("Licence Agreement"). You shall use it and distribute only in accordance
8 | * with the terms of the License Agreement.
9 | *
10 | */
11 | package org.smpp.util;
12 |
13 | import java.util.LinkedList;
14 | import java.util.ListIterator;
15 |
16 | import org.smpp.SmppObject;
17 |
18 | /**
19 | * Implements fifo style queue with removal of specified element from inside of
20 | * the queue.
21 | *
22 | * @author Logica Mobile Networks SMPP Open Source Team
23 | * @version $Revision: 1.1 $
24 | */
25 | public class Queue extends SmppObject {
26 | private int maxQueueSize = 0;
27 | private LinkedList