org.tmatesoft.svn.core
Class 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.
SVNURL | appendPath(String segment, boolean uriEncoded)- Constructs a new SVNURL representation appending a new path
segment to the path component of this representation.
|
static SVNURL | create(String protocol, String userInfo, String host, int port, String path, boolean uriEncoded)- Creates a new SVNURL representation from the given url
components.
|
boolean | equals(Object obj)- Compares this object with another one.
|
static SVNURL | fromFile(File repositoryPath)- 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.
|
String | getHost()- Returns the host component of the url represented by this object.
|
String | getPath()- Returns the path component of the url represented by this object
as a uri-decoded string
|
int | getPort()- Returns the port number specified (or default) for the host.
|
String | getProtocol()- Returns the protocol component of the url represented by this
object.
|
String | getURIEncodedPath()- Returns the path component of the url represented by this object
as a uri-encoded string
|
String | getUserInfo()- Returns the user info component of the url represented by this
object.
|
boolean | hasPort()- Says if the url is provided with a non-default port number or not.
|
int | hashCode()- Calculates and returns a hash code for this object.
|
static SVNURL | parseURIDecoded(String url)- Parses the given decoded (not UTF-8 encoded) url string and creates
a new SVNURL representation for this url.
|
static SVNURL | parseURIEncoded(String url)- Parses the given UTF-8 encoded url string and creates a new
SVNURL representation for this url.
|
SVNURL | removePathTail()- Constructs a new SVNURL representation removing a tail path
segment from the path component of this representation.
|
SVNURL | setPath(String path, boolean uriEncoded)- Creates a new SVNURL object replacing a path component of
this object with a new provided one.
|
String | toDecodedString()- Returns a string representing a decoded url.
|
String | toString()- Returns a string representing a UTF-8 encoded url.
|
appendPath
public SVNURL appendPath(String segment,
boolean uriEncoded)
throws SVNException Constructs a new SVNURL representation appending a new path
segment to the path component of this representation.
segment - a new path segmenturiEncoded - true if
segment is UTF-8 encoded,
false
otherwise
- a new SVNURL representation
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.
protocol - a protocol componentuserInfo - a user info componenthost - a host componentport - a port numberpath - a path componenturiEncoded - true if
path is UTF-8 encoded,
false
otherwise
- a new SVNURL representation
SVNException - if the resultant url (composed of the given
components) is malformed
equals
public boolean equals(Object obj)
Compares this object with another one.
obj - an object to compare with
- true if
obj
is an instance of SVNURL and has got the same
url components as this object has
fromFile
public static SVNURL fromFile(File repositoryPath)
throws SVNException Creates a "file:///" SVNURL
representation given a filesystem style repository path.
repositoryPath - a repository path as a filesystem path
getDefaultPortNumber
public static int getDefaultPortNumber(String protocol)
Returns the default port number for the specified protocol.
protocol - a particular access protocol
getHost
public String getHost()
Returns the host component of the url represented by this object.
getPath
public String getPath()
Returns the path component of the url represented by this object
as a uri-decoded string
getPort
public int getPort()
Returns the port number specified (or default) for the host.
getProtocol
public String getProtocol()
Returns the protocol component of the url represented by this
object.
- a protocol name (like
http)
getURIEncodedPath
public String getURIEncodedPath()
Returns the path component of the url represented by this object
as a uri-encoded string
getUserInfo
public String getUserInfo()
Returns the user info component of the url represented by this
object.
- a user info part of the url (if it was provided)
hasPort
public boolean hasPort()
Says if the url is provided with a non-default port number or not.
- true if the url
comes with a non-default port number,
false otherwise
hashCode
public int hashCode()
Calculates and returns a hash code for this object.
parseURIDecoded
public static SVNURL parseURIDecoded(String url)
throws SVNException Parses the given decoded (not UTF-8 encoded) url string and creates
a new SVNURL representation for this url.
url - an input url string (like 'http://myhost/mypath')
- a new SVNURL representation of
url
parseURIEncoded
public static SVNURL parseURIEncoded(String url)
throws SVNException Parses the given UTF-8 encoded url string and creates a new
SVNURL representation for this url.
url - an input url string (like 'http://myhost/my%20path')
- a new SVNURL representation of
url
removePathTail
public SVNURL removePathTail()
throws SVNException Constructs a new SVNURL representation removing a tail path
segment from the path component of this representation.
- a new SVNURL representation
setPath
public SVNURL setPath(String path,
boolean uriEncoded)
throws SVNException Creates a new SVNURL object replacing a path component of
this object with a new provided one.
path - a path componenturiEncoded - true if path
is UTF-8 encoded
- a new SVNURL representation
toDecodedString
public String toDecodedString()
Returns a string representing a decoded url.
toString
public String toString()
Returns a string representing a UTF-8 encoded url.
Copyright © 2004-2006 TMate Software Ltd. All Rights Reserved.