com.sun.jersey.server.impl.uri
Class UriHelper

java.lang.Object
  extended by com.sun.jersey.server.impl.uri.UriHelper

public final class UriHelper
extends java.lang.Object

URI helper.

Author:
Jakub Podlesak (japod at sun dot com), Yegor Bugayenko (yegor256@java.net)

Constructor Summary
UriHelper()
           
 
Method Summary
static java.net.URI normalize(java.net.URI uri, boolean preserveContdSlashes)
          Normalize the URI provided and return the normalized copy.
static java.lang.String removeDotSegments(java.lang.String path, boolean preserveContdSlashes)
          Remove dots from path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriHelper

public UriHelper()
Method Detail

normalize

public static java.net.URI normalize(java.net.URI uri,
                                     boolean preserveContdSlashes)
Normalize the URI provided and return the normalized copy.

Parameters:
uri - The URI to normalize
preserveContdSlashes - Shall we preserve "///" slashes
Returns:
New normalized URI

removeDotSegments

public static java.lang.String removeDotSegments(java.lang.String path,
                                                 boolean preserveContdSlashes)
Remove dots from path. alg taken from http://gbiv.com/protocols/uri/rfc/rfc3986.html#relative-dot-segments the alg works as follows: 1. The input buffer is initialized with the now-appended path components and the output buffer is initialized to the empty string. 2. While the input buffer is not empty, loop as follows: A. If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, B. if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, C. if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, D. if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, E. move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer. 3. Finally, the output buffer is returned as the result of remove_dot_segments.

Parameters:
path - Path provided
preserveContdSlashes - Shall we preserve "///" slashes
Returns:
New path


Copyright © 2014 Oracle Corporation. All Rights Reserved.