Exemple #1
0
func (this *AddressParser) NameAddr() (addr *address.AddressImpl, ParseException error) {
	var ch byte
	var uri address.URI

	lexer := this.GetLexer()

	if ch, _ = lexer.LookAheadK(0); ch == '<' {
		lexer.Match('<')
		lexer.SelectLexer("sip_urlLexer")
		lexer.SPorHT()
		uriParser := NewURLParserFromLexer(lexer)
		if uri, ParseException = uriParser.UriReference(); ParseException != nil {
			return nil, ParseException
		}
		addr = address.NewAddressImpl()
		addr.SetAddressType(address.NAME_ADDR)
		addr.SetURI(uri)
		lexer.SPorHT()
		lexer.Match('>')
		return addr, nil
	} else {
		addr = address.NewAddressImpl()
		addr.SetAddressType(address.NAME_ADDR)
		var name string
		if ch, _ = lexer.LookAheadK(0); ch == '"' {
			if name, ParseException = lexer.QuotedString(); ParseException != nil {
				return nil, ParseException
			}
			lexer.SPorHT()
		} else {
			if name, ParseException = lexer.GetNextTokenByDelim('<'); ParseException != nil {
				return nil, ParseException
			}
		}
		addr.SetDisplayName(strings.TrimSpace(name))
		lexer.Match('<')
		lexer.SPorHT()
		uriParser := NewURLParserFromLexer(lexer)
		if uri, ParseException = uriParser.UriReference(); ParseException != nil {
			return nil, ParseException
		}
		addr.SetAddressType(address.NAME_ADDR)
		addr.SetURI(uri)
		lexer.SPorHT()
		lexer.Match('>')
		return addr, nil
	}
}
Exemple #2
0
func (this *AddressParser) Address() (retval *address.AddressImpl, ParseException error) {
	var ch byte
	lexer := this.GetLexer()
	k := 0
	for lexer.HasMoreChars() {
		if ch, ParseException = lexer.LookAheadK(k); ch == '<' ||
			ch == '"' ||
			ch == ':' ||
			ch == '/' {
			break
		} else if ParseException != nil /*ch == 0*/ { //'\0'
			return nil, this.CreateParseException("unexpected EOL")
		} else {
			k++
		}
	}

	if ch, _ = lexer.LookAheadK(k); ch == '<' ||
		ch == '"' {
		if retval, ParseException = this.NameAddr(); ParseException != nil {
			return nil, ParseException
		}
	} else if ch == ':' ||
		ch == '/' {
		retval = address.NewAddressImpl()
		uriParser := NewURLParserFromLexer(lexer)

		var uri address.URI
		if uri, ParseException = uriParser.UriReference(); ParseException != nil {
			return nil, ParseException
		}
		retval.SetAddressType(address.ADDRESS_SPEC)
		retval.SetURI(uri)
	} else {
		return nil, this.CreateParseException("Bad address spec")
	}

	return retval, nil
}
Exemple #3
0
/**
 * Set the wildCardFlag member
 * @param w boolean to set
 */
func (this *Contact) SetWildCardFlag(w bool) {
	this.wildCardFlag = true
	addr := address.NewAddressImpl()
	addr.SetWildCardFlag()
	this.SetAddress(addr)
}