/** * Sets the RequestURI of Request. The Request-URI is a SIP or SIPS URI or a general URI. It * indicates the user or service to which this request is being addressed. SIP elements MAY * support Request-URIs with schemes other than "sip" and "sips", for example the "tel" URI * scheme. SIP elements MAY translate non-SIP URIs using any mechanism at their disposal, * resulting in SIP URI, SIPS URI, or some other scheme. * * @param uri the new Request URI of this request message */ public void setRequestURI(URI uri) { if ( uri == null ) { throw new NullPointerException("Null request URI"); } if (this.requestLine == null) { this.requestLine = new RequestLine(); } this.requestLine.setUri((GenericURI) uri); this.nullRequest = false; }
/** * Get the first line encoded. * * @return a string containing the encoded request line. */ public String getFirstLine() { if (requestLine == null) return null; else return this.requestLine.encode(); }
/** * A conveniance function to access the Request URI. * * @return the requestURI if it exists. */ public javax.sip.address.URI getRequestURI() { if (this.requestLine == null) return null; else return (javax.sip.address.URI) this.requestLine.getUri(); }
/** * Set the method. * * @param method is the method to set. * @throws IllegalArgumentException if the method is null */ public void setMethod(String method) { if (method == null) throw new IllegalArgumentException("null method"); if (this.requestLine == null) { this.requestLine = new RequestLine(); } // Set to standard constants to speed up processing. // this makes equals compares run much faster in the // stack because then it is just identity comparision String meth = getCannonicalName(method); this.requestLine.setMethod(meth); if (this.cSeqHeader != null) { try { this.cSeqHeader.setMethod(meth); } catch (ParseException e) { } } }
public RequestLine parse() throws ParseException { if (debug) dbg_enter("parse"); try { RequestLine retval = new RequestLine(); String m = method(); lexer.SPorHT(); retval.setMethod(m); this.lexer.selectLexer("sip_urlLexer"); URLParser urlParser = new URLParser(this.getLexer()); GenericURI url = urlParser.uriReference(true); lexer.SPorHT(); retval.setUri(url); this.lexer.selectLexer("request_lineLexer"); String v = sipVersion(); retval.setSipVersion(v); lexer.SPorHT(); lexer.match('\n'); return retval; } finally { if (debug) dbg_leave("parse"); } }
/** * Set the default values in the request URI if necessary. */ protected void setDefaults() { // The request line may be unparseable (set to null by the // exception handler. if (requestLine == null) return; String method = requestLine.getMethod(); // The requestLine may be malformed! if (method == null) return; GenericURI u = requestLine.getUri(); if (u == null) return; if (method.compareTo(Request.REGISTER) == 0 || method.compareTo(Request.INVITE) == 0) { if (u instanceof SipUri) { SipUri sipUri = (SipUri) u; sipUri.setUserParam(DEFAULT_USER); try { sipUri.setTransportParam(DEFAULT_TRANSPORT); } catch (ParseException ex) { } } } }
/** * Set the sip version. * * @param sipVersion the sip version to set. */ public void setSIPVersion(String sipVersion) throws ParseException { if (sipVersion == null || !sipVersion.equalsIgnoreCase("SIP/2.0")) throw new ParseException("sipVersion", 0); this.requestLine.setSipVersion(sipVersion); }
/** * Make a clone (deep copy) of this object. You can use this if you want to modify a request * while preserving the original * * @return a deep copy of this object. */ public Object clone() { SIPRequest retval = (SIPRequest) super.clone(); // Do not copy over the tx pointer -- this is only for internal // tracking. retval.transactionPointer = null; if (this.requestLine != null) retval.requestLine = (RequestLine) this.requestLine.clone(); return retval; }
/** * Get the method from the request line. * * @return the method from the request line if the method exits and null if the request line * or the method does not exist. */ public String getMethod() { if (requestLine == null) return null; else return requestLine.getMethod(); }
/** * Compare for equality. * * @param other object to compare ourselves with. */ public boolean equals(Object other) { if (!this.getClass().equals(other.getClass())) return false; SIPRequest that = (SIPRequest) other; return requestLine.equals(that.requestLine) && super.equals(other); }
/** * Convert to a formatted string for pretty printing. Note that the encode method converts * this into a sip message that is suitable for transmission. Note hack here if you want to * convert the nice curly brackets into some grotesque XML tag. * * @return a string which can be used to examine the message contents. * */ public String debugDump() { String superstring = super.debugDump(); stringRepresentation = ""; sprint(SIPRequest.class.getName()); sprint("{"); if (requestLine != null) sprint(requestLine.debugDump()); sprint(superstring); sprint("}"); return stringRepresentation; }
public RequestLine parse() throws ParseException { if (debug) dbg_enter("parse"); try { RequestLine retval = new RequestLine(); String m = method(); lexer.SPorHT(); retval.setMethod(m); this.lexer.selectLexer("sip_urlLexer"); URLParser urlParser = new URLParser(this.getLexer()); GenericURI url = urlParser.uriReference(true); lexer.SPorHT(); retval.setUri(url); this.lexer.selectLexer("request_lineLexer"); String v = sipVersion(); retval.setSipVersion(v); lexer.SPorHT(); lexer.match('\n'); return retval; } finally { if (debug) dbg_leave("parse"); } }
cancel.setRequestLine((RequestLine) this.requestLine.clone()); cancel.setMethod(Request.CANCEL); cancel.setHeader((Header) this.callIdHeader.clone());
final String method = requestLine.getMethod(); if (SIPTransactionStack.isDialogCreated(method)) { if (this.getContactHeader() == null) {
/** Encode the request line as a String. * * @return requestLine encoded as a string. */ public String encode() { return encode(new StringBuilder()).toString(); }
return defaultRoute; javax.sip.address.URI requestURI = requestLine.getUri(); if (requestURI == null) throw new IllegalArgumentException("Bad message: Null requestURI");
newRequest.setRequestLine((RequestLine) this.requestLine.clone()); newRequest.setMethod(Request.ACK); newRequest.setHeader((Header) this.callIdHeader.clone());
/** * Get the message as a linked list of strings. Use this if you want to iterate through the * message. * * @return a linked list containing the request line and headers encoded as strings. */ public LinkedList getMessageAsEncodedStrings() { LinkedList retval = super.getMessageAsEncodedStrings(); if (requestLine != null) { this.setRequestLineDefaults(); retval.addFirst(requestLine.encode()); } return retval; }
return getOutboundProxy(); javax.sip.address.URI requestURI = requestLine.getUri(); if (requestURI == null) throw new IllegalArgumentException("Bad message: Null requestURI");