use of gov.nist.core.Token in project XobotOS by xamarin.
the class Parser method sipVersion.
protected String sipVersion() throws ParseException {
if (debug)
dbg_enter("sipVersion");
try {
Token tok = lexer.match(SIP);
if (!tok.getTokenValue().equalsIgnoreCase("SIP"))
createParseException("Expecting SIP");
lexer.match('/');
tok = lexer.match(ID);
if (!tok.getTokenValue().equals("2.0"))
createParseException("Expecting SIP/2.0");
return "SIP/2.0";
} finally {
if (debug)
dbg_leave("sipVersion");
}
}
use of gov.nist.core.Token in project XobotOS by xamarin.
the class PMediaAuthorizationParser method parse.
public SIPHeader parse() throws ParseException {
PMediaAuthorizationList mediaAuthorizationList = new PMediaAuthorizationList();
if (debug)
dbg_enter("MediaAuthorizationParser.parse");
try {
headerName(TokenTypes.P_MEDIA_AUTHORIZATION);
PMediaAuthorization mediaAuthorization = new PMediaAuthorization();
mediaAuthorization.setHeaderName(SIPHeaderNamesIms.P_MEDIA_AUTHORIZATION);
while (lexer.lookAhead(0) != '\n') {
this.lexer.match(TokenTypes.ID);
Token token = lexer.getNextToken();
try {
mediaAuthorization.setMediaAuthorizationToken(token.getTokenValue());
} catch (InvalidArgumentException e) {
throw createParseException(e.getMessage());
}
mediaAuthorizationList.add(mediaAuthorization);
this.lexer.SPorHT();
if (lexer.lookAhead(0) == ',') {
this.lexer.match(',');
mediaAuthorization = new PMediaAuthorization();
}
this.lexer.SPorHT();
}
return mediaAuthorizationList;
} finally {
if (debug)
dbg_leave("MediaAuthorizationParser.parse");
}
}
use of gov.nist.core.Token in project XobotOS by xamarin.
the class SecurityAgreeParser method parse.
public SIPHeaderList parse(SecurityAgree header) throws ParseException {
SIPHeaderList list;
if (header.getClass().isInstance(new SecurityClient())) {
list = new SecurityClientList();
} else if (header.getClass().isInstance(new SecurityServer())) {
list = new SecurityServerList();
} else if (header.getClass().isInstance(new SecurityVerify())) {
list = new SecurityVerifyList();
} else
return null;
// the security-mechanism:
this.lexer.SPorHT();
lexer.match(TokenTypes.ID);
Token type = lexer.getNextToken();
header.setSecurityMechanism(type.getTokenValue());
this.lexer.SPorHT();
char la = lexer.lookAhead(0);
if (la == '\n') {
list.add(header);
return list;
} else if (la == ';')
this.lexer.match(';');
this.lexer.SPorHT();
// The parameters:
try {
while (lexer.lookAhead(0) != '\n') {
this.parseParameter(header);
this.lexer.SPorHT();
char laInLoop = lexer.lookAhead(0);
if (laInLoop == '\n' || laInLoop == '\0')
break;
else if (laInLoop == ',') {
list.add(header);
if (header.getClass().isInstance(new SecurityClient())) {
header = new SecurityClient();
} else if (header.getClass().isInstance(new SecurityServer())) {
header = new SecurityServer();
} else if (header.getClass().isInstance(new SecurityVerify())) {
header = new SecurityVerify();
}
this.lexer.match(',');
// the security-mechanism:
this.lexer.SPorHT();
lexer.match(TokenTypes.ID);
type = lexer.getNextToken();
header.setSecurityMechanism(type.getTokenValue());
}
this.lexer.SPorHT();
if (lexer.lookAhead(0) == ';')
this.lexer.match(';');
this.lexer.SPorHT();
}
list.add(header);
return list;
} catch (ParseException ex) {
throw ex;
}
}
use of gov.nist.core.Token in project XobotOS by xamarin.
the class URLParser method local_phone_number.
private TelephoneNumber local_phone_number(boolean inBrackets) throws ParseException {
if (debug)
dbg_enter("local_phone_number");
TelephoneNumber tn = new TelephoneNumber();
tn.setGlobal(false);
NameValueList nv = null;
String b = null;
try {
b = local_number();
tn.setPhoneNumber(b);
if (lexer.hasMoreChars()) {
Token tok = this.lexer.peekNextToken();
switch(tok.getTokenType()) {
case SEMICOLON:
{
if (inBrackets) {
this.lexer.consume(1);
nv = tel_parameters();
tn.setParameters(nv);
}
break;
}
default:
{
break;
}
}
}
} finally {
if (debug)
dbg_leave("local_phone_number");
}
return tn;
}
use of gov.nist.core.Token in project XobotOS by xamarin.
the class URLParser method phone_context.
/**
* Parses the 'phone-context' parameter in tel: URLs
* @throws ParseException
*/
private NameValue phone_context() throws ParseException {
lexer.match('=');
char la = lexer.lookAhead(0);
Object value;
if (la == '+') {
// global-number-digits
// skip '+'
lexer.consume(1);
value = "+" + base_phone_number();
} else if (Lexer.isAlphaDigit(la)) {
// more broad than allowed
Token t = lexer.match(Lexer.ID);
value = t.getTokenValue();
} else {
throw new ParseException("Invalid phone-context:" + la, -1);
}
return new NameValue("phone-context", value, false);
}
Aggregations