/** * Create a response from a string * * @param responseString -- * string from which to create the message null string returns an * empty message. * */ public Response createResponse(String responseString) throws java.text.ParseException { if (responseString == null) return new SIPResponse(); StringMsgParser smp = new StringMsgParser(); SIPMessage sipMessage = smp.parseSIPMessage(responseString.getBytes(), true, false, null); if (!(sipMessage instanceof SIPResponse)) throw new ParseException(responseString, 0); return (SIPResponse) sipMessage; }
/** Create and return a list of headers. *@param headers -- list of headers. *@throws ParseException -- if a parse exception occurs or a List * of that type of header is not alowed. *@return a List containing the headers. */ public java.util.List createHeaders(String headers) throws java.text.ParseException { if (headers == null) throw new NullPointerException("null arg!"); StringMsgParser smp = new StringMsgParser(); SIPHeader shdr = smp.parseSIPHeader(headers); if (shdr instanceof SIPHeaderList) return (SIPHeaderList) shdr; else throw new ParseException( "List of headers of this type is not allowed in a message", 0); }
/** create a sip uri. * *@param uri -- the uri to parse. */ public javax.sip.address.SipURI createSipURI(String uri) throws ParseException { if (uri == null) throw new NullPointerException("null URI"); try { StringMsgParser smp = new StringMsgParser(); SipUri sipUri = smp.parseSIPUrl(uri); return (SipURI) sipUri; } catch (ParseException ex) { throw new ParseException(ex.getMessage(), 0); } }
currentLine = trimEndOfLine(currentLine); processHeader(currentHeader, message, parseExceptionListener, msgBuffer); message = processFirstLine(currentLine, parseExceptionListener, msgBuffer); } else { char firstChar = currentLine.charAt(0); processHeader(currentHeader, message, parseExceptionListener, msgBuffer);
@Override public SIPMessage parseSIPMessage(byte[] msgBuffer, boolean readBody, boolean strict, ParseExceptionListener parseExceptionListener) throws ParseException { return super.parseSIPMessage(msgBuffer, readBody, strict, parseExceptionListener); }
/** * Creates a TelURL based on given URI string. The '+' should * not be included in the phoneNumber string argument. If scheme is not present, it will be added. * * @param uri - the new string value of the phoneNumber. * @throws URISyntaxException if the URI string is malformed. */ public javax.sip.address.TelURL createTelURL(String uri) throws ParseException { if (uri == null) throw new NullPointerException("null url"); String telUrl = null; if(uri.startsWith("tel:")) { telUrl = uri; }else { telUrl = "tel:" + uri; } try { StringMsgParser smp = new StringMsgParser(); TelURLImpl timp = (TelURLImpl) smp.parseUrl(telUrl); return (TelURL) timp; } catch (ParseException ex) { throw new ParseException(ex.getMessage(), 0); } }
/** * Creates an Address with the new address string value. The address * string is parsed in order to create the new Address instance. Create * with a String value of "*" creates a wildcard address. The wildcard * can be determined if * <code>((SipURI)Address.getURI).getUser() == *;</code>. * * @param address - the new string value of the address. * @throws ParseException which signals that an error has been reached * unexpectedly while parsing the address value. */ public javax.sip.address.Address createAddress(String address) throws java.text.ParseException { if (address == null) throw new NullPointerException("null address"); if (address.equals("*")) { AddressImpl addressImpl = new AddressImpl(); addressImpl.setAddressType(AddressImpl.WILD_CARD); SipURI uri = new SipUri(); uri.setUser("*"); addressImpl.setURI( uri ); return addressImpl; } else { StringMsgParser smp = new StringMsgParser(); return smp.parseAddress(address); } }
public MessageParser createMessageParser(SIPTransactionStack stack) { return new StringMsgParser(); }
@Override protected void processHeader(String header, SIPMessage message, ParseExceptionListener parseExceptionListener, byte[] msgBuffer) throws ParseException { String headerName = Lexer.getHeaderName(header); if (headerName == null) throw new ParseException("The header name or value is null", 0); // logic to process headers only if they are present in the list of headers to parse from a given stack property if(headersToParse.contains(headerName.toLowerCase())) { super.processHeader(header, message, parseExceptionListener, msgBuffer); } else { ((SelectiveMessage) message).addHeaderNotParsed(headerName, header); } }
"false").equalsIgnoreCase("true"); StringMsgParser .setComputeContentLengthFromMessage(computeContentLength);
rxBuffer.compact(); try { SIPMessage m = parser.parseSIPMessage( msg, true, true, this ); this.processMessage( m, rxTime ); rxTime = 0; // reset for next message
StringMsgParser smp = new StringMsgParser(); exHandler = parseExceptionListener; SIPMessage sipMessage = smp.parseSIPMessage(requestString.getBytes(), true, this.strict, exHandler);
StringMsgParser smp = new StringMsgParser(); SIPHeader sipHeader = smp.parseSIPHeader(headerText.trim()); if (sipHeader instanceof SIPHeaderList) { if (((SIPHeaderList) sipHeader).size() > 1) {
public boolean parse() { try { this.msg = new StringMsgParser().parseSIPMessage(payload.getBytes(), true, false, null); } catch (ParseException e) { return false; } if (msg == null) { return false; } try { this.callId = msg.getCallId().getCallId(); this.caller = HeaderAddressUtil.parseUser(msg.getFromHeader()); this.callee = HeaderAddressUtil.parseUser(msg.getToHeader()); if (msg instanceof SIPRequest) { SIPRequest r = (SIPRequest) msg; this.method = r.getMethod(); this.isRequest = true; } else { SIPResponse r = (SIPResponse) msg; this.method = String.valueOf(r.getStatusCode()); this.isRequest = false; } } catch (Exception e) { return false; } return true; }