Top Description Fields Constructors Methods
org.eclipse.jgit.transport

public Class URIish

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Static Imports
java.nio.charset.StandardCharsets.UTF_8

This URI like construct used for referencing Git archives over the net, as well as locally stored archives. It is similar to RFC 2396 URI's, but also support SCP and the malformed file://<path> syntax (as opposed to the correct file:<path> syntax.

Field Summary

Modifier and TypeField and Description
private static final Pattern
ABSOLUTE_SCP_URI

A pattern matching a SCP URI's of the form user@host:/path/to/repo.git

private static final Pattern
FULL_URI

A pattern matching standard URI: scheme "://" user_password?

private String
private static final String
HOST_P

Part of a pattern which matches the host part of URIs.

private static final Pattern
LOCAL_FILE

A pattern matching the reference to a local file.

private static final String
OPT_DRIVE_LETTER_P

Part of a pattern which matches the optional drive letter in paths (e.g. D: in file:///D:/a.txt).

private static final String
OPT_PORT_P

Part of a pattern which matches the optional port part of URIs.

private static final String
OPT_USER_PWD_P

Part of a pattern which matches the optional user/password part (e.g. root:pwd@ in git://root:[email protected]/a.git) of URIs.

private String
private String
private static final String
PATH_P

Part of a pattern which matches a relative or absolute path.

private int
private String
private static final String
RELATIVE_PATH_P

Part of a pattern which matches a relative path.

private static final Pattern
RELATIVE_SCP_URI

A pattern matching a SCP URI's of the form user@host:path/to/repo.git

private static final BitSet
private String
private static final String
SCHEME_P

Part of a pattern which matches the scheme part (git, http, ...) of an URI.

private static final long
private static final Pattern
SINGLE_SLASH_FILE_URI

A pattern matching a URI for the scheme 'file' which has only ':/' as separator between scheme and path.

private String
private static final String
USER_HOME_P

Part of a pattern which matches the ~username part (e.g. /~root in git://host.xyz/~root/a.git) of URIs.

Constructor Summary

AccessConstructor and Description
public
URIish(String s)

Parse and construct an org.eclipse.jgit.transport.URIish from a string

public
URIish(URL
the source URL to convert from.
u
)

Construct a URIish from a standard URL.

public
URIish()

Create an empty, non-configured URI.

private

Method Summary

Modifier and TypeMethod and Description
private String
private static boolean
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

private static String

Returns:

a URI-encoded string
escape
(String
The Java String to encode (may contain any character)
s
,
boolean
true to escape URI reserved characters
escapeReservedChars
,
boolean
encode any non-ASCII characters
encodeNonAscii
)

Escape unprintable characters optionally URI-reserved characters

private String
format(boolean includePassword, boolean escapeNonAscii)

public String

Returns:

host name part or null
getHost
()

Get host name part.

public String

Returns:

the "humanish" part of the path. May be an empty string. Never null.
getHumanishName
()

Get the "humanish" part of the path.

public String

Returns:

password requested for transfer or null
getPass
()

Get password requested for transfer

public String

Returns:

path name component
getPath
()

Get path name component

public int

Returns:

port number requested for transfer or -1 if not explicit
getPort
()

Get port number requested for transfer or -1 if not explicit

public String

Returns:

path name component
getRawPath
()

Get path name component

public String

Returns:

protocol name or null for local references
getScheme
()

Get protocol name

public String

Returns:

user name requested for transfer or null
getUser
()

Get user name requested for transfer

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if this URI references a repository on another system.
isRemote
()

Whether this URI references a repository on another system.

private String
private static int
parseHexByte(byte c1, byte c2)

public URIish

Returns:

a new URI with the updated value.
setHost
(String
the new value for host.
n
)

Return a new URI matching this one, but with a different host.

public URIish

Returns:

a new URI with the updated value.
setPass
(String
the new value for password.
n
)

Return a new URI matching this one, but with a different password.

public URIish

Returns:

a new URI with the updated value.
setPath
(String
the new value for path.
n
)

Return a new URI matching this one, but with a different path.

public URIish

Returns:

a new URI with the updated value.
setPort
(int
the new value for port.
n
)

Return a new URI matching this one, but with a different port.

public URIish

Returns:

a new URI with the updated value.
setRawPath
(String
the new value for path.
n
)

Return a new URI matching this one, but with a different (raw) path.

public URIish

Returns:

a new URI with the updated value.
setScheme
(String
the new value for scheme.
n
)

Return a new URI matching this one, but with a different scheme.

public URIish

Returns:

a new URI with the updated value.
setUser
(String
the new value for user.
n
)

Return a new URI matching this one, but with a different user.

public String

Returns:

the URI as an ASCII string. Password is not included.
toASCIIString
()

Get the URI as an ASCII string.

public String

Returns:

the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.
toPrivateASCIIString
()

Convert the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.

public String

Returns:

the URI, including its password field, if any.
toPrivateString
()

Obtain the string form of the URI, with the password included.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static String
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ABSOLUTE_SCP_URIback to summary
private static final Pattern ABSOLUTE_SCP_URI

A pattern matching a SCP URI's of the form user@host:/path/to/repo.git

FULL_URIback to summary
private static final Pattern FULL_URI

A pattern matching standard URI:
scheme "://" user_password? hostname? portnumber? path

hostback to summary
private String host
HOST_Pback to summary
private static final String HOST_P

Part of a pattern which matches the host part of URIs. Defines one capturing group containing the host name.

LOCAL_FILEback to summary
private static final Pattern LOCAL_FILE

A pattern matching the reference to a local file. This may be an absolute path (maybe even containing windows drive-letters) or a relative path.

OPT_DRIVE_LETTER_Pback to summary
private static final String OPT_DRIVE_LETTER_P

Part of a pattern which matches the optional drive letter in paths (e.g. D: in file:///D:/a.txt). Defines no capturing group.

OPT_PORT_Pback to summary
private static final String OPT_PORT_P

Part of a pattern which matches the optional port part of URIs. Defines one capturing group containing the port without the preceding colon.

OPT_USER_PWD_Pback to summary
private static final String OPT_USER_PWD_P

Part of a pattern which matches the optional user/password part (e.g. root:pwd@ in git://root:[email protected]/a.git) of URIs. Defines two capturing groups: the first containing the user and the second containing the password

passback to summary
private String pass
pathback to summary
private String path
PATH_Pback to summary
private static final String PATH_P

Part of a pattern which matches a relative or absolute path. Defines no capturing group.

portback to summary
private int port
rawPathback to summary
private String rawPath
RELATIVE_PATH_Pback to summary
private static final String RELATIVE_PATH_P

Part of a pattern which matches a relative path. Relative paths don't start with slash or drive letters. Defines no capturing group.

RELATIVE_SCP_URIback to summary
private static final Pattern RELATIVE_SCP_URI

A pattern matching a SCP URI's of the form user@host:path/to/repo.git

reservedCharsback to summary
private static final BitSet reservedChars
schemeback to summary
private String scheme
SCHEME_Pback to summary
private static final String SCHEME_P

Part of a pattern which matches the scheme part (git, http, ...) of an URI. Defines one capturing group containing the scheme without the trailing colon and slashes

serialVersionUIDback to summary
private static final long serialVersionUID
SINGLE_SLASH_FILE_URIback to summary
private static final Pattern SINGLE_SLASH_FILE_URI

A pattern matching a URI for the scheme 'file' which has only ':/' as separator between scheme and path. Standard file URIs have '://' as separator, but java.io.File.toURI() constructs those URIs.

userback to summary
private String user
USER_HOME_Pback to summary
private static final String USER_HOME_P

Part of a pattern which matches the ~username part (e.g. /~root in git://host.xyz/~root/a.git) of URIs. Defines no capturing group.

Constructor Detail

URIishback to summary
public URIish(String s) throws URISyntaxException

Parse and construct an org.eclipse.jgit.transport.URIish from a string

Parameters
s:String

a java.lang.String object.

Exceptions
URISyntaxException:
if s was null or couldn't be parsed
URIishback to summary
public URIish(URL u)

Construct a URIish from a standard URL.

Parameters
u:URL

the source URL to convert from.

URIishback to summary
public URIish()

Create an empty, non-configured URI.

URIishback to summary
private URIish(URIish u)

Method Detail

cleanLeadingSlashesback to summary
private String cleanLeadingSlashes(String p, String s)
eqback to summary
private static boolean eq(String a, String b)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
escapeback to summary
private static String escape(String s, boolean escapeReservedChars, boolean encodeNonAscii)

Escape unprintable characters optionally URI-reserved characters

Parameters
s:String

The Java String to encode (may contain any character)

escapeReservedChars:boolean

true to escape URI reserved characters

encodeNonAscii:boolean

encode any non-ASCII characters

Returns:String

a URI-encoded string

formatback to summary
private String format(boolean includePassword, boolean escapeNonAscii)
getHostback to summary
public String getHost()

Get host name part.

Returns:String

host name part or null

getHumanishNameback to summary
public String getHumanishName() throws IllegalArgumentException

Get the "humanish" part of the path. Some examples of a 'humanish' part for a full path:

path vs. humanish path
Path Humanish part
/path/to/repo.git repo
/path/to/repo.git/
/path/to/repo/.git
/path/to/repo/
localhost ssh://localhost/
/path//to an empty string
Returns:String

the "humanish" part of the path. May be an empty string. Never null.

Exceptions
IllegalArgumentException:
if it's impossible to determine a humanish part, or path is null or empty
See Also
getPath
getPassback to summary
public String getPass()

Get password requested for transfer

Returns:String

password requested for transfer or null

getPathback to summary
public String getPath()

Get path name component

Returns:String

path name component

getPortback to summary
public int getPort()

Get port number requested for transfer or -1 if not explicit

Returns:int

port number requested for transfer or -1 if not explicit

getRawPathback to summary
public String getRawPath()

Get path name component

Returns:String

path name component

getSchemeback to summary
public String getScheme()

Get protocol name

Returns:String

protocol name or null for local references

getUserback to summary
public String getUser()

Get user name requested for transfer

Returns:String

user name requested for transfer or null

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isRemoteback to summary
public boolean isRemote()

Whether this URI references a repository on another system.

Returns:boolean

true if this URI references a repository on another system.

n2eback to summary
private String n2e(String s)
parseHexByteback to summary
private static int parseHexByte(byte c1, byte c2)
setHostback to summary
public URIish setHost(String n)

Return a new URI matching this one, but with a different host.

Parameters
n:String

the new value for host.

Returns:URIish

a new URI with the updated value.

setPassback to summary
public URIish setPass(String n)

Return a new URI matching this one, but with a different password.

Parameters
n:String

the new value for password.

Returns:URIish

a new URI with the updated value.

setPathback to summary
public URIish setPath(String n)

Return a new URI matching this one, but with a different path.

Parameters
n:String

the new value for path.

Returns:URIish

a new URI with the updated value.

setPortback to summary
public URIish setPort(int n)

Return a new URI matching this one, but with a different port.

Parameters
n:int

the new value for port.

Returns:URIish

a new URI with the updated value.

setRawPathback to summary
public URIish setRawPath(String n) throws URISyntaxException

Return a new URI matching this one, but with a different (raw) path.

Parameters
n:String

the new value for path.

Returns:URIish

a new URI with the updated value.

Exceptions
URISyntaxException:
if URI couldn't be parsed from String
setSchemeback to summary
public URIish setScheme(String n)

Return a new URI matching this one, but with a different scheme.

Parameters
n:String

the new value for scheme.

Returns:URIish

a new URI with the updated value.

setUserback to summary
public URIish setUser(String n)

Return a new URI matching this one, but with a different user.

Parameters
n:String

the new value for user.

Returns:URIish

a new URI with the updated value.

toASCIIStringback to summary
public String toASCIIString()

Get the URI as an ASCII string.

Returns:String

the URI as an ASCII string. Password is not included.

toPrivateASCIIStringback to summary
public String toPrivateASCIIString()

Convert the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.

Returns:String

the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.

toPrivateStringback to summary
public String toPrivateString()

Obtain the string form of the URI, with the password included.

Returns:String

the URI, including its password field, if any.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
unescapeback to summary
private static String unescape(String s) throws URISyntaxException