use of gov.nist.core.HostPort in project XobotOS by xamarin.
the class Via method setHost.
/**
* Set the host part of this ViaHeader to the newly supplied <code>host</code>
* parameter.
*
* @throws ParseException which signals that an error has been reached
* unexpectedly while parsing the host value.
*/
public void setHost(String host) throws ParseException {
if (sentBy == null)
sentBy = new HostPort();
try {
Host h = new Host(host);
sentBy.setHost(h);
} catch (Exception e) {
throw new NullPointerException(" host parameter is null");
}
}
use of gov.nist.core.HostPort in project XobotOS by xamarin.
the class URLParser method sipURL.
/**
* Parse and return a structure for a SIP URL.
* @return a URL structure for a SIP url.
* @throws ParseException if there was a problem parsing.
*/
public SipUri sipURL(boolean inBrackets) throws ParseException {
if (debug)
dbg_enter("sipURL");
SipUri retval = new SipUri();
// pmusgrave - handle sips case
Token nextToken = lexer.peekNextToken();
int sipOrSips = TokenTypes.SIP;
String scheme = TokenNames.SIP;
if (nextToken.getTokenType() == TokenTypes.SIPS) {
sipOrSips = TokenTypes.SIPS;
scheme = TokenNames.SIPS;
}
try {
lexer.match(sipOrSips);
lexer.match(':');
retval.setScheme(scheme);
int startOfUser = lexer.markInputPosition();
// Note: user may contain ';', host may not...
String userOrHost = user();
String passOrPort = null;
// name:password or host:port
if (lexer.lookAhead() == ':') {
lexer.consume(1);
passOrPort = password();
}
// name@hostPort
if (lexer.lookAhead() == '@') {
lexer.consume(1);
retval.setUser(userOrHost);
if (passOrPort != null)
retval.setUserPassword(passOrPort);
} else {
// then userOrHost was a host, backtrack just in case a ';' was eaten...
lexer.rewindInputPosition(startOfUser);
}
HostNameParser hnp = new HostNameParser(this.getLexer());
HostPort hp = hnp.hostPort(false);
retval.setHostPort(hp);
lexer.selectLexer("charLexer");
while (lexer.hasMoreChars()) {
// If the URI is not enclosed in brackets, parameters belong to header
if (lexer.lookAhead(0) != ';' || !inBrackets)
break;
lexer.consume(1);
NameValue parms = uriParam();
if (parms != null)
retval.setUriParameter(parms);
}
if (lexer.hasMoreChars() && lexer.lookAhead(0) == '?') {
lexer.consume(1);
while (lexer.hasMoreChars()) {
NameValue parms = qheader();
retval.setQHeader(parms);
if (lexer.hasMoreChars() && lexer.lookAhead(0) != '&')
break;
else
lexer.consume(1);
}
}
return retval;
} finally {
if (debug)
dbg_leave("sipURL");
}
}
use of gov.nist.core.HostPort in project XobotOS by xamarin.
the class MessageChannel method getViaHostPort.
/**
* Get the via header host:port structure. This is extracted from the topmost via header of
* the request.
*
* @return a host:port structure
*/
public HostPort getViaHostPort() {
HostPort retval = new HostPort();
retval.setHost(new Host(this.getViaHost()));
retval.setPort(this.getViaPort());
return retval;
}
use of gov.nist.core.HostPort in project XobotOS by xamarin.
the class MessageChannel method getHostPort.
/**
* Get the hostport structure of this message channel.
*/
public HostPort getHostPort() {
HostPort retval = new HostPort();
retval.setHost(new Host(this.getHost()));
retval.setPort(this.getPort());
return retval;
}
use of gov.nist.core.HostPort in project XobotOS by xamarin.
the class MessageProcessor method setSentBy.
/**
* Set the sentby string. This is used for stamping outgoing messages sent
* from this listening point.
*
* @param sentBy
*/
public void setSentBy(String sentBy) throws ParseException {
int ind = sentBy.indexOf(":");
if (ind == -1) {
this.sentByHostPort = new HostPort();
this.sentByHostPort.setHost(new Host(sentBy));
} else {
this.sentByHostPort = new HostPort();
this.sentByHostPort.setHost(new Host(sentBy.substring(0, ind)));
String portStr = sentBy.substring(ind + 1);
try {
int port = Integer.parseInt(portStr);
this.sentByHostPort.setPort(port);
} catch (NumberFormatException ex) {
throw new ParseException("Bad format encountered at ", ind);
}
}
this.sentBySet = true;
this.sentBy = sentBy;
}
Aggregations