Package org.eclipse.jgit.transport
Class URIish
java.lang.Object
org.eclipse.jgit.transport.URIish
- All Implemented Interfaces:
Serializable
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Pattern
A pattern matching a SCP URI's of the form user@host:/path/to/repo.gitprivate static final Pattern
A pattern matching standard URI:scheme "://" user_password? hostname? portnumber? path
private String
private static final String
Part of a pattern which matches the host part of URIs.private static final Pattern
A pattern matching the reference to a local file.private static final String
Part of a pattern which matches the optional drive letter in paths (e.g.private static final String
Part of a pattern which matches the optional port part of URIs.private static final String
Part of a pattern which matches the optional user/password part (e.g.private String
private String
private static final String
Part of a pattern which matches a relative or absolute path.private int
private String
private static final String
Part of a pattern which matches a relative path.private static final Pattern
A pattern matching a SCP URI's of the form user@host:path/to/repo.gitprivate static final BitSet
private String
private static final String
Part of a pattern which matches the scheme part (git, http, ...) of an URI.private static final long
private static final Pattern
A pattern matching a URI for the scheme 'file' which has only ':/' as separator between scheme and path.private String
private static final String
Part of a pattern which matches the ~username part (e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
cleanLeadingSlashes
(String p, String s) private static boolean
boolean
private static String
Escape unprintable characters optionally URI-reserved charactersprivate String
format
(boolean includePassword, boolean escapeNonAscii) getHost()
Get host name part.Get the "humanish" part of the path.getPass()
Get password requested for transfergetPath()
Get path name componentint
getPort()
Get port number requested for transfer or -1 if not explicitGet path name componentGet protocol namegetUser()
Get user name requested for transferint
hashCode()
boolean
isRemote()
Whether this URI references a repository on another system.private String
private static int
parseHexByte
(byte c1, byte c2) Return a new URI matching this one, but with a different host.Return a new URI matching this one, but with a different password.Return a new URI matching this one, but with a different path.setPort
(int n) Return a new URI matching this one, but with a different port.setRawPath
(String n) Return a new URI matching this one, but with a different (raw) path.Return a new URI matching this one, but with a different scheme.Return a new URI matching this one, but with a different user.Get the URI as an ASCII string.Convert the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.Obtain the string form of the URI, with the password included.toString()
private static String
-
Field Details
-
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- See Also:
-
OPT_USER_PWD_P
Part of a pattern which matches the optional user/password part (e.g. root:pwd@ in git://root:pwd@host.xyz/a.git) of URIs. Defines two capturing groups: the first containing the user and the second containing the password- See Also:
-
HOST_P
Part of a pattern which matches the host part of URIs. Defines one capturing group containing the host name.- See Also:
-
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.- See Also:
-
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.- See Also:
-
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.- See Also:
-
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.- See Also:
-
PATH_P
Part of a pattern which matches a relative or absolute path. Defines no capturing group.- See Also:
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FULL_URI
A pattern matching standard URI:scheme "://" user_password? hostname? portnumber? path
-
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. -
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. -
RELATIVE_SCP_URI
A pattern matching a SCP URI's of the form user@host:path/to/repo.git -
ABSOLUTE_SCP_URI
A pattern matching a SCP URI's of the form user@host:/path/to/repo.git -
scheme
-
path
-
rawPath
-
user
-
pass
-
port
private int port -
host
-
reservedChars
-
-
Constructor Details
-
URIish
Parse and construct anURIish
from a string- Parameters:
s
- aString
object.- Throws:
URISyntaxException
-
URIish
Construct a URIish from a standard URL.- Parameters:
u
- the source URL to convert from.
-
URIish
public URIish()Create an empty, non-configured URI. -
URIish
-
-
Method Details
-
parseHexByte
private static int parseHexByte(byte c1, byte c2) -
unescape
- Throws:
URISyntaxException
-
escape
Escape unprintable characters optionally URI-reserved characters- Parameters:
s
- The Java String to encode (may contain any character)escapeReservedChars
- true to escape URI reserved charactersencodeNonAscii
- encode any non-ASCII characters- Returns:
- a URI-encoded string
-
n2e
-
cleanLeadingSlashes
-
isRemote
public boolean isRemote()Whether this URI references a repository on another system.- Returns:
- true if this URI references a repository on another system.
-
getHost
Get host name part.- Returns:
- host name part or null
-
setHost
Return a new URI matching this one, but with a different host.- Parameters:
n
- the new value for host.- Returns:
- a new URI with the updated value.
-
getScheme
Get protocol name- Returns:
- protocol name or null for local references
-
setScheme
Return a new URI matching this one, but with a different scheme.- Parameters:
n
- the new value for scheme.- Returns:
- a new URI with the updated value.
-
getPath
Get path name component- Returns:
- path name component
-
getRawPath
Get path name component- Returns:
- path name component
-
setPath
Return a new URI matching this one, but with a different path.- Parameters:
n
- the new value for path.- Returns:
- a new URI with the updated value.
-
setRawPath
Return a new URI matching this one, but with a different (raw) path.- Parameters:
n
- the new value for path.- Returns:
- a new URI with the updated value.
- Throws:
URISyntaxException
-
getUser
Get user name requested for transfer- Returns:
- user name requested for transfer or null
-
setUser
Return a new URI matching this one, but with a different user.- Parameters:
n
- the new value for user.- Returns:
- a new URI with the updated value.
-
getPass
Get password requested for transfer- Returns:
- password requested for transfer or null
-
setPass
Return a new URI matching this one, but with a different password.- Parameters:
n
- the new value for password.- Returns:
- a new URI with the updated value.
-
getPort
public int getPort()Get port number requested for transfer or -1 if not explicit- Returns:
- port number requested for transfer or -1 if not explicit
-
setPort
Return a new URI matching this one, but with a different port.- Parameters:
n
- the new value for port.- Returns:
- a new URI with the updated value.
-
hashCode
public int hashCode() -
equals
-
eq
-
toPrivateString
Obtain the string form of the URI, with the password included.- Returns:
- the URI, including its password field, if any.
-
toString
-
format
-
toASCIIString
Get the URI as an ASCII string.- Returns:
- the URI as an ASCII string. Password is not included.
-
toPrivateASCIIString
Convert the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.- Returns:
- the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.
-
getHumanishName
Get the "humanish" part of the path. Some examples of a 'humanish' part for a full 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:
- the "humanish" part of the path. May be an empty string. Never
null
. - Throws:
IllegalArgumentException
- if it's impossible to determine a humanish part, or path isnull
or empty- See Also:
-