UriComponent { public static List<PathSegment> parsePathSegments(String path, boolean decode) { List<PathSegment> result = new ArrayList<>(); if (!(path == null || path.isEmpty())) { if (path.charAt(0) == '/') { path = path.substring(1); } int p = 0; int n = 0; while (n < path.length()) { n = path.indexOf('/', p); if (n < 0) { n = path.length(); } result.add(PathSegmentImpl.fromString(path.substring(p, n), decode)); p = n + 1; } } return result; } private  UriComponent(); static URI normalize(URI uri); static String encode(String str, int component, boolean containsUriParams); static String validateUriComponent(String str, int component, boolean containsUriParams); static boolean isUriComponentContainsValidCharacters(int component, String str); static String recognizeEncode(String str, int component, boolean containsUriParams); static String decode(String str, int component); static boolean checkHexCharacters(String s, int p); static List<PathSegment> parsePathSegments(String path, boolean decode); static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode); static URI resolve(URI baseUri, URI resolvingUri); static final int SCHEME; static final int USER_INFO; static final int HOST; static final int PORT; static final int PATH_SEGMENT; static final int PATH; static final int QUERY; static final int FRAGMENT; static final int SSP; static final int MATRIX_PARAM; static final int QUERY_STRING; static final String PERCENT; }
@Test public void parsesPathSegments() { String path = "/to/be/or%20not/to/be;a=foo;b=b%20a%23r"; List<PathSegment> expected = newArrayList(PathSegmentImpl.fromString("to", false), PathSegmentImpl.fromString("be", false), PathSegmentImpl.fromString("or not", false), PathSegmentImpl.fromString("to", false), PathSegmentImpl.fromString("be;a=foo;b=b a#r", false) ); List<PathSegment> result = parsePathSegments(path, true); assertEquals(expected, result); }