/** * Start time:08:44:19 2009-04-06<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski * </a> * */ package org.mobicents.ss7.isup.impl.message.parameter; import java.io.IOException; import org.mobicents.ss7.isup.ParameterRangeInvalidException; import org.mobicents.ss7.isup.message.parameter.RedirectCounter; /** * Start time:08:44:19 2009-04-06<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a> */ public class RedirectCounterImpl extends AbstractParameter implements RedirectCounter { private int counter; public RedirectCounterImpl(byte[] b) throws ParameterRangeInvalidException { super(); decodeElement(b); } public RedirectCounterImpl(int counter) { super(); this.setCounter(counter); } public RedirectCounterImpl() { super(); // TODO Auto-generated constructor stub } /* * (non-Javadoc) * * @see org.mobicents.isup.ISUPComponent#decodeElement(byte[]) */ public int decodeElement(byte[] b) throws ParameterRangeInvalidException { if (b == null || b.length != 1) { throw new ParameterRangeInvalidException("byte[] must not be null and length must be 1"); } this.counter = b[0] & 0x1F; return 1; } /* * (non-Javadoc) * * @see org.mobicents.isup.ISUPComponent#encodeElement() */ public byte[] encodeElement() throws IOException { return new byte[] { (byte) (this.counter & 0x1F) }; } public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } public int getCode() { return _PARAMETER_CODE; } }