/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/ErrorAddress.java

http://mobicents.googlecode.com/ · Java · 113 lines · 38 code · 13 blank · 62 comment · 0 complexity · 50486f0591bb6f07ed3b10ad42fa526b 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;
  23. import org.mobicents.protocols.smpp.util.PacketDecoder;
  24. import org.mobicents.protocols.smpp.util.PacketEncoder;
  25. /**
  26. * An address that message submission was unsuccessfully submitted to. This
  27. * class is used in the SubmitMultiResp packet type to return a list of SME
  28. * addresses that message submission failed for along with an error code for
  29. * each address indicating the reason for the failure.
  30. *
  31. */
  32. public class ErrorAddress extends Address {
  33. static final long serialVersionUID = 2L;
  34. /**
  35. * The error code showing why this address failed.
  36. */
  37. private long error;
  38. /**
  39. * Create a new ErrorAddress object.
  40. */
  41. public ErrorAddress() {
  42. }
  43. /**
  44. * Create a new ErrorAddress object.
  45. *
  46. * @param ton
  47. * The Type Of Number.
  48. * @param npi
  49. * The Numbering Plan Indicator.
  50. * @param addr
  51. * The address.
  52. */
  53. public ErrorAddress(int ton, int npi, String addr) {
  54. super(ton, npi, addr);
  55. }
  56. /**
  57. * Create a new ErrorAddress object.
  58. *
  59. * @param ton
  60. * The Type Of Number.
  61. * @param npi
  62. * The Numbering Plan Indicator.
  63. * @param addr
  64. * The address.
  65. * @param error
  66. * The error code indicating why message submission failed.
  67. */
  68. public ErrorAddress(int ton, int npi, String addr, long error) {
  69. super(ton, npi, addr);
  70. this.error = error;
  71. }
  72. /**
  73. * Get the error code associated with this ErrorAddress.
  74. */
  75. public long getError() {
  76. return error;
  77. }
  78. /**
  79. * Set the error code associated with this ErrorAddress.
  80. */
  81. public void setError(long error) {
  82. this.error = error;
  83. }
  84. public int getLength() {
  85. return super.getLength() + 4;
  86. }
  87. public void writeTo(PacketEncoder encoder) throws java.io.IOException {
  88. super.writeTo(encoder);
  89. encoder.writeUInt4(error);
  90. }
  91. public void readFrom(PacketDecoder decoder) {
  92. super.readFrom(decoder);
  93. error = decoder.readUInt4();
  94. }
  95. @Override
  96. public String toString() {
  97. return new StringBuffer(super.toString())
  98. .append("/Error=").append(error).toString();
  99. }
  100. }