/protocols/ss7/map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/dialog/MAPUserAbortChoiceImpl.java

http://mobicents.googlecode.com/ · Java · 124 lines · 71 code · 23 blank · 30 comment · 8 complexity · 906784735a34933206a69f1382e7a113 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.ss7.map.dialog;
  23. import org.mobicents.protocols.ss7.map.api.dialog.MAPUserAbortChoice;
  24. import org.mobicents.protocols.ss7.map.api.dialog.ProcedureCancellationReason;
  25. import org.mobicents.protocols.ss7.map.api.dialog.ResourceUnavailableReason;
  26. /**
  27. * MAP-UserAbortChoice ::= CHOICE {
  28. * userSpecificReason [0] NULL,
  29. * userResourceLimitation [1] NULL,
  30. * resourceUnavailable [2] ResourceUnavailableReason,
  31. * applicationProcedureCancellation [3] ProcedureCancellationReason}
  32. * @author amit bhayani
  33. *
  34. */
  35. public class MAPUserAbortChoiceImpl implements MAPUserAbortChoice {
  36. protected static final int USER_SPECIFIC_REASON_TAG = 0;
  37. protected static final int USER_RESOURCE_LIMITATION_TAG = 1;
  38. protected static final int RESOURCE_UNAVAILABLE = 2;
  39. protected static final int APPLICATION_PROCEDURE_CANCELLATION = 3;
  40. private ProcedureCancellationReason procedureCancellationReason = null;
  41. private boolean isProcedureCancellationReason = false;
  42. private ResourceUnavailableReason resourceUnavailableReason = null;
  43. private boolean isResourceUnavailableReason = false;
  44. private boolean isUserResourceLimitation = false;
  45. private boolean isUserSpecificReason = false;
  46. public ProcedureCancellationReason getProcedureCancellationReason() {
  47. return this.procedureCancellationReason;
  48. }
  49. public ResourceUnavailableReason getResourceUnavailableReason() {
  50. return this.resourceUnavailableReason;
  51. }
  52. public boolean isProcedureCancellationReason() {
  53. return this.isProcedureCancellationReason;
  54. }
  55. public boolean isResourceUnavailableReason() {
  56. return this.isResourceUnavailableReason;
  57. }
  58. public boolean isUserResourceLimitation() {
  59. return this.isUserResourceLimitation;
  60. }
  61. public boolean isUserSpecificReason() {
  62. return this.isUserSpecificReason;
  63. }
  64. public void setProcedureCancellationReason(
  65. ProcedureCancellationReason procCanReasn) {
  66. this.procedureCancellationReason = procCanReasn;
  67. this.isProcedureCancellationReason = true;
  68. }
  69. public void setResourceUnavailableReason(
  70. ResourceUnavailableReason resUnaReas) {
  71. this.resourceUnavailableReason = resUnaReas;
  72. this.isResourceUnavailableReason = true;
  73. }
  74. public void setUserResourceLimitation() {
  75. this.isUserResourceLimitation = true;
  76. }
  77. public void setUserSpecificReason() {
  78. this.isUserSpecificReason = true;
  79. }
  80. @Override
  81. public String toString() {
  82. StringBuilder sb = new StringBuilder();
  83. sb.append("MAPUserAbortChoice [");
  84. if (this.isUserSpecificReason)
  85. sb.append(" UserSpecificReason");
  86. if (this.isUserResourceLimitation)
  87. sb.append(" UserResourceLimitation");
  88. if (this.isResourceUnavailableReason) {
  89. sb.append(" ResourceUnavailableReason=");
  90. if (this.resourceUnavailableReason != null)
  91. sb.append(this.resourceUnavailableReason.toString());
  92. }
  93. if (this.isProcedureCancellationReason) {
  94. sb.append(" ProcedureCancellationReason=");
  95. if (this.procedureCancellationReason != null)
  96. sb.append(this.procedureCancellationReason.toString());
  97. }
  98. sb.append("]");
  99. return sb.toString();
  100. }
  101. }