/** * 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.PivotCounter; /** * 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 PivotCounterImpl extends AbstractParameter implements PivotCounter { private int counter = 0; public PivotCounterImpl(byte[] b) throws ParameterRangeInvalidException { super(); decodeElement(b); } public PivotCounterImpl() { super(); // TODO Auto-generated constructor stub } public PivotCounterImpl(int counter) { super(); this.setCounter(counter); } /* * (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; } }