Package org.restlet.ext.sip

Examples of org.restlet.ext.sip.Availability


        super(header);
    }

    @Override
    public Availability readValue() throws IOException {
        Availability result = null;

        skipSpaces();
        if (peek() != -1) {
            String delay = readToken();
            result = new Availability(Integer.parseInt(delay));
            skipSpaces();
            if (peek() == '(') {
                result.setComment(readComment());
            }
            skipSpaces();
        }

        // Read availability parameters.
        if (skipParameterSeparator()) {
            Parameter param = readParameter();

            while (param != null) {
                if ("duration".equals(param.getName())) {
                    result.setDuration(Integer.parseInt(param.getValue()));
                } else {
                    result.getParameters().add(param);
                }

                if (skipParameterSeparator()) {
                    param = readParameter();
                } else {
View Full Code Here


    @Test
    public void testParsing() throws Exception {
        String str = "18000;duration=3600;tag=hyh8";
        AvailabilityReader r = new AvailabilityReader(str);
        Availability a = r.readValue();

        assertEquals(18000, a.getDelay());
        assertEquals(3600, a.getDuration());
        assertNull(a.getComment());
        assertEquals(1, a.getParameters().size());
        Parameter parameter = a.getParameters().get(0);
        assertEquals("tag", parameter.getName());
        assertEquals("hyh8", parameter.getValue());

        str = "120 (I'm in a meeting)";
        r = new AvailabilityReader(str);
        a = r.readValue();
        assertEquals(120, a.getDelay());
        assertEquals(0, a.getDuration());
        assertEquals("I'm in a meeting", a.getComment());
        assertEquals(0, a.getParameters().size());
    }
View Full Code Here

TOP

Related Classes of org.restlet.ext.sip.Availability

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.