com.sapportals.wcm.util.uri

Class HttpUrl

java.lang.Object
  extended by com.sapportals.wcm.util.uri.HttpUrl
All Implemented Interfaces:
IHierarchicalUri, IUri

public class HttpUrl
extends Object
implements IHierarchicalUri

An IHierarchicalUri implementation for HTTP/HTTPS URLs.

Copyright (c) SAP AG 2001-2003


Field Summary
static int DEFAULT_PORT
           
 
Constructor Summary
HttpUrl(String scheme, String host, int port, String path, String query)
           
HttpUrl(String scheme, String authority, String path, String query)
           
 
Method Summary
 IHierarchicalUri appendPath(String path)
          Append the given path segment to the current path of this uri.
 boolean equals(HttpUrl other)
           
 boolean equals(IHierarchicalUri other)
           
 boolean equals(IUri other)
           
 boolean equals(Object other)
           
 String getAuthority()
          Return authority part of this hierarchical Uri.
 String getHost()
          Return the host name of this uri
 String getPath()
          Return path of this Uri or, if not there, the emtpy string
 String[] getPathSegments()
          Return the segments of the uri path
 int getPort()
          Return the port number of this uri
 String getQuery()
          Return query of this Uri or, if not there, null
 String getRemainder()
          Get the remainder of this Uri (part after scheme without ':').
 IHierarchicalUri getRoot()
          Returns the uri of the root collection (path = "/").
 String getScheme()
          Get the scheme of this Uri (without ':').
 int hashCode()
           
 boolean isAncestorOf(IHierarchicalUri other)
          Determine if this Uri is ancestor of other uri
 IUriReference mapToAbsolutePath(IUriReference ref)
          Given this Uri as the base, map the uri reference to a uri reference with absolute path component.
 IUriReference mapToAbsolutePath(RID wcmPath)
           
 IUriReference mapToAbsolutePath(RID wcmPath, URICodec codec)
           
 IUriReference mapToAbsolutePath(URI wcmPath)
          Deprecated. As of EP5 SP6, replaced by mapToAbsolutePath(RID)
 IUriReference mapToAbsolutePath(URI wcmPath, URICodec codec)
          Deprecated. As of EP5 SP6, replaced by mapToAbsolutePath(RID, URICodec)
 IHierarchicalUri mapToAbsoluteUri(RID wcmPath)
           
 IHierarchicalUri mapToAbsoluteUri(RID wcmPath, URICodec codec)
           
 IHierarchicalUri mapToAbsoluteUri(URI wcmPath)
          Deprecated. As of EP5 SP6, replaced by #mapToAbsoluteURI(RID) Given this Uri as the base of the WCM repository, map the WCM Path to a absolute uri.
 Example: "http://host/docs" + "test 3", gives "http://host/docs/test%203"
 Example: "http://host/docs" + "/fs/test", gives "http://host/docs/fs/test"
 
 IHierarchicalUri mapToAbsoluteUri(URI wcmPath, URICodec codec)
          Deprecated. As of EP5 SP6, replaced by #mapToAbsoluteURI(RID, URICodec) Given this Uri as the base of the WCM repository, map the WCM Path to a absolute uri.
 Example: "http://host/docs" + "test 3", gives "http://host/docs/test%203"
 Example: "http://host/docs" + "/fs/test", gives "http://host/docs/fs/test"
 
 RID mapToResourceID(IUriReference ref)
           
 RID mapToResourceID(IUriReference ref, URICodec codec)
           
 URI mapToWcmPath(IUriReference ref)
          Deprecated. As of EP5 SP6, replaced by mapToResourceID(IUriReference)
 URI mapToWcmPath(IUriReference ref, URICodec codec)
          Deprecated. As of EP5 SP6, replaced by mapToResourceID(IUriReference, URICodec)
protected static StringBuffer normalizePath(StringBuffer sb)
           
 IUri resolve(IUriReference reference)
          Resolve the uri reference in the context of this Uri.
 IHierarchicalUri setPath(String path)
          Construct a new object of same type with the given path.
 IHierarchicalUri setQuery(String query)
          Construct a new object of same type with the given query.
 String toExternalForm()
          Returns a string representation according to RFC 2396 of this URI.
 String toString()
           
 IUriReference unresolve(IHierarchicalUri other, String fragment)
          Convert the given uri to a relative uri reference with this uri as base.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static int DEFAULT_PORT
