Search in sources :

Example 1 with GenericURI

use of gov.nist.javax.sip.address.GenericURI in project XobotOS by xamarin.

the class URLParser method main.

// quick test routine for debugging type assignment
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());
    }
}
Also used : GenericURI(gov.nist.javax.sip.address.GenericURI)

Example 2 with GenericURI

use of gov.nist.javax.sip.address.GenericURI in project XobotOS by xamarin.

the class URLParser method uriReference.

/**
     * Parse and return a structure for a generic URL.
     * Note that non SIP URLs are just stored as a string (not parsed).
     * @return URI is a URL structure for a SIP url.
     * @throws ParseException if there was a problem parsing.
     */
public GenericURI uriReference(boolean inBrackets) throws ParseException {
    if (debug)
        dbg_enter("uriReference");
    GenericURI retval = null;
    Token[] tokens = lexer.peekNextToken(2);
    Token t1 = (Token) tokens[0];
    Token t2 = (Token) tokens[1];
    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
                throw createParseException("Expecting \':\'");
        } else {
            String urlString = uricString();
            try {
                retval = new GenericURI(urlString);
            } catch (ParseException ex) {
                throw createParseException(ex.getMessage());
            }
        }
    } finally {
        if (debug)
            dbg_leave("uriReference");
    }
    return retval;
}
Also used : GenericURI(gov.nist.javax.sip.address.GenericURI) Token(gov.nist.core.Token) ParseException(java.text.ParseException)

Example 3 with GenericURI

use of gov.nist.javax.sip.address.GenericURI in project XobotOS by xamarin.

the class AlertInfoParser method parse.

/**
     * parse the AlertInfo  String header
     * @return SIPHeader (AlertInfoList  object)
     * @throws SIPParseException if the message does not respect the spec.
     */
public SIPHeader parse() throws ParseException {
    if (debug)
        dbg_enter("AlertInfoParser.parse");
    AlertInfoList list = new AlertInfoList();
    try {
        headerName(TokenTypes.ALERT_INFO);
        while (lexer.lookAhead(0) != '\n') {
            AlertInfo alertInfo = new AlertInfo();
            alertInfo.setHeaderName(SIPHeaderNames.ALERT_INFO);
            URLParser urlParser;
            GenericURI uri;
            do {
                this.lexer.SPorHT();
                if (this.lexer.lookAhead(0) == '<') {
                    this.lexer.match('<');
                    urlParser = new URLParser((Lexer) this.lexer);
                    uri = urlParser.uriReference(true);
                    alertInfo.setAlertInfo(uri);
                    this.lexer.match('>');
                } else {
                    /* This is non standard for Polycom support. 
	                	 * I know it is bad grammar but please do not remove. mranga 
	                	 */
                    String alertInfoStr = this.lexer.byteStringNoSemicolon();
                    alertInfo.setAlertInfo(alertInfoStr);
                }
                this.lexer.SPorHT();
                super.parse(alertInfo);
                list.add(alertInfo);
                if (lexer.lookAhead(0) == ',') {
                    this.lexer.match(',');
                } else
                    break;
            } while (true);
        }
        return list;
    } finally {
        if (debug)
            dbg_leave("AlertInfoParser.parse");
    }
}
Also used : AlertInfoList(gov.nist.javax.sip.header.AlertInfoList) GenericURI(gov.nist.javax.sip.address.GenericURI) AlertInfo(gov.nist.javax.sip.header.AlertInfo)

Aggregations

GenericURI (gov.nist.javax.sip.address.GenericURI)3 Token (gov.nist.core.Token)1 AlertInfo (gov.nist.javax.sip.header.AlertInfo)1 AlertInfoList (gov.nist.javax.sip.header.AlertInfoList)1 ParseException (java.text.ParseException)1