
org.mobicents.protocols.mgcp.parser.params.EmbeddedRequestHandler Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.mobicents.protocols.mgcp.parser.params;
import java.text.ParseException;
import org.mobicents.protocols.mgcp.parser.StringFunctions;
import org.mobicents.protocols.mgcp.parser.SplitDetails;
import jain.protocol.ip.mgcp.message.parms.DigitMap;
import jain.protocol.ip.mgcp.message.parms.RequestedEvent;
import jain.protocol.ip.mgcp.message.parms.EventName;
import jain.protocol.ip.mgcp.message.parms.EmbeddedRequest;
public class EmbeddedRequestHandler
{
private static Object decodeSingle(byte[] value,int offset,int length) throws ParseException
{
if(length<=3)
throw new ParseException("Unknown value for Embedded Request: " + new String(value,offset,length), 0);
int startIndex=offset+1;
while(startIndexcontentStart && value[contentEnd]==StringFunctions.SPACE_BYTE)
contentEnd--;
if(contentStart==contentEnd)
throw new ParseException("Unknown value for Embedded Request: " + new String(value,offset,length), 0);
byte currByte=value[offset];
switch(currByte)
{
case StringFunctions.LOW_R_BYTE:
case StringFunctions.HIGH_R_BYTE:
return RequestedEventHandler.decodeList(value,contentStart,contentEnd-contentStart+1);
case StringFunctions.LOW_D_BYTE:
case StringFunctions.HIGH_D_BYTE:
return DigitMapHandler.decode(value,contentStart,contentEnd-contentStart+1);
case StringFunctions.LOW_S_BYTE:
case StringFunctions.HIGH_S_BYTE:
return EventNameHandler.decodeList(value,contentStart,contentEnd-contentStart+1);
default:
throw new ParseException("Unknown value for Embedded Request: " + new String(value,offset,length), 0);
}
}
public static EmbeddedRequest decode(byte[] value,int offset,int length) throws ParseException
{
Object currObject;
RequestedEvent[] requestedEvents = null;
EventName[] signalEvents = null;
DigitMap digitMap = null;
int currIndex=offset;
int startIndex=offset;
int i=0;
while(value[startIndex]==StringFunctions.SPACE_BYTE && i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy