Class SVNURL

java.lang.Object
org.tmatesoft.svn.core.SVNURL

public class SVNURL extends java.lang.Object
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
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final java.util.Map
     
    private java.lang.String
     
    private java.lang.String
     
    private boolean
     
    private java.lang.String
     
    private int
     
    private java.lang.String
     
    private java.lang.String
     
    private java.lang.String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    SVNURL(java.lang.String url, boolean uriEncoded)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    appendPath(java.lang.String segment, boolean uriEncoded)
    Constructs a new SVNURL representation appending a new path segment to the path component of this representation.
    private static java.lang.String
    composeURL(java.lang.String protocol, java.lang.String userInfo, java.lang.String host, int port, java.lang.String path)
     
    static SVNURL
    create(java.lang.String protocol, java.lang.String userInfo, java.lang.String host, int port, java.lang.String path, boolean uriEncoded)
    Creates a new SVNURL representation from the given url components.
    boolean
    equals(java.lang.Object obj)
    Compares this object with another one.
    static SVNURL
    fromFile(java.io.File repositoryPath)
    Creates a "file:///" SVNURL representation given a filesystem style repository path.
    static int
    getDefaultPortNumber(java.lang.String protocol)
    Returns the default port number for the specified protocol.
    java.lang.String
    Returns the host component of the url represented by this object.
    java.lang.String
    Returns the path component of the url represented by this object as a uri-decoded string
    private static java.lang.String
    getPath(java.net.URL url)
     
    int
    Returns the port number specified (or default) for the host.
    java.lang.String
    Returns the protocol component of the url represented by this object.
    java.lang.String
    Returns the path component of the url represented by this object as a uri-encoded string
    java.lang.String
    Returns the user info component of the url represented by this object.
    int
    Calculates and returns a hash code for this object.
    boolean
    Says if the url is provided with a non-default port number or not.
    private static java.lang.String
    norlmalizeURLPath(java.lang.String url, java.lang.String path)
     
    static SVNURL
    parseURIDecoded(java.lang.String url)
    Deprecated.
    static SVNURL
    parseURIEncoded(java.lang.String url)
    Parses the given UTF-8 encoded url string and creates a new SVNURL representation for this url.
    static void
    registerProtocol(java.lang.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.
    setPath(java.lang.String path, boolean uriEncoded)
    Creates a new SVNURL object replacing a path component of this object with a new provided one.
    java.lang.String
    Returns a string representing a decoded url.
    java.lang.String
    Returns a string representing a UTF-8 encoded url.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_PORTS

      private static final java.util.Map DEFAULT_PORTS
    • myURL

      private java.lang.String myURL
    • myProtocol

      private java.lang.String myProtocol
    • myHost

      private java.lang.String myHost
    • myPath

      private java.lang.String myPath
    • myUserName

      private java.lang.String myUserName
    • myPort

      private int myPort
    • myEncodedPath

      private java.lang.String myEncodedPath
    • myIsDefaultPort

      private boolean myIsDefaultPort
  • Constructor Details

  • Method Details

    • create

      public static SVNURL create(java.lang.String protocol, java.lang.String userInfo, java.lang.String host, int port, java.lang.String path, boolean uriEncoded) throws SVNException
      Creates a new SVNURL representation from the given url components.
      Parameters:
      protocol - a protocol component
      userInfo - a user info component
      host - a host component
      port - a port number
      path - a path component
      uriEncoded - true if path 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 public static SVNURL parseURIDecoded(java.lang.String url) throws SVNException
      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 - if url is malformed
    • parseURIEncoded

      public static SVNURL parseURIEncoded(java.lang.String url) throws SVNException
      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 - if url is malformed
    • fromFile

      public static SVNURL fromFile(java.io.File repositoryPath) throws SVNException
      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

      public static int getDefaultPortNumber(java.lang.String protocol)
      Returns the default port number for the specified protocol.
      Parameters:
      protocol - a particular access protocol
      Returns:
      default port number
    • registerProtocol

      public static void registerProtocol(java.lang.String protocolName, int defaultPort)
      Sets the default protocol for a repository access protocol.
      Parameters:
      protocolName - protocol name
      defaultPort - default port value
      Since:
      1.2.0
    • getProtocol

      public java.lang.String getProtocol()
      Returns the protocol component of the url represented by this object.
      Returns:
      a protocol name (like http)
    • getHost

      public java.lang.String 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

      public java.lang.String getPath()
      Returns the path component of the url represented by this object as a uri-decoded string
      Returns:
      a uri-decoded path
    • getURIEncodedPath

      public java.lang.String getURIEncodedPath()
      Returns the path component of the url represented by this object as a uri-encoded string
      Returns:
      a uri-encoded path
    • getUserInfo

      public java.lang.String 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

      public java.lang.String toString()
      Returns a string representing a UTF-8 encoded url.
      Overrides:
      toString in class java.lang.Object
      Returns:
      an encoded url string
    • toDecodedString

      public java.lang.String toDecodedString()
      Returns a string representing a decoded url.
      Returns:
      a decoded url string
    • appendPath

      public SVNURL appendPath(java.lang.String segment, boolean uriEncoded) throws SVNException
      Constructs a new SVNURL representation appending a new path segment to the path component of this representation.
      Parameters:
      segment - a new path segment
      uriEncoded - true if segment is UTF-8 encoded, false otherwise
      Returns:
      a new SVNURL representation
      Throws:
      SVNException - if a parse error occurred
    • setPath

      public SVNURL setPath(java.lang.String path, boolean uriEncoded) throws SVNException
      Creates a new SVNURL object replacing a path component of this object with a new provided one.
      Parameters:
      path - a path component
      uriEncoded - true if path is UTF-8 encoded
      Returns:
      a new SVNURL representation
      Throws:
      SVNException - if a parse error occurred
    • removePathTail

      public SVNURL removePathTail() throws SVNException
      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

      public boolean equals(java.lang.Object obj)
      Compares this object with another one.
      Overrides:
      equals in class java.lang.Object
      Parameters:
      obj - an object to compare with
      Returns:
      true if obj is an instance of SVNURL and has got the same url components as this object has
    • hashCode

      public int hashCode()
      Calculates and returns a hash code for this object.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      a hash code value
    • composeURL

      private static java.lang.String composeURL(java.lang.String protocol, java.lang.String userInfo, java.lang.String host, int port, java.lang.String path)
    • norlmalizeURLPath

      private static java.lang.String norlmalizeURLPath(java.lang.String url, java.lang.String path) throws SVNException
      Throws:
      SVNException
    • getPath

      private static java.lang.String getPath(java.net.URL url)