PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms 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
  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
 23package org.mobicents.protocols.ss7.m3ua.impl.message.transfer;
 24
 25import java.nio.ByteBuffer;
 26
 27import org.mobicents.protocols.ss7.m3ua.impl.message.M3UAMessageImpl;
 28import org.mobicents.protocols.ss7.m3ua.impl.parameter.CorrelationIdImpl;
 29import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterImpl;
 30import org.mobicents.protocols.ss7.m3ua.impl.parameter.ProtocolDataImpl;
 31import org.mobicents.protocols.ss7.m3ua.message.MessageClass;
 32import org.mobicents.protocols.ss7.m3ua.message.MessageType;
 33import org.mobicents.protocols.ss7.m3ua.message.transfer.PayloadData;
 34import org.mobicents.protocols.ss7.m3ua.parameter.CorrelationId;
 35import org.mobicents.protocols.ss7.m3ua.parameter.NetworkAppearance;
 36import org.mobicents.protocols.ss7.m3ua.parameter.Parameter;
 37import org.mobicents.protocols.ss7.m3ua.parameter.ProtocolData;
 38import org.mobicents.protocols.ss7.m3ua.parameter.RoutingContext;
 39
 40/**
 41 * @author amit bhayani
 42 * @author kulikov
 43 */
 44public class PayloadDataImpl extends M3UAMessageImpl implements PayloadData {
 45
 46	public PayloadDataImpl() {
 47		super(MessageClass.TRANSFER_MESSAGES, MessageType.PAYLOAD, MessageType.S_PAYLOAD);
 48	}
 49
 50	public NetworkAppearance getNetworkAppearance() {
 51		return (NetworkAppearance) parameters.get(Parameter.Network_Appearance);
 52	}
 53
 54	public void setNetworkAppearance(NetworkAppearance p) {
 55		if(p!=null){
 56			parameters.put(Parameter.Network_Appearance, p);
 57		}
 58	}
 59
 60	public RoutingContext getRoutingContext() {
 61		return (RoutingContext) parameters.get(Parameter.Routing_Context);
 62	}
 63
 64	public void setRoutingContext(RoutingContext p) {
 65		if (p != null) {
 66			parameters.put(Parameter.Routing_Context, p);
 67		}
 68	}
 69
 70	public ProtocolData getData() {
 71		return (ProtocolDataImpl) parameters.get(Parameter.Protocol_Data);
 72	}
 73
 74	public void setData(ProtocolData p) {
 75		parameters.put(Parameter.Protocol_Data, p);
 76	}
 77
 78	public CorrelationId getCorrelationId() {
 79		return (CorrelationIdImpl) parameters.get(Parameter.Correlation_ID);
 80	}
 81
 82	public void setCorrelationId(CorrelationId corrId) {
 83		if(corrId != null){
 84			parameters.put(Parameter.Correlation_ID, corrId);
 85		}
 86	}
 87
 88	@Override
 89	public String toString() {
 90		return "TransferMessage: " + parameters;
 91	}
 92
 93	@Override
 94	protected void encodeParams(ByteBuffer buffer) {
 95		if (parameters.containsKey(Parameter.Network_Appearance)) {
 96			((ParameterImpl) parameters.get(Parameter.Network_Appearance)).write(buffer);
 97		}
 98		if (parameters.containsKey(Parameter.Routing_Context)) {
 99			((ParameterImpl) parameters.get(Parameter.Routing_Context)).write(buffer);
100		}
101		if (parameters.containsKey(Parameter.Protocol_Data)) {
102			((ParameterImpl) parameters.get(Parameter.Protocol_Data)).write(buffer);
103		}
104		if (parameters.containsKey(Parameter.Correlation_ID)) {
105			((ParameterImpl) parameters.get(Parameter.Correlation_ID)).write(buffer);
106		}
107	}
108}