Package org.apache.wink.common.internal

Examples of org.apache.wink.common.internal.PathSegmentImpl


    public static List<PathSegment> parsePath(String path) {
        String[] segmentsArray = StringUtils.fastSplitTemplate(path, "/", true);
        List<PathSegment> pathSegments = new ArrayList<PathSegment>(segmentsArray.length);
        // go over all the segments and add them
        for (String segment : segmentsArray) {
            pathSegments.add(new PathSegmentImpl(segment));
        }
        return pathSegments;
    }
View Full Code Here


    public static List<PathSegment> parsePath(String path) {
        String[] segmentsArray = StringUtils.fastSplitTemplate(path, "/", true); //$NON-NLS-1$
        List<PathSegment> pathSegments = new ArrayList<PathSegment>(segmentsArray.length);
        // go over all the segments and add them
        for (String segment : segmentsArray) {
            pathSegments.add(new PathSegmentImpl(segment));
        }
        return pathSegments;
    }
View Full Code Here

    private static String PATH_WITH_ONE_MATRIX        = "matrix;a=a1";
    private static String PATH_WITH_TWO_MATRIX        = "matrix;a=a1;b=b1";
    private static String PATH_WITH_TWO_MATRIX_VALUES = "matrix;a=a1;a=a2;b=b1";

    public void testPathSegmentClean() {
        PathSegment segment = new PathSegmentImpl(PATH_CLEAN);
        assertEquals(PATH_CLEAN, segment.getPath());
        MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
        assertNotNull(matrixParameters);
        assertEquals(0, matrixParameters.size());
    }
View Full Code Here

        assertNotNull(matrixParameters);
        assertEquals(0, matrixParameters.size());
    }

    public void testPathSegmentWithOneMatrix() {
        PathSegment segment = new PathSegmentImpl(PATH_WITH_ONE_MATRIX);
        assertEquals("matrix", segment.getPath());
        MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
        assertNotNull(matrixParameters);
        assertEquals(1, matrixParameters.size());
        assertEquals(1, matrixParameters.get("a").size());
        assertEquals("a1", matrixParameters.getFirst("a"));
        assertNull(matrixParameters.get("b"));
View Full Code Here

        assertEquals("a1", matrixParameters.getFirst("a"));
        assertNull(matrixParameters.get("b"));
    }

    public void testPathSegmentWithTwoMatrix() {
        PathSegment segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX);
        assertEquals("matrix", segment.getPath());
        MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
        assertNotNull(matrixParameters);
        assertEquals(2, matrixParameters.size());
        assertEquals(1, matrixParameters.get("a").size());
        assertEquals("a1", matrixParameters.getFirst("a"));
        assertEquals(1, matrixParameters.get("b").size());
View Full Code Here

        assertEquals(1, matrixParameters.get("b").size());
        assertEquals("b1", matrixParameters.getFirst("b"));
    }

    public void testPathSegmentWithTwoMatrixValues() {
        PathSegment segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX_VALUES);
        testPathSegmentWithTwoMatrixValues(segment);
    }
View Full Code Here

        PathSegment segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX_VALUES);
        testPathSegmentWithTwoMatrixValues(segment);
    }

    public void testClone() {
        PathSegmentImpl segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX_VALUES);
        testPathSegmentWithTwoMatrixValues(segment.clone());
    }
View Full Code Here

        assertEquals("b1", matrixParameters.getFirst("b"));
        assertNull(matrixParameters.get("c"));
    }

    public void testPathSegmentImplSpecifics() {
        PathSegmentImpl segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX_VALUES);

        MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
        matrixParameters.add("a", "a3");
        matrixParameters.add("a", "a4");
        matrixParameters.add("c", "c1");

        assertEquals(3, matrixParameters.size());
        assertEquals(4, matrixParameters.get("a").size());
        assertEquals("a1", matrixParameters.get("a").get(0));
        assertEquals("a2", matrixParameters.get("a").get(1));
        assertEquals("a3", matrixParameters.get("a").get(2));
        assertEquals("a4", matrixParameters.get("a").get(3));
        assertEquals(1, matrixParameters.get("c").size());
        assertEquals("c1", matrixParameters.get("c").get(0));

        segment.clearMatrixParameter("c");
        assertEquals(2, matrixParameters.size());
        assertNull(matrixParameters.get("c"));

        segment.clearAllMatrixParameters();
        assertEquals(0, matrixParameters.size());

        segment.setMatrixParameters("A=A1;B=B2");
        assertEquals(2, matrixParameters.size());
        assertEquals("A1", matrixParameters.get("A").get(0));
        assertEquals("B2", matrixParameters.get("B").get(0));
        assertNull(matrixParameters.get("a"));
        assertNull(matrixParameters.get("b"));
View Full Code Here

        assertNull(matrixParameters.get("a"));
        assertNull(matrixParameters.get("b"));
    }

    public void testToString() {
        PathSegmentImpl segment = new PathSegmentImpl(PATH_WITH_TWO_MATRIX_VALUES);
        String string = segment.toString();
        assertEquals(PATH_WITH_TWO_MATRIX_VALUES, string);
        segment = new PathSegmentImpl(PATH_CLEAN);
        string = segment.toString();
        assertEquals(PATH_CLEAN, string);
    }
View Full Code Here

        string = segment.toString();
        assertEquals(PATH_CLEAN, string);
    }

    public void testEquality() {
        PathSegmentImpl segment1 = new PathSegmentImpl("matrix");
        PathSegmentImpl segment2 = new PathSegmentImpl("matrix");
        assertEquals(segment1, segment2);

        segment1 = new PathSegmentImpl(";a=a1;a=a2;b=b1");
        segment2 = new PathSegmentImpl(";a=a1;a=a2;b=b1");
        assertEquals(segment1, segment2);

        segment1 = new PathSegmentImpl("matrix;a=a1;a=a2;b=b1");
        segment2 = new PathSegmentImpl("matrix;a=a1;a=a2;b=b1");
        assertEquals(segment1, segment2);

        segment1 = new PathSegmentImpl("matrix;a=a2;a=a1;b=b1");
        segment2 = new PathSegmentImpl("matrix;a=a1;a=a2;b=b1");
        assertFalse(segment1.equals(segment2));

        segment1 = new PathSegmentImpl("matrix1;a=a1;a=a2;b=b1");
        segment2 = new PathSegmentImpl("matrix2;a=a1;a=a2;b=b1");
        assertFalse(segment1.equals(segment2));

        segment1 = new PathSegmentImpl("matrix;a=a1;a=a2;b=b1");
        segment2 = new PathSegmentImpl("matrix;a=a1;a=a2");
        assertFalse(segment1.equals(segment2));
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.PathSegmentImpl

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.