func (this *URLParser) UriParam() (nv *core.NameValue, ParseException error) { var pname, pvalue string if pname, ParseException = this.ParamNameOrValue(); ParseException != nil { return nil, ParseException } next, _ := this.GetLexer().LookAheadK(0) if next == '=' { this.GetLexer().ConsumeK(1) if pvalue, ParseException = this.ParamNameOrValue(); ParseException != nil { return nil, ParseException } return core.NewNameValue(pname, pvalue), nil } else { return core.NewNameValue(pname, nil), nil } }
/** Sets the value of the <code>lr</code> parameter of this SipURI. The lr * parameter, when present, indicates that the element responsible for * this resource implements the routing mechanisms specified in RFC 3261. * This parameter will be used in the URIs proxies place in the * Record-Route header field values, and may appear in the URIs in a * pre-existing route Set. */ func (this *SipURIImpl) SetLrParam() { if this.uriParms.GetValue("lr") != nil { return } nv := core.NewNameValue("lr", nil) this.uriParms.AddNameValue(nv) }
/** Set the specified parameter. * Bug reported by Dominic Sparks. * * @param name -- name of the parameter * @param value -- value of the parameter. */ func (this *Authentication) SetParameter(name, value string) error { if name == "" { return errors.New("NullPointerException: null name") } nv := this.parameters.GetNameValue(strings.ToLower(name)) if nv == nil { nv = core.NewNameValue(name, value) if strings.ToLower(name) == (ParameterNames_QOP) || strings.ToLower(name) == (ParameterNames_REALM) || strings.ToLower(name) == (ParameterNames_CNONCE) || strings.ToLower(name) == (ParameterNames_NONCE) || strings.ToLower(name) == (ParameterNames_USERNAME) || strings.ToLower(name) == (ParameterNames_DOMAIN) || strings.ToLower(name) == (ParameterNames_OPAQUE) || strings.ToLower(name) == (ParameterNames_NEXT_NONCE) || strings.ToLower(name) == (ParameterNames_URI) || strings.ToLower(name) == (ParameterNames_ALGORITHM) || strings.ToLower(name) == (ParameterNames_RESPONSE) { //if value == "" {//TODO by LY // return errors.New("NullPointerException: null value") //} if strings.HasPrefix(value, core.SIPSeparatorNames_DOUBLE_QUOTE) { return errors.New("ParseException: " + value + " : Unexpected DOUBLE_QUOTE") } nv.SetQuotedValue() } this.parameters.SetNameValue(nv) } else { nv.SetValue(value) } return nil }
/** Get a name value for a given query header (ie one that comes * after the ?). */ func (this *URLParser) Qheader() (nv *core.NameValue, ParseException error) { name, _ := this.GetLexer().GetNextTokenByDelim('=') this.GetLexer().ConsumeK(1) value, _ := this.Hvalue() return core.NewNameValue(name, value), nil }
/** Sets the value of the specified header fields to be included in a * request constructed from the URI. If the header already had a value it * will be overwritten. * * @param name - a String specifying the header name * @param value - a String specifying the header value */ func (this *SipURIImpl) SetHeader(name, value string) { if this.qheaders.GetValue(name) == nil { nv := core.NewNameValue(name, value) this.qheaders.AddNameValue(nv) } else { nv := this.qheaders.GetNameValue(name) nv.SetValue(value) } }
/** * Sets the value of the specified parameter. If the parameter already had * * a value it will be overwritten. A zero-length String indicates flag * * parameter. * * * * @param name - a String specifying the parameter name * * @param value - a String specifying the parameter value * * @throws ParseException which signals that an error has been reached * * unexpectedly while parsing the parameter name or value. * */ func (this *Parameters) SetParameter(name, value string) (ParseException error) { nv := this.parameters.GetNameValue(name) if nv != nil { nv.SetValue(value) } else { nv = core.NewNameValue(name, value) this.parameters.AddNameValue(nv) } return nil }
/** * Sets the URI of the WWWAuthenicateHeader to the <var>uri</var> * parameter value. * * @param uri - the new URI of this WWWAuthenicateHeader. * */ func (this *Authentication) SetURI(uri address.URI) error { if uri != nil { nv := core.NewNameValue(ParameterNames_URI, uri.String()) nv.SetQuotedValue() this.parameters.SetNameValue(nv) return nil } else { return errors.New("NullPointerException: Null URI") } }
/** * Sets the value of the specified parameter. If the parameter already had * * a value it will be overwritten. A zero-length String indicates flag * * parameter. * * * * @param name - a String specifying the parameter name * * @param value - a String specifying the parameter value * * @throws ParseException which signals that an error has been reached * * unexpectedly while parsing the parameter name or value. * */ func (this *SipURIImpl) SetParameter(name, value string) { if name == "ttl" { if _, err := strconv.Atoi(value); err != nil { return } } nv := core.NewNameValue(name, value) this.uriParms.Delete(name) this.uriParms.AddNameValue(nv) }
/** * Set the MADDR parameter . * @param mAddr Host Name to set */ func (this *SipURIImpl) SetMAddr(mAddr string) { nameValue := this.uriParms.GetNameValue(core.SIPTransportNames_MADDR) host := &core.Host{} host.SetAddress(mAddr) if nameValue != nil { nameValue.SetValue(host) } else { nameValue = core.NewNameValue(core.SIPTransportNames_MADDR, host) this.uriParms.AddNameValue(nameValue) } }
/** * Sets the value of the specified parameter. If the parameter already had * * a value it will be overwritten. A zero-length String indicates flag * * parameter. * * * * @param name - a String specifying the parameter name * * @param value - a String specifying the parameter value * * @throws ParseException which signals that an error has been reached * * unexpectedly while parsing the parameter name or value. * */ func (this *Parameters) SetQuotedParameter(name, value string) { nv := this.parameters.GetNameValue(name) if nv != nil { nv.SetValue(value) nv.SetQuotedValue() } else { nv = core.NewNameValue(name, value) nv.SetQuotedValue() this.parameters.AddNameValue(nv) } }
/** Sets the value of the <code>ttl</code> parameter. The ttl parameter * specifies the time-to-live value when packets are sent using UDP * multicast. This is equivalent to SetParameter("ttl", ttl). * * @param ttl - new value of the <code>ttl</code> parameter */ func (this *SipURIImpl) SetTTLParam(ttl int) error { if ttl <= 0 { return errors.New("IllegalArgumentException: Bad ttl value") } if this.uriParms != nil { this.uriParms.Delete("ttl") nv := core.NewNameValue("ttl", ttl) this.uriParms.AddNameValue(nv) } return nil }
/** Overrides the superclass nameValue parser because * we have to tolerate IPV6 addresses in the received parameter. */ func (this *ViaParser) NameValue() (nv *core.NameValue, ParseException error) { lexer := this.GetLexer() lexer.Match(core.CORELEXER_ID) name := lexer.GetNextToken() // eat white space. lexer.SPorHT() quoted := false la, _ := lexer.LookAheadK(0) if la == '=' { lexer.ConsumeK(1) lexer.SPorHT() var str string if strings.ToLower(name.GetTokenValue()) == core.SIPParameters_RECEIVED { // Allow for IPV6 Addresses. // these could have : in them! str = lexer.ByteStringNoSemicolon() } else { if la, _ = lexer.LookAheadK(0); la == '"' { if str, ParseException = lexer.QuotedString(); ParseException != nil { return nil, ParseException } quoted = true } else { lexer.Match(core.CORELEXER_ID) value := lexer.GetNextToken() str = value.GetTokenValue() } } nv := core.NewNameValue(name.GetTokenValue(), str) if quoted { nv.SetQuotedValue() } return nv, nil } else { return core.NewNameValue(name.GetTokenValue(), nil), nil } }
/** Sets the value of the "transport" parameter. This parameter specifies * which transport protocol to use for sending requests and responses to * this entity. The following values are defined: "udp", "tcp", "sctp", * "tls", but other values may be used also. This method is equivalent to * SetParameter("transport", transport). Transport parameter constants * are defined in the {@link javax.sip.ListeningPoint}. * * @param transport - new value for the "transport" parameter * @see javax.sip.ListeningPoint */ func (this *SipURIImpl) SetTransportParam(transport string) error { if transport == "" { return errors.New("NullPointerException: null arg") } if strings.ToUpper(transport) == "UDP" || strings.ToUpper(transport) == "TCP" { nv := core.NewNameValue(core.SIPTransportNames_TRANSPORT, strings.ToLower(transport)) this.uriParms.Delete(core.SIPTransportNames_TRANSPORT) this.uriParms.AddNameValue(nv) return nil } else { return errors.New("ParseException: bad transport " + transport) } }
func (this *TelephoneNumber) SetParameter(name, value string) { nv := core.NewNameValue(name, value) this.parms.AddNameValue(nv) }
/** set the specified parameter * @param name String to set * @param value Object to set */ func (this *TelephoneNumber) SetParm(name string, value interface{}) { nv := core.NewNameValue(name, value) this.parms.AddNameValue(nv) }
/** set the PostDial field * @param p String to set */ func (this *TelephoneNumber) SetPostDial(p string) { nv := core.NewNameValue(core.SIPTransportNames_POSTDIAL, p) this.parms.AddNameValue(nv) }
func (this *Contact) SetExpires(expiryDeltaSeconds int) (InvalidArgumentException error) { this.parameters.AddNameValue(core.NewNameValue(ParameterNames_EXPIRES, strconv.Itoa(expiryDeltaSeconds))) return nil }
/** Set the default parameters for this URI. * Do nothing if the parameter is already set to some value. * Otherwise set it to the given value. * @param name Name of the parameter to set. * @param value value of the parameter to set. */ func (this *SipURIImpl) SetDefaultParm(name string, value interface{}) { if this.uriParms.GetValue(name) == nil { nv := core.NewNameValue(name, value) this.uriParms.AddNameValue(nv) } }
/** * Set a given URI parameter. Note - parameter must be properly * encoded before the function is called. * @param name Name of the parameter to set. * @param value value of the parameter to set. */ func (this *SipURIImpl) SetUriParm(name string, value interface{}) { nv := core.NewNameValue(name, value) this.uriParms.AddNameValue(nv) }