/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/message/QueryBroadcastSM.java

http://mobicents.googlecode.com/ · Java · 100 lines · 59 code · 15 blank · 26 comment · 3 complexity · fa327bfc99b56cadf4ac35c46826c9ea MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.smpp.message;
  23. import java.io.IOException;
  24. import org.mobicents.protocols.smpp.Address;
  25. import org.mobicents.protocols.smpp.util.PacketDecoder;
  26. import org.mobicents.protocols.smpp.util.PacketEncoder;
  27. /**
  28. * Query the status of a previously submitted broadcast message.
  29. * @version $Id: QueryBroadcastSM.java 457 2009-01-15 17:37:42Z orank $
  30. * @since 0.4.0
  31. */
  32. public class QueryBroadcastSM extends SMPPPacket {
  33. private static final long serialVersionUID = 2L;
  34. private String messageId;
  35. private Address source;
  36. public QueryBroadcastSM() {
  37. super (CommandId.QUERY_BROADCAST_SM);
  38. }
  39. public String getMessageId() {
  40. return messageId;
  41. }
  42. public void setMessageId(String messageId) {
  43. this.messageId = messageId;
  44. }
  45. public Address getSource() {
  46. return source;
  47. }
  48. public void setSource(Address source) {
  49. this.source = source;
  50. }
  51. @Override
  52. public boolean equals(Object obj) {
  53. boolean equals = super.equals(obj);
  54. if (equals) {
  55. QueryBroadcastSM other = (QueryBroadcastSM) obj;
  56. equals |= safeCompare(messageId, other.messageId);
  57. equals |= safeCompare(source, other.source);
  58. }
  59. return equals;
  60. }
  61. @Override
  62. public int hashCode() {
  63. int hc = super.hashCode();
  64. hc += (messageId != null) ? messageId.hashCode() : 0;
  65. hc += (source != null) ? source.hashCode() : 0;
  66. return hc;
  67. }
  68. @Override
  69. protected void readMandatory(PacketDecoder decoder) {
  70. messageId = decoder.readCString();
  71. source = decoder.readAddress();
  72. }
  73. @Override
  74. protected void writeMandatory(PacketEncoder encoder) throws IOException {
  75. encoder.writeCString(messageId);
  76. encoder.writeAddress(source);
  77. }
  78. @Override
  79. protected int getMandatorySize() {
  80. int length = 1;
  81. length += sizeOf(messageId);
  82. length += sizeOf(source);
  83. return length;
  84. }
  85. }