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

http://mobicents.googlecode.com/ · Java · 114 lines · 71 code · 17 blank · 26 comment · 4 complexity · a0ddda52c4becff9ccdbe4b9441574ee 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. * Cancel a previously submitted broadcast message.
  29. * @version $Id: CancelBroadcastSM.java 457 2009-01-15 17:37:42Z orank $
  30. * @since 0.4.0
  31. */
  32. public class CancelBroadcastSM extends SMPPPacket {
  33. private static final long serialVersionUID = 2L;
  34. private String serviceType;
  35. private String messageId;
  36. private Address source;
  37. public CancelBroadcastSM() {
  38. super (CommandId.CANCEL_BROADCAST_SM);
  39. }
  40. public String getMessageId() {
  41. return messageId;
  42. }
  43. public void setMessageId(String messageId) {
  44. this.messageId = messageId;
  45. }
  46. public String getServiceType() {
  47. return serviceType;
  48. }
  49. public void setServiceType(String serviceType) {
  50. this.serviceType = serviceType;
  51. }
  52. public Address getSource() {
  53. return source;
  54. }
  55. public void setSource(Address source) {
  56. this.source = source;
  57. }
  58. @Override
  59. public boolean equals(Object obj) {
  60. boolean equals = super.equals(obj);
  61. if (equals) {
  62. CancelBroadcastSM other = (CancelBroadcastSM) obj;
  63. equals |= safeCompare(serviceType, other.serviceType);
  64. equals |= safeCompare(messageId, other.messageId);
  65. equals |= safeCompare(source, other.source);
  66. }
  67. return equals;
  68. }
  69. @Override
  70. public int hashCode() {
  71. int hc = super.hashCode();
  72. hc += (serviceType != null) ? serviceType.hashCode() : 0;
  73. hc += (messageId != null) ? messageId.hashCode() : 31;
  74. hc += (source != null) ? source.hashCode() : 97;
  75. return hc;
  76. }
  77. @Override
  78. protected void readMandatory(PacketDecoder decoder) {
  79. serviceType = decoder.readCString();
  80. messageId = decoder.readCString();
  81. source = decoder.readAddress();
  82. }
  83. @Override
  84. protected void writeMandatory(PacketEncoder encoder) throws IOException {
  85. encoder.writeCString(serviceType);
  86. encoder.writeCString(messageId);
  87. encoder.writeAddress(source);
  88. }
  89. @Override
  90. protected int getMandatorySize() {
  91. int length = 2;
  92. length += sizeOf(serviceType);
  93. length += sizeOf(messageId);
  94. length += sizeOf(source);
  95. return length;
  96. }
  97. }