PageRenderTime 116ms CodeModel.GetById 67ms app.highlight 44ms RepoModel.GetById 0ms app.codeStats 1ms

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