Package org.tmatesoft.svn.core
Class SVNURL
java.lang.Object
org.tmatesoft.svn.core.SVNURL
The SVNURL class is used for representing urls. Those SVNKit
API methods, that need repository locations to carry out an operation,
receive a repository location url represented by SVNURL. This
class does all the basic work for a caller: parses an original url
string (splitting it to components), encodes/decodes a path component
to/from the UTF-8 charset, checks for validity (such as protocol support
- if SVNKit does not support a particular protocol, SVNURL
throws a corresponding exception).
To create a new SVNURL representation, pass an original url string (like "http://userInfo@host:port/path") to a corresponding parse method of this class.
- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionappendPath
(String segment, boolean uriEncoded) Constructs a new SVNURL representation appending a new path segment to the path component of this representation.static SVNURL
Creates a new SVNURL representation from the given url components.boolean
Compares this object with another one.static SVNURL
Creates a "file:///" SVNURL representation given a filesystem style repository path.static int
getDefaultPortNumber
(String protocol) Returns the default port number for the specified protocol.getHost()
Returns the host component of the url represented by this object.getPath()
Returns the path component of the url represented by this object as a uri-decoded stringint
getPort()
Returns the port number specified (or default) for the host.Returns the protocol component of the url represented by this object.Returns the path component of the url represented by this object as a uri-encoded stringReturns the user info component of the url represented by this object.int
hashCode()
Calculates and returns a hash code for this object.boolean
hasPort()
Says if the url is provided with a non-default port number or not.static SVNURL
parseURIDecoded
(String url) Deprecated.static SVNURL
parseURIEncoded
(String url) Parses the given UTF-8 encoded url string and creates a new SVNURL representation for this url.static void
registerProtocol
(String protocolName, int defaultPort) Sets the default protocol for a repository access protocol.Constructs a new SVNURL representation removing a tail path segment from the path component of this representation.Creates a new SVNURL object replacing a path component of this object with a new provided one.Returns a string representing a decoded url.toString()
Returns a string representing a UTF-8 encoded url.
-
Method Details
-
create
public static SVNURL create(String protocol, String userInfo, String host, int port, String path, boolean uriEncoded) throws SVNException Creates a new SVNURL representation from the given url components.- Parameters:
protocol
- a protocol componentuserInfo
- a user info componenthost
- a host componentport
- a port numberpath
- a path componenturiEncoded
- true ifpath
is UTF-8 encoded, false otherwise- Returns:
- a new SVNURL representation
- Throws:
SVNException
- if the resultant url (composed of the given components) is malformed
-
parseURIDecoded
Deprecated.Parses the given decoded (not UTF-8 encoded) url string and creates a new SVNURL representation for this url.- Parameters:
url
- an input url string (like 'http://myhost/mypath')- Returns:
- a new SVNURL representation of
url
- Throws:
SVNException
- ifurl
is malformed
-
parseURIEncoded
Parses the given UTF-8 encoded url string and creates a new SVNURL representation for this url.- Parameters:
url
- an input url string (like 'http://myhost/my%20path')- Returns:
- a new SVNURL representation of
url
- Throws:
SVNException
- ifurl
is malformed
-
fromFile
Creates a "file:///" SVNURL representation given a filesystem style repository path.- Parameters:
repositoryPath
- a repository path as a filesystem path- Returns:
- an SVNURL representation
- Throws:
SVNException
-
getDefaultPortNumber
Returns the default port number for the specified protocol.- Parameters:
protocol
- a particular access protocol- Returns:
- default port number
-
registerProtocol
Sets the default protocol for a repository access protocol.- Parameters:
protocolName
- protocol namedefaultPort
- default port value- Since:
- 1.2.0
-
getProtocol
Returns the protocol component of the url represented by this object.- Returns:
- a protocol name (like
http
)
-
getHost
Returns the host component of the url represented by this object.- Returns:
- a host name
-
getPort
public int getPort()Returns the port number specified (or default) for the host.- Returns:
- a port number
-
hasPort
public boolean hasPort()Says if the url is provided with a non-default port number or not.- Returns:
- true if the url comes with a non-default port number, false otherwise
- See Also:
-
getPath
Returns the path component of the url represented by this object as a uri-decoded string- Returns:
- a uri-decoded path
-
getURIEncodedPath
Returns the path component of the url represented by this object as a uri-encoded string- Returns:
- a uri-encoded path
-
getUserInfo
Returns the user info component of the url represented by this object.- Returns:
- a user info part of the url (if it was provided)
-
toString
Returns a string representing a UTF-8 encoded url. -
toDecodedString
Returns a string representing a decoded url.- Returns:
- a decoded url string
-
appendPath
Constructs a new SVNURL representation appending a new path segment to the path component of this representation.- Parameters:
segment
- a new path segmenturiEncoded
- true ifsegment
is UTF-8 encoded, false otherwise- Returns:
- a new SVNURL representation
- Throws:
SVNException
- if a parse error occurred
-
setPath
Creates a new SVNURL object replacing a path component of this object with a new provided one.- Parameters:
path
- a path componenturiEncoded
- true ifpath
is UTF-8 encoded- Returns:
- a new SVNURL representation
- Throws:
SVNException
- if a parse error occurred
-
removePathTail
Constructs a new SVNURL representation removing a tail path segment from the path component of this representation.- Returns:
- a new SVNURL representation
- Throws:
SVNException
-
equals
Compares this object with another one. -
hashCode
public int hashCode()Calculates and returns a hash code for this object.
-