/protocols/ss7/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/ReleaseMessageImpl.java

http://mobicents.googlecode.com/ · Java · 388 lines · 259 code · 58 blank · 71 comment · 8 complexity · d5e42e8ad59e9c0812c74a365764171d 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. /**
  23. * Start time:21:00:56 2009-07-17<br>
  24. * Project: mobicents-isup-stack<br>
  25. *
  26. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a>
  27. *
  28. */
  29. package org.mobicents.protocols.ss7.isup.impl.message;
  30. import java.util.Map;
  31. import java.util.Set;
  32. import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
  33. import org.mobicents.protocols.ss7.isup.ParameterException;
  34. import org.mobicents.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter;
  35. import org.mobicents.protocols.ss7.isup.impl.message.parameter.MessageTypeImpl;
  36. import org.mobicents.protocols.ss7.isup.message.ReleaseMessage;
  37. import org.mobicents.protocols.ss7.isup.message.parameter.AccessDeliveryInformation;
  38. import org.mobicents.protocols.ss7.isup.message.parameter.AutomaticCongestionLevel;
  39. import org.mobicents.protocols.ss7.isup.message.parameter.CauseIndicators;
  40. import org.mobicents.protocols.ss7.isup.message.parameter.DisplayInformation;
  41. import org.mobicents.protocols.ss7.isup.message.parameter.HTRInformation;
  42. import org.mobicents.protocols.ss7.isup.message.parameter.MessageType;
  43. import org.mobicents.protocols.ss7.isup.message.parameter.NetworkSpecificFacility;
  44. import org.mobicents.protocols.ss7.isup.message.parameter.ParameterCompatibilityInformation;
  45. import org.mobicents.protocols.ss7.isup.message.parameter.RedirectBackwardInformation;
  46. import org.mobicents.protocols.ss7.isup.message.parameter.RedirectCounter;
  47. import org.mobicents.protocols.ss7.isup.message.parameter.RedirectionInformation;
  48. import org.mobicents.protocols.ss7.isup.message.parameter.RedirectionNumber;
  49. import org.mobicents.protocols.ss7.isup.message.parameter.RemoteOperations;
  50. import org.mobicents.protocols.ss7.isup.message.parameter.SignalingPointCode;
  51. import org.mobicents.protocols.ss7.isup.message.parameter.UserToUserIndicators;
  52. import org.mobicents.protocols.ss7.isup.message.parameter.UserToUserInformation;
  53. import org.mobicents.protocols.ss7.isup.message.parameter.accessTransport.AccessTransport;
  54. /**
  55. * Start time:21:00:56 2009-07-17<br>
  56. * Project: mobicents-isup-stack<br>
  57. *
  58. * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
  59. */
  60. class ReleaseMessageImpl extends ISUPMessageImpl implements ReleaseMessage {
  61. public static final MessageTypeImpl _MESSAGE_TYPE = new MessageTypeImpl(MESSAGE_CODE);
  62. private static final int _MANDATORY_VAR_COUNT = 1;
  63. // mandatory fixed L
  64. static final int _INDEX_F_MessageType = 0;
  65. // mandatory variable L
  66. static final int _INDEX_V_CauseIndicators = 0;
  67. // optional
  68. static final int _INDEX_O_RedirectionInformation = 0;
  69. static final int _INDEX_O_RedirectionNumber = 1;
  70. static final int _INDEX_O_AccessTransport = 2;
  71. static final int _INDEX_O_SignalingPointCode = 3;
  72. static final int _INDEX_O_U2UInformation = 4;
  73. static final int _INDEX_O_AutomaticCongestionLevel = 5;
  74. static final int _INDEX_O_NetworkSpecificFacility = 6;
  75. static final int _INDEX_O_AccessDeliveryInformation = 7;
  76. static final int _INDEX_O_ParameterCompatibilityInformation = 8;
  77. static final int _INDEX_O_U2UIndicators = 9;
  78. static final int _INDEX_O_DisplayInformation = 10;
  79. static final int _INDEX_O_RemoteOperations = 11;
  80. static final int _INDEX_O_HTRInformation = 12;
  81. static final int _INDEX_O_RedirectCounter = 13;
  82. static final int _INDEX_O_RedirectBackwardInformation = 14;
  83. static final int _INDEX_O_EndOfOptionalParameters = 15;
  84. ReleaseMessageImpl(Set<Integer> mandatoryCodes, Set<Integer> mandatoryVariableCodes, Set<Integer> optionalCodes, Map<Integer, Integer> mandatoryCode2Index,
  85. Map<Integer, Integer> mandatoryVariableCode2Index, Map<Integer, Integer> optionalCode2Index) {
  86. super(mandatoryCodes, mandatoryVariableCodes, optionalCodes, mandatoryCode2Index, mandatoryVariableCode2Index, optionalCode2Index);
  87. super.f_Parameters.put(_INDEX_F_MessageType, this.getMessageType());
  88. super.o_Parameters.put(_INDEX_O_EndOfOptionalParameters, _END_OF_OPTIONAL_PARAMETERS);
  89. }
  90. /**
  91. * @param parameterBody
  92. * @param parameterCode
  93. * @throws ParameterException
  94. */
  95. protected void decodeMandatoryVariableBody(ISUPParameterFactory parameterFactory, byte[] parameterBody, int parameterIndex) throws ParameterException {
  96. switch (parameterIndex) {
  97. case _INDEX_V_CauseIndicators:
  98. CauseIndicators cpn = parameterFactory.createCauseIndicators();
  99. ((AbstractISUPParameter) cpn).decode(parameterBody);
  100. this.setCauseIndicators(cpn);
  101. break;
  102. default:
  103. throw new ParameterException("Unrecognized parameter index for mandatory variable part: " + parameterIndex);
  104. }
  105. }
  106. /*
  107. * (non-Javadoc)
  108. *
  109. * @see org.mobicents.isup.messages.ISUPMessage#decodeOptionalBody(byte[],
  110. * byte)
  111. */
  112. protected void decodeOptionalBody(ISUPParameterFactory parameterFactory, byte[] parameterBody, byte parameterCode) throws ParameterException {
  113. switch ((int) parameterCode) {
  114. case RedirectionNumber._PARAMETER_CODE:
  115. RedirectionNumber rn = parameterFactory.createRedirectionNumber();
  116. ((AbstractISUPParameter) rn).decode(parameterBody);
  117. this.setRedirectionNumber(rn);
  118. break;
  119. case RedirectionInformation._PARAMETER_CODE:
  120. RedirectionInformation ri = parameterFactory.createRedirectionInformation();
  121. ((AbstractISUPParameter) ri).decode(parameterBody);
  122. this.setRedirectionInformation(ri);
  123. break;
  124. case AccessTransport._PARAMETER_CODE:
  125. AccessTransport at = parameterFactory.createAccessTransport();
  126. ((AbstractISUPParameter) at).decode(parameterBody);
  127. this.setAccessTransport(at);
  128. break;
  129. case SignalingPointCode._PARAMETER_CODE:
  130. SignalingPointCode v = parameterFactory.createSignalingPointCode();
  131. ((AbstractISUPParameter) v).decode(parameterBody);
  132. this.setSignalingPointCode(v);
  133. break;
  134. case UserToUserInformation._PARAMETER_CODE:
  135. UserToUserInformation u2ui = parameterFactory.createUserToUserInformation();
  136. ((AbstractISUPParameter) u2ui).decode(parameterBody);
  137. this.setU2UInformation(u2ui);
  138. break;
  139. case AutomaticCongestionLevel._PARAMETER_CODE:
  140. AutomaticCongestionLevel acl = parameterFactory.createAutomaticCongestionLevel();
  141. ((AbstractISUPParameter) acl).decode(parameterBody);
  142. this.setAutomaticCongestionLevel(acl);
  143. break;
  144. case NetworkSpecificFacility._PARAMETER_CODE:
  145. NetworkSpecificFacility nsf = parameterFactory.createNetworkSpecificFacility();
  146. ((AbstractISUPParameter) nsf).decode(parameterBody);
  147. this.setNetworkSpecificFacility(nsf);
  148. break;
  149. case AccessDeliveryInformation._PARAMETER_CODE:
  150. AccessDeliveryInformation adi = parameterFactory.createAccessDeliveryInformation();
  151. ((AbstractISUPParameter) adi).decode(parameterBody);
  152. this.setAccessDeliveryInformation(adi);
  153. break;
  154. case ParameterCompatibilityInformation._PARAMETER_CODE:
  155. ParameterCompatibilityInformation pci = parameterFactory.createParameterCompatibilityInformation();
  156. ((AbstractISUPParameter) pci).decode(parameterBody);
  157. this.setParameterCompatibilityInformation(pci);
  158. break;
  159. case UserToUserIndicators._PARAMETER_CODE:
  160. UserToUserIndicators utui = parameterFactory.createUserToUserIndicators();
  161. ((AbstractISUPParameter) utui).decode(parameterBody);
  162. this.setU2UIndicators(utui);
  163. break;
  164. case DisplayInformation._PARAMETER_CODE:
  165. DisplayInformation di = parameterFactory.createDisplayInformation();
  166. ((AbstractISUPParameter) di).decode(parameterBody);
  167. this.setDisplayInformation(di);
  168. break;
  169. case RemoteOperations._PARAMETER_CODE:
  170. RemoteOperations ro = parameterFactory.createRemoteOperations();
  171. ((AbstractISUPParameter) ro).decode(parameterBody);
  172. this.setRemoteOperations(ro);
  173. break;
  174. case HTRInformation._PARAMETER_CODE:
  175. HTRInformation htri = parameterFactory.createHTRInformation();
  176. ((AbstractISUPParameter) htri).decode(parameterBody);
  177. this.setHTRInformation(htri);
  178. break;
  179. case RedirectBackwardInformation._PARAMETER_CODE:
  180. RedirectBackwardInformation rbi = parameterFactory.createRedirectBackwardInformation();
  181. ((AbstractISUPParameter) rbi).decode(parameterBody);
  182. this.setRedirectBackwardInformation(rbi);
  183. break;
  184. case RedirectCounter._PARAMETER_CODE:
  185. RedirectCounter rc = parameterFactory.createRedirectCounter();
  186. ((AbstractISUPParameter) rc).decode(parameterBody);
  187. this.setRedirectCounter(rc);
  188. break;
  189. default:
  190. throw new ParameterException("Unrecognized parameter code for optional part: " + parameterCode);
  191. }
  192. }
  193. public CauseIndicators getCauseIndicators() {
  194. return (CauseIndicators) super.v_Parameters.get(_INDEX_V_CauseIndicators);
  195. }
  196. public void setCauseIndicators(CauseIndicators v) {
  197. super.v_Parameters.put(_INDEX_V_CauseIndicators, v);
  198. }
  199. public RedirectionInformation getRedirectionInformation() {
  200. return (RedirectionInformation) super.o_Parameters.get(_INDEX_O_RedirectionInformation);
  201. }
  202. public void setRedirectionInformation(RedirectionInformation v) {
  203. super.o_Parameters.put(_INDEX_O_RedirectionInformation, v);
  204. }
  205. public RedirectionNumber getRedirectionNumber() {
  206. return (RedirectionNumber) super.o_Parameters.get(_INDEX_O_RedirectionNumber);
  207. }
  208. public void setRedirectionNumber(RedirectionNumber v) {
  209. super.o_Parameters.put(_INDEX_O_RedirectionNumber, v);
  210. }
  211. public AccessTransport getAccessTransport() {
  212. return (AccessTransport) super.o_Parameters.get(_INDEX_O_AccessTransport);
  213. }
  214. public void setAccessTransport(AccessTransport v) {
  215. super.o_Parameters.put(_INDEX_O_AccessTransport, v);
  216. }
  217. public SignalingPointCode getSignalingPointCode() {
  218. return (SignalingPointCode) super.o_Parameters.get(_INDEX_O_SignalingPointCode);
  219. }
  220. public void setSignalingPointCode(SignalingPointCode v) {
  221. super.o_Parameters.put(_INDEX_O_SignalingPointCode, v);
  222. }
  223. public UserToUserInformation getU2UInformation() {
  224. return (UserToUserInformation) super.o_Parameters.get(_INDEX_O_U2UInformation);
  225. }
  226. public void setU2UInformation(UserToUserInformation v) {
  227. super.o_Parameters.put(_INDEX_O_U2UInformation, v);
  228. }
  229. public AutomaticCongestionLevel getAutomaticCongestionLevel() {
  230. return (AutomaticCongestionLevel) super.o_Parameters.get(_INDEX_O_AutomaticCongestionLevel);
  231. }
  232. public void setAutomaticCongestionLevel(AutomaticCongestionLevel v) {
  233. super.o_Parameters.put(_INDEX_O_AutomaticCongestionLevel, v);
  234. }
  235. public NetworkSpecificFacility getNetworkSpecificFacility() {
  236. return (NetworkSpecificFacility) super.o_Parameters.get(_INDEX_O_NetworkSpecificFacility);
  237. }
  238. public void setNetworkSpecificFacility(NetworkSpecificFacility v) {
  239. super.o_Parameters.put(_INDEX_O_NetworkSpecificFacility, v);
  240. }
  241. public AccessDeliveryInformation getAccessDeliveryInformation() {
  242. return (AccessDeliveryInformation) super.o_Parameters.get(_INDEX_O_AccessDeliveryInformation);
  243. }
  244. public void setAccessDeliveryInformation(AccessDeliveryInformation v) {
  245. super.o_Parameters.put(_INDEX_O_AccessDeliveryInformation, v);
  246. }
  247. public ParameterCompatibilityInformation getParameterCompatibilityInformation() {
  248. return (ParameterCompatibilityInformation) super.o_Parameters.get(_INDEX_O_ParameterCompatibilityInformation);
  249. }
  250. public void setParameterCompatibilityInformation(ParameterCompatibilityInformation v) {
  251. super.o_Parameters.put(_INDEX_O_ParameterCompatibilityInformation, v);
  252. }
  253. public UserToUserIndicators getU2UIndicators() {
  254. return (UserToUserIndicators) super.o_Parameters.get(_INDEX_O_U2UIndicators);
  255. }
  256. public void setU2UIndicators(UserToUserIndicators v) {
  257. super.o_Parameters.put(_INDEX_O_U2UIndicators, v);
  258. }
  259. public DisplayInformation getDisplayInformation() {
  260. return (DisplayInformation) super.o_Parameters.get(_INDEX_O_DisplayInformation);
  261. }
  262. public void setDisplayInformation(DisplayInformation v) {
  263. super.o_Parameters.put(_INDEX_O_DisplayInformation, v);
  264. }
  265. public RemoteOperations getRemoteOperations() {
  266. return (RemoteOperations) super.o_Parameters.get(_INDEX_O_RemoteOperations);
  267. }
  268. public void setRemoteOperations(RemoteOperations v) {
  269. super.o_Parameters.put(_INDEX_O_RemoteOperations, v);
  270. }
  271. public HTRInformation getHTRInformation() {
  272. return (HTRInformation) super.o_Parameters.get(_INDEX_O_HTRInformation);
  273. }
  274. public void setHTRInformation(HTRInformation v) {
  275. super.o_Parameters.put(_INDEX_O_HTRInformation, v);
  276. }
  277. public RedirectCounter getRedirectCounter() {
  278. return (RedirectCounter) super.o_Parameters.get(_INDEX_O_RedirectCounter);
  279. }
  280. public void setRedirectCounter(RedirectCounter v) {
  281. super.o_Parameters.put(_INDEX_O_RedirectCounter, v);
  282. }
  283. public RedirectBackwardInformation getRedirectBackwardInformation() {
  284. return (RedirectBackwardInformation) super.o_Parameters.get(_INDEX_O_RedirectBackwardInformation);
  285. }
  286. public void setRedirectBackwardInformation(RedirectBackwardInformation v) {
  287. super.o_Parameters.put(_INDEX_O_RedirectBackwardInformation, v);
  288. }
  289. /*
  290. * (non-Javadoc)
  291. *
  292. * @see org.mobicents.isup.messages.ISUPMessage#getMessageType()
  293. */
  294. public MessageType getMessageType() {
  295. return this._MESSAGE_TYPE;
  296. }
  297. /*
  298. * (non-Javadoc)
  299. *
  300. * @seeorg.mobicents.isup.messages.ISUPMessage#
  301. * getNumberOfMandatoryVariableLengthParameters()
  302. */
  303. protected int getNumberOfMandatoryVariableLengthParameters() {
  304. return _MANDATORY_VAR_COUNT;
  305. }
  306. /*
  307. * (non-Javadoc)
  308. *
  309. * @see org.mobicents.isup.messages.ISUPMessage#hasAllMandatoryParameters()
  310. */
  311. public boolean hasAllMandatoryParameters() {
  312. if (this.f_Parameters.get(_INDEX_F_MessageType) == null || this.f_Parameters.get(_INDEX_F_MessageType).getCode() != this.getMessageType().getCode()) {
  313. return false;
  314. }
  315. if (this.v_Parameters.get(_INDEX_V_CauseIndicators) == null) {
  316. return false;
  317. }
  318. return true;
  319. }
  320. /*
  321. * (non-Javadoc)
  322. *
  323. * @see
  324. * org.mobicents.protocols.ss7.isup.impl.ISUPMessageImpl#optionalPartIsPossible
  325. * ()
  326. */
  327. protected boolean optionalPartIsPossible() {
  328. return true;
  329. }
  330. }