Constructor Detail

HttpUrl

public HttpUrl(String scheme,
               String host,
               int port,
               String path,
               String query)
        throws IllegalArgumentException
Throws:
IllegalArgumentException

HttpUrl

public HttpUrl(String scheme,
               String authority,
               String path,
               String query)
        throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object

equals

public boolean equals(IUri other)

equals

public boolean equals(IHierarchicalUri other)

equals

public boolean equals(HttpUrl other)

appendPath

public IHierarchicalUri appendPath(String path)
Append the given path segment to the current path of this uri. Takes care of leading, trailing slashes. Note that the path must be uri encoded or the resulting uri is not valid.

Specified by:
appendPath in interface IHierarchicalUri
Parameters:
path - to be appended
Returns:
new uri with concatenated path

getScheme

public String getScheme()
Get the scheme of this Uri (without ':').

Specified by:
getScheme in interface IUri
Returns:
scheme of this Uri

getRemainder

public String getRemainder()
Get the remainder of this Uri (part after scheme without ':').

Specified by:
getRemainder in interface IUri
Returns:
remainder of this Uri

getAuthority

public String getAuthority()
Return authority part of this hierarchical Uri.

Specified by:
getAuthority in interface IHierarchicalUri
Returns:
authority part of this hierarchical Uri

getHost

public String getHost()
Return the host name of this uri

Returns:
the host name

getPort

public int getPort()
Return the port number of this uri

Returns:
the port number

getPath

public String getPath()
Return path of this Uri or, if not there, the emtpy string

Specified by:
getPath in interface IHierarchicalUri
Returns:
path of this uri

getPathSegments

public String[] getPathSegments()
Return the segments of the uri path

Specified by:
getPathSegments in interface IHierarchicalUri
Returns:
segments of uri path

getQuery

public String getQuery()
Return query of this Uri or, if not there, null

Specified by:
getQuery in interface IHierarchicalUri
Returns:
query of this uri or null

getRoot

public IHierarchicalUri getRoot()
Returns the uri of the root collection (path = "/").

Specified by:
getRoot in interface IHierarchicalUri
Returns:
uri of server root

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isAncestorOf

public boolean isAncestorOf(IHierarchicalUri other)
Determine if this Uri is ancestor of other uri

Specified by:
isAncestorOf in interface IHierarchicalUri
Parameters:
other - uri to check on
Returns:
if this Uri is ancestor of other uri

resolve

public IUri resolve(IUriReference reference)
             throws IllegalArgumentException
Resolve the uri reference in the context of this Uri.

Specified by:
resolve in interface IUri
Parameters:
reference - to be resolved
Returns:
resolved reference as absolute uri without fragment identifier
Throws:
IllegalArgumentException

unresolve

public IUriReference unresolve(IHierarchicalUri other,
                               String fragment)
Convert the given uri to a relative uri reference with this uri as base. If this uri is no ancestor of the other uri, an absolute uri refernce is returned.

Specified by:
unresolve in interface IHierarchicalUri
Parameters:
other - uri to unresolve
fragment - to add to result reference
Returns:
uri reference relative to this uri

mapToWcmPath

public URI mapToWcmPath(IUriReference ref)
Deprecated. As of EP5 SP6, replaced by mapToResourceID(IUriReference)

Specified by:
mapToWcmPath in interface IHierarchicalUri
Parameters:
ref - the uri reference to map
Returns:
the mapped wcm path or null if not possible

mapToResourceID

public RID mapToResourceID(IUriReference ref)
Specified by:
mapToResourceID in interface IHierarchicalUri

mapToWcmPath

public URI mapToWcmPath(IUriReference ref,
                        URICodec codec)
Deprecated. As of EP5 SP6, replaced by mapToResourceID(IUriReference, URICodec)

Specified by:
mapToWcmPath in interface IHierarchicalUri
Parameters:
ref - the uri reference to map
codec - to use for uri decoding
Returns:
the mapped wcm path or null if not possible

mapToResourceID

public RID mapToResourceID(IUriReference ref,
                           URICodec codec)
Specified by:
mapToResourceID in interface IHierarchicalUri

mapToAbsolutePath

public IUriReference mapToAbsolutePath(URI wcmPath)
Deprecated. As of EP5 SP6, replaced by mapToAbsolutePath(RID)

