/** * Set the visited network ID as a token * @param networkID - token value */ public void setVisitedNetworkID(Token networkID) { if (networkID == null) throw new NullPointerException(" the networkID parameter is null"); this.networkID = networkID.getTokenValue(); // issued by Miguel Freitas this.isQuoted = false; }
throw new ParseException(buffer + "\nID expected", ptr); String id = getNextId(); this.currentMatch = new Token(); this.currentMatch.tokenValue = id; this.currentMatch.tokenType = ID; throw new ParseException(buffer + "\nID expected", ptr); String id = ttokenSafe(); this.currentMatch = new Token(); this.currentMatch.tokenValue = id; this.currentMatch.tokenType = SAFE; throw new ParseException(buffer + "\nID no white space expected", ptr); String id = getNextIdNoWhiteSpace(); this.currentMatch = new Token(); this.currentMatch.tokenValue = id; this.currentMatch.tokenType = ID_NO_WHITESPACE; buffer + "\nUnexpected Token : " + nexttok, ptr); this.currentMatch = new Token(); this.currentMatch.tokenValue = nexttok; this.currentMatch.tokenType = tok; if (!isDigit(next)) throw new ParseException(buffer + "\nExpecting DIGIT", ptr); this.currentMatch = new Token(); this.currentMatch.tokenValue = String.valueOf(next);
/** * parses a method. Consumes if a valid method has been found. */ protected String method() throws ParseException { try { if (debug) dbg_enter("method"); Token[] tokens = this.lexer.peekNextToken(1); Token token = (Token) tokens[0]; if (token.getTokenType() == INVITE || token.getTokenType() == ACK || token.getTokenType() == OPTIONS || token.getTokenType() == BYE || token.getTokenType() == REGISTER || token.getTokenType() == CANCEL || token.getTokenType() == SUBSCRIBE || token.getTokenType() == NOTIFY || token.getTokenType() == PUBLISH || token.getTokenType() == MESSAGE || token.getTokenType() == ID) { lexer.consume(); return token.getTokenValue(); } else { throw createParseException("Invalid Method"); } } finally { if (Debug.debug) dbg_leave("method"); } }
try { if (t1.getTokenType() == TokenTypes.SIP || t1.getTokenType() == TokenTypes.SIPS) { if (t2.getTokenType() == ':') retval = sipURL( inBrackets ); else throw createParseException("Expecting \':\'"); } else if (t1.getTokenType() == TokenTypes.TEL) { if (t2.getTokenType() == ':') { retval = telURL( inBrackets ); } else
if (this.lexer.peekNextToken().getTokenType() == TokenTypes.SLASH) {
public PVisitedNetworkID(Token tok) { super(P_VISITED_NETWORK_ID); setVisitedNetworkID(tok.getTokenValue()); }
if (lexer.hasMoreChars()) { Token tok = this.lexer.peekNextToken(); switch (tok.getTokenType()) { case SEMICOLON:
public Token[] peekNextToken(int ntokens) throws ParseException { int old = ptr; Token[] retval = new Token[ntokens]; for (int i = 0; i < ntokens; i++) { Token tok = new Token(); if (startsId()) { String id = ttoken(); tok.tokenValue = id; String idUppercase = Utils.toUpperCase(id); if (currentLexer.containsKey(idUppercase)) { Integer type = (Integer) currentLexer.get(idUppercase); tok.tokenType = type.intValue(); } else tok.tokenType = ID; } else { char nextChar = getNextChar(); tok.tokenValue = String.valueOf(nextChar); if (isAlpha(nextChar)) { tok.tokenType = ALPHA; } else if (isDigit(nextChar)) { tok.tokenType = DIGIT; } else tok.tokenType = (int) nextChar; } retval[i] = tok; } savedPtr = ptr; ptr = old; return retval; }
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"); } }
int sipOrSips = TokenTypes.SIP; String scheme = TokenNames.SIP; if ( nextToken.getTokenType() == TokenTypes.SIPS)
lexer.SPorHT(); String str = null; if (name.getTokenValue().compareToIgnoreCase(Via.RECEIVED) == 0) { lexer.match(LexerCore.ID); Token value = lexer.getNextToken(); str = value.getTokenValue(); NameValue nv = new NameValue(name.getTokenValue() .toLowerCase(), str); if (quoted) return nv; } else { return new NameValue(name.getTokenValue().toLowerCase(), null); return new NameValue(name.getTokenValue(), null);
/** * 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 lexer.consume(1);// skip '+' value = "+" + base_phone_number(); } else if ( Lexer.isAlphaDigit(la) ) { Token t = lexer.match( Lexer.ID );// more broad than allowed value = t.getTokenValue(); } else { throw new ParseException( "Invalid phone-context:" + la , -1 ); } return new NameValue( "phone-context", value, false ); }
originField.setUsername(userName.getTokenValue()); this.lexer.SPorHT(); String sessId = sessionId.getTokenValue(); if (sessId.length() > 18) sessId = sessId.substring(sessId.length() - 18); Token sessionVersion = lexer.getNextToken(); String sessVer = sessionVersion.getTokenValue(); if (sessVer.length() > 18) sessVer = sessVer.substring(sessVer.length() - 18); originField.setNettype(networkType.getTokenValue()); this.lexer.SPorHT(); originField.setAddrtype(addressType.getTokenValue()); this.lexer.SPorHT();
Token time = lexer.getNextToken(); this.lexer.SPorHT(); String timeValue = time.getTokenValue(); if (timeValue.length() > 18) timeValue = timeValue.substring(timeValue.length() - 18); Token offset = lexer.getNextToken(); this.lexer.SPorHT(); String sign = getSign(offset.getTokenValue()); TypedTime typedTime = getTypedTime(offset.getTokenValue()); zoneAdjustment.setSign(sign); zoneAdjustment.setOffset(typedTime);
if (lexer.startsId()) { Token value = lexer.match(TokenTypes.ID); acceptEncoding.setEncoding(value.getTokenValue()); this.lexer.SPorHT(); value = lexer.match(TokenTypes.ID); if ( pname.getTokenValue().equalsIgnoreCase("q")) { try { float qv = Float.parseFloat(value.getTokenValue()); acceptEncoding.setQValue(qv); } catch (NumberFormatException ex) { acceptEncoding.setParameter( pname.getTokenValue(), value.getTokenValue() ); } else acceptEncoding.setParameter( pname.getTokenValue(), "" );
public ProtoVersionField protoVersionField() throws ParseException { try { this.lexer.match('v'); this.lexer.SPorHT(); this.lexer.match('='); this.lexer.SPorHT(); ProtoVersionField protoVersionField = new ProtoVersionField(); lexer.match(Lexer.ID); Token version = lexer.getNextToken(); protoVersionField.setProtoVersion( Integer.parseInt(version.getTokenValue())); this.lexer.SPorHT(); return protoVersionField; } catch (Exception e) { throw lexer.createParseException(); } }
mediaField.setMedia(media.getTokenValue()); this.lexer.SPorHT(); mediaField.setPort(Integer.parseInt(port.getTokenValue())); Token portsNumber = lexer.getNextToken(); mediaField.setNports( Integer.parseInt(portsNumber.getTokenValue())); this.lexer.SPorHT(); String transport = token.getTokenValue(); while (lexer.lookAhead(0) == '/') { lexer.consume(1); lexer.match(Lexer.ID); Token transportTemp = lexer.getNextToken(); transport = transport + "/" + transportTemp.getTokenValue(); Token tok = lexer.getNextToken(); this.lexer.SPorHT(); String format = tok.getTokenValue().trim(); if (!format.equals("")) formatList.add(format);
Token secToken = lexer.getNextToken(); inReplyTo.setCallId( token.getTokenValue() + "@" + secToken.getTokenValue()); } else { inReplyTo.setCallId(token.getTokenValue()); Token secToken = lexer.getNextToken(); inReplyTo.setCallId( token.getTokenValue() + "@" + secToken.getTokenValue()); } else { inReplyTo.setCallId(token.getTokenValue());
public ConnectionField connectionField() throws ParseException { try { this.lexer.match('c'); this.lexer.SPorHT(); this.lexer.match('='); this.lexer.SPorHT(); ConnectionField connectionField = new ConnectionField(); lexer.match(LexerCore.ID); this.lexer.SPorHT(); Token token = lexer.getNextToken(); connectionField.setNettype(token.getTokenValue()); lexer.match(LexerCore.ID); this.lexer.SPorHT(); token = lexer.getNextToken(); connectionField.setAddressType(token.getTokenValue()); this.lexer.SPorHT(); String rest = lexer.getRest(); ConnectionAddress connectionAddress = connectionAddress(rest.trim()); connectionField.setAddress(connectionAddress); return connectionField; } catch (Exception e) { throw new ParseException(lexer.getBuffer(), lexer.getPtr()); } }
lexer.match(TokenTypes.ID); Token type = lexer.getNextToken(); header.setSecurityMechanism(type.getTokenValue()); this.lexer.SPorHT(); lexer.match(TokenTypes.ID); type = lexer.getNextToken(); header.setSecurityMechanism(type.getTokenValue());