PageRenderTime 33ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/message/transfer/PayloadDataImpl.java

http://mobicents.googlecode.com/
Java | 108 lines | 68 code | 15 blank | 25 comment | 9 complexity | d81d55742c03b95dc90f06ed03cefd71 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  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.m3ua.impl.message.transfer;
  23. import java.nio.ByteBuffer;
  24. import org.mobicents.protocols.ss7.m3ua.impl.message.M3UAMessageImpl;
  25. import org.mobicents.protocols.ss7.m3ua.impl.parameter.CorrelationIdImpl;
  26. import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterImpl;
  27. import org.mobicents.protocols.ss7.m3ua.impl.parameter.ProtocolDataImpl;
  28. import org.mobicents.protocols.ss7.m3ua.message.MessageClass;
  29. import org.mobicents.protocols.ss7.m3ua.message.MessageType;
  30. import org.mobicents.protocols.ss7.m3ua.message.transfer.PayloadData;
  31. import org.mobicents.protocols.ss7.m3ua.parameter.CorrelationId;
  32. import org.mobicents.protocols.ss7.m3ua.parameter.NetworkAppearance;
  33. import org.mobicents.protocols.ss7.m3ua.parameter.Parameter;
  34. import org.mobicents.protocols.ss7.m3ua.parameter.ProtocolData;
  35. import org.mobicents.protocols.ss7.m3ua.parameter.RoutingContext;
  36. /**
  37. * @author amit bhayani
  38. * @author kulikov
  39. */
  40. public class PayloadDataImpl extends M3UAMessageImpl implements PayloadData {
  41. public PayloadDataImpl() {
  42. super(MessageClass.TRANSFER_MESSAGES, MessageType.PAYLOAD, MessageType.S_PAYLOAD);
  43. }
  44. public NetworkAppearance getNetworkAppearance() {
  45. return (NetworkAppearance) parameters.get(Parameter.Network_Appearance);
  46. }
  47. public void setNetworkAppearance(NetworkAppearance p) {
  48. if(p!=null){
  49. parameters.put(Parameter.Network_Appearance, p);
  50. }
  51. }
  52. public RoutingContext getRoutingContext() {
  53. return (RoutingContext) parameters.get(Parameter.Routing_Context);
  54. }
  55. public void setRoutingContext(RoutingContext p) {
  56. if (p != null) {
  57. parameters.put(Parameter.Routing_Context, p);
  58. }
  59. }
  60. public ProtocolData getData() {
  61. return (ProtocolDataImpl) parameters.get(Parameter.Protocol_Data);
  62. }
  63. public void setData(ProtocolData p) {
  64. parameters.put(Parameter.Protocol_Data, p);
  65. }
  66. public CorrelationId getCorrelationId() {
  67. return (CorrelationIdImpl) parameters.get(Parameter.Correlation_ID);
  68. }
  69. public void setCorrelationId(CorrelationId corrId) {
  70. if(corrId != null){
  71. parameters.put(Parameter.Correlation_ID, corrId);
  72. }
  73. }
  74. @Override
  75. public String toString() {
  76. return "TransferMessage: " + parameters;
  77. }
  78. @Override
  79. protected void encodeParams(ByteBuffer buffer) {
  80. if (parameters.containsKey(Parameter.Network_Appearance)) {
  81. ((ParameterImpl) parameters.get(Parameter.Network_Appearance)).write(buffer);
  82. }
  83. if (parameters.containsKey(Parameter.Routing_Context)) {
  84. ((ParameterImpl) parameters.get(Parameter.Routing_Context)).write(buffer);
  85. }
  86. if (parameters.containsKey(Parameter.Protocol_Data)) {
  87. ((ParameterImpl) parameters.get(Parameter.Protocol_Data)).write(buffer);
  88. }
  89. if (parameters.containsKey(Parameter.Correlation_ID)) {
  90. ((ParameterImpl) parameters.get(Parameter.Correlation_ID)).write(buffer);
  91. }
  92. }
  93. }