Specified by:
mapToAbsolutePath in interface IHierarchicalUri
Parameters:
wcmPath - to map
Returns:
the mapped uri reference

mapToAbsolutePath

public IUriReference mapToAbsolutePath(URI wcmPath,
                                       URICodec codec)
Deprecated. As of EP5 SP6, replaced by mapToAbsolutePath(RID, URICodec)

Specified by:
mapToAbsolutePath in interface IHierarchicalUri
Parameters:
wcmPath - to map
codec - to use for uri encoding
Returns:
the mapped uri reference

mapToAbsoluteUri

public IHierarchicalUri mapToAbsoluteUri(URI wcmPath)
Deprecated. As of EP5 SP6, replaced by #mapToAbsoluteURI(RID) Given this Uri as the base of the WCM repository, map the WCM Path to a absolute uri.
 Example: "http://host/docs" + "test 3", gives "http://host/docs/test%203"
 Example: "http://host/docs" + "/fs/test", gives "http://host/docs/fs/test"
 

Specified by:
mapToAbsoluteUri in interface IHierarchicalUri
Parameters:
wcmPath - to map
Returns:
the mapped uri

mapToAbsoluteUri

public IHierarchicalUri mapToAbsoluteUri(URI wcmPath,
                                         URICodec codec)
Deprecated. As of EP5 SP6, replaced by #mapToAbsoluteURI(RID, URICodec) Given this Uri as the base of the WCM repository, map the WCM Path to a absolute uri.
 Example: "http://host/docs" + "test 3", gives "http://host/docs/test%203"
 Example: "http://host/docs" + "/fs/test", gives "http://host/docs/fs/test"
 

Specified by:
mapToAbsoluteUri in interface IHierarchicalUri
Parameters:
wcmPath - to map
codec - to use for uri encoding
Returns:
the mapped uri

mapToAbsolutePath

public IUriReference mapToAbsolutePath(IUriReference ref)
Given this Uri as the base, map the uri reference to a uri reference with absolute path component.
 Example: "http://host/docs" + "test%203", gives "/test%203"
 Example: "http://host/docs/" + "test%203", gives "/docs/test%203"
 Example: "http://host/docs" + "http://another/docs/test", gives "http://another/docs/test"
 

Specified by:
mapToAbsolutePath in interface IHierarchicalUri
Parameters:
ref - uri reference to be mapped
Returns:
the mapped uri reference

mapToAbsolutePath

public IUriReference mapToAbsolutePath(RID wcmPath)
Specified by:
mapToAbsolutePath in interface IHierarchicalUri

mapToAbsolutePath

public IUriReference mapToAbsolutePath(RID wcmPath,
                                       URICodec codec)
Specified by:
mapToAbsolutePath in interface IHierarchicalUri

mapToAbsoluteUri

public IHierarchicalUri mapToAbsoluteUri(RID wcmPath)
Specified by:
mapToAbsoluteUri in interface IHierarchicalUri

mapToAbsoluteUri

public IHierarchicalUri mapToAbsoluteUri(RID wcmPath,
                                         URICodec codec)
Specified by:
mapToAbsoluteUri in interface IHierarchicalUri

setQuery

public IHierarchicalUri setQuery(String query)
Description copied from interface: IHierarchicalUri
Construct a new object of same type with the given query. If query is null , the new uri will be without query. The query string must be in RFC 2396 encoded form. See UriQuery for manipulation of query strings.

Specified by:
setQuery in interface IHierarchicalUri
Parameters:
query - encoded query string for returned object
Returns:
hierarchical uri of same type as this

setPath

public IHierarchicalUri setPath(String path)
Description copied from interface: IHierarchicalUri
Construct a new object of same type with the given path. If path is null , the new uri will have the root path /. The path string must be in RFC 2396 encoded form. See URICodec. The query of the resulting uri will always be empty.

Specified by:
setPath in interface IHierarchicalUri
Parameters:
path - encoded path string for returned object
Returns:
hierarchical uri of same type as this

toExternalForm

public String toExternalForm()
Description copied from interface: IUri
Returns a string representation according to RFC 2396 of this URI.

Specified by:
toExternalForm in interface IUri
Returns:
string in uri format

normalizePath

protected static StringBuffer normalizePath(StringBuffer sb)
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2014 SAP AG Complete Copyright Notice