/** * Parse a uri from a string and return a URI structure for it. * * @param url * a String containing the URI structure to be parsed. * @return A parsed URI structure * @exception ParseException * if there was an error parsing the message. */ public GenericURI parseUrl(String url) throws ParseException { return new URLParser(url).parse(); }
/** * Parse a telephone number return a parsed structure. * * @param telephone_number * is a String containing the telephone # to be parsed * @return a parsed address structure. * @since v1.0 * @exception ParseException * a ParseException when the address is badly formatted. */ public TelephoneNumber parseTelephoneNumber(String telephone_number) throws ParseException { // Bug fix contributed by Will Scullin return new URLParser(telephone_number).parseTelephoneNumber(true); }
/** * Parse a SIP url from a string and return a URI structure for it. * * @param url * a String containing the URI structure to be parsed. * @return A parsed URI structure * @exception ParseException * if there was an error parsing the message. */ public SipUri parseSIPUrl(String url) throws ParseException { try { return new URLParser(url).sipURL(true); } catch (ClassCastException ex) { throw new ParseException(url + " Not a SIP URL ", 0); } }
public static void main(String[] args) throws ParseException { // quick test for sips parsing String[] test = { "sip:alice@example.com", "sips:alice@examples.com" , "sip:3Zqkv5dajqaaas0tCjCxT0xH2ZEuEMsFl0xoasip%3A%2B3519116786244%40siplab.domain.com@213.0.115.163:7070"}; for ( int i = 0; i < test.length; i++) { URLParser p = new URLParser(test[i]); GenericURI uri = p.parse(); System.out.println("uri type returned " + uri.getClass().getName()); System.out.println(test[i] + " is SipUri? " + uri.isSipURI() + ">" + uri.encode()); } }
/** * Creates a URI based on given URI string. The URI string is parsed in * order to create the new URI instance. Depending on the scheme the * returned may or may not be a SipURI or TelURL cast as a URI. * * @param uri - the new string value of the URI. * @throws URISyntaxException if the URI string is malformed. */ public javax.sip.address.URI createURI(String uri) throws ParseException { if (uri == null) throw new NullPointerException("null arg"); try { URLParser urlParser = new URLParser(uri); String scheme = urlParser.peekScheme(); if (scheme == null) throw new ParseException("bad scheme", 0); if (scheme.equalsIgnoreCase("sip") || scheme.equalsIgnoreCase("sips")) { return this.createSipURI(uri); } else if (scheme.equalsIgnoreCase("tel")) { return this.createTelURL(uri); } // Issue 316 : the scheme should match ALPHA *(ALPHA / DIGIT / "+" / "-" / "." ) if(!SCHEME_PATTERN.matcher(scheme).matches()) { throw new ParseException("the scheme " + scheme + " from the following uri " + uri + " doesn't match ALPHA *(ALPHA / DIGIT / \"+\" / \"-\" / \".\" ) from RFC3261",0); } } catch (ParseException ex) { throw new ParseException(ex.getMessage(), 0); } return new gov.nist.javax.sip.address.GenericURI(uri); }
} else if (la == ':' || la == '/') { retval = new AddressImpl(); URLParser uriParser = new URLParser((Lexer) lexer); GenericURI uri = uriParser.uriReference( inclParams ); retval.setAddressType(AddressImpl.ADDRESS_SPEC);
this.lexer.selectLexer("sip_urlLexer"); this.lexer.SPorHT(); URLParser uriParser = new URLParser((Lexer) lexer); GenericURI uri = uriParser.uriReference( true ); AddressImpl retval = new AddressImpl(); this.lexer.match('<'); this.lexer.SPorHT(); URLParser uriParser = new URLParser((Lexer) lexer); GenericURI uri = uriParser.uriReference( true ); AddressImpl retval = new AddressImpl();
public RequestLine parse() throws ParseException { if (debug) dbg_enter("parse"); try { RequestLine retval = new RequestLine(); String m = method(); lexer.SPorHT(); retval.setMethod(m); this.lexer.selectLexer("sip_urlLexer"); URLParser urlParser = new URLParser(this.getLexer()); GenericURI url = urlParser.uriReference(true); lexer.SPorHT(); retval.setUri(url); this.lexer.selectLexer("request_lineLexer"); String v = sipVersion(); retval.setSipVersion(v); lexer.SPorHT(); lexer.match('\n'); return retval; } finally { if (debug) dbg_leave("parse"); } }
URLParser urlParser = new URLParser((Lexer) this.lexer); GenericURI uri = urlParser.uriReference( true ); errorInfo.setErrorInfo(uri);
if (this.lexer.lookAhead(0) == '<') { this.lexer.match('<'); urlParser = new URLParser((Lexer) this.lexer); uri = urlParser.uriReference( true ); alertInfo.setAlertInfo(uri);