Package org.eclipse.jgit.transport
Class URIish
- java.lang.Object
-
- org.eclipse.jgit.transport.URIish
-
- All Implemented Interfaces:
java.io.Serializable
public class URIish extends java.lang.Object implements java.io.SerializableThis 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternABSOLUTE_SCP_URIA pattern matching a SCP URI's of the form user@host:/path/to/repo.gitprivate static java.util.regex.PatternFULL_URIA pattern matching standard URI:scheme "://" user_password? hostname? portnumber? pathprivate java.lang.Stringhostprivate static java.lang.StringHOST_PPart of a pattern which matches the host part of URIs.private static java.util.regex.PatternLOCAL_FILEA pattern matching the reference to a local file.private static java.lang.StringOPT_DRIVE_LETTER_PPart of a pattern which matches the optional drive letter in paths (e.g.private static java.lang.StringOPT_PORT_PPart of a pattern which matches the optional port part of URIs.private static java.lang.StringOPT_USER_PWD_PPart of a pattern which matches the optional user/password part (e.g.private java.lang.Stringpassprivate java.lang.Stringpathprivate static java.lang.StringPATH_PPart of a pattern which matches a relative or absolute path.private intportprivate java.lang.StringrawPathprivate static java.lang.StringRELATIVE_PATH_PPart of a pattern which matches a relative path.private static java.util.regex.PatternRELATIVE_SCP_URIA pattern matching a SCP URI's of the form user@host:path/to/repo.gitprivate static java.util.BitSetreservedCharsprivate java.lang.Stringschemeprivate static java.lang.StringSCHEME_PPart of a pattern which matches the scheme part (git, http, ...) of an URI.private static longserialVersionUIDprivate static java.util.regex.PatternSINGLE_SLASH_FILE_URIA pattern matching a URI for the scheme 'file' which has only ':/' as separator between scheme and path.private java.lang.Stringuserprivate static java.lang.StringUSER_HOME_PPart of a pattern which matches the ~username part (e.g.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringcleanLeadingSlashes(java.lang.String p, java.lang.String s)private static booleaneq(java.lang.String a, java.lang.String b)booleanequals(java.lang.Object obj)private static java.lang.Stringescape(java.lang.String s, boolean escapeReservedChars, boolean encodeNonAscii)Escape unprintable characters optionally URI-reserved charactersprivate java.lang.Stringformat(boolean includePassword, boolean escapeNonAscii)java.lang.StringgetHost()Get host name part.java.lang.StringgetHumanishName()Get the "humanish" part of the path.java.lang.StringgetPass()Get password requested for transferjava.lang.StringgetPath()Get path name componentintgetPort()Get port number requested for transfer or -1 if not explicitjava.lang.StringgetRawPath()Get path name componentjava.lang.StringgetScheme()Get protocol namejava.lang.StringgetUser()Get user name requested for transferinthashCode()booleanisRemote()Whether this URI references a repository on another system.private java.lang.Stringn2e(java.lang.String s)private static intparseHexByte(byte c1, byte c2)URIishsetHost(java.lang.String n)Return a new URI matching this one, but with a different host.URIishsetPass(java.lang.String n)Return a new URI matching this one, but with a different password.URIishsetPath(java.lang.String n)Return a new URI matching this one, but with a different path.URIishsetPort(int n)Return a new URI matching this one, but with a different port.URIishsetRawPath(java.lang.String n)Return a new URI matching this one, but with a different (raw) path.URIishsetScheme(java.lang.String n)Return a new URI matching this one, but with a different scheme.URIishsetUser(java.lang.String n)Return a new URI matching this one, but with a different user.java.lang.StringtoASCIIString()Get the URI as an ASCII string.java.lang.StringtoPrivateASCIIString()Convert the URI including password, formatted with only ASCII characters such that it will be valid for use over the network.java.lang.StringtoPrivateString()Obtain the string form of the URI, with the password included.java.lang.StringtoString()private static java.lang.Stringunescape(java.lang.String s)
-
-
-
Field Detail
-
SCHEME_P
private static final java.lang.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- See Also:
- Constant Field Values
-
OPT_USER_PWD_P
private static final java.lang.String 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:
- Constant Field Values
-
HOST_P
private static final java.lang.String HOST_P
Part of a pattern which matches the host part of URIs. Defines one capturing group containing the host name.- See Also:
- Constant Field Values
-
OPT_PORT_P
private static final java.lang.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.- See Also:
- Constant Field Values
-
USER_HOME_P
private static final java.lang.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.- See Also:
- Constant Field Values
-
OPT_DRIVE_LETTER_P
private static final java.lang.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.- See Also:
- Constant Field Values
-
RELATIVE_PATH_P
private static final java.lang.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.- See Also:
- Constant Field Values
-
PATH_P
private static final java.lang.String PATH_P
Part of a pattern which matches a relative or absolute path. Defines no capturing group.- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
FULL_URI
private static final java.util.regex.Pattern FULL_URI
A pattern matching standard URI:scheme "://" user_password? hostname? portnumber? path
-
LOCAL_FILE
private static final java.util.regex.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.
-
SINGLE_SLASH_FILE_URI
private static final java.util.regex.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.
-
RELATIVE_SCP_URI
private static final java.util.regex.Pattern RELATIVE_SCP_URI
A pattern matching a SCP URI's of the form user@host:path/to/repo.git
-
ABSOLUTE_SCP_URI
private static final java.util.regex.Pattern ABSOLUTE_SCP_URI
A pattern matching a SCP URI's of the form user@host:/path/to/repo.git
-
scheme
private java.lang.String scheme
-
path
private java.lang.String path
-
rawPath
private java.lang.String rawPath
-
user
private java.lang.String user
-
pass
private java.lang.String pass
-
port
private int port
-
host
private java.lang.String host
-
reservedChars
private static final java.util.BitSet reservedChars
-
-
Constructor Detail
-
URIish
public URIish(java.lang.String s) throws java.net.URISyntaxExceptionParse and construct anURIishfrom a string- Parameters:
s- aStringobject.- Throws:
java.net.URISyntaxException
-
URIish
public URIish(java.net.URL u)
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
private URIish(URIish u)
-
-
Method Detail
-
parseHexByte
private static int parseHexByte(byte c1, byte c2)
-
unescape
private static java.lang.String unescape(java.lang.String s) throws java.net.URISyntaxException- Throws:
java.net.URISyntaxException
-
escape
private static java.lang.String escape(java.lang.String s, boolean escapeReservedChars, boolean encodeNonAscii)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
private java.lang.String n2e(java.lang.String s)
-
cleanLeadingSlashes
private java.lang.String cleanLeadingSlashes(java.lang.String p, java.lang.String s)
-
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
public java.lang.String getHost()
Get host name part.- Returns:
- host name part or null
-
setHost
public URIish setHost(java.lang.String n)
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
public java.lang.String getScheme()
Get protocol name- Returns:
- protocol name or null for local references
-
setScheme
public URIish setScheme(java.lang.String n)
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
public java.lang.String getPath()
Get path name component- Returns:
- path name component
-
getRawPath
public java.lang.String getRawPath()
Get path name component- Returns:
- path name component
-
setPath
public URIish setPath(java.lang.String n)
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
public URIish setRawPath(java.lang.String n) throws java.net.URISyntaxException
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:
java.net.URISyntaxException
-
getUser
public java.lang.String getUser()
Get user name requested for transfer- Returns:
- user name requested for transfer or null
-
setUser
public URIish setUser(java.lang.String n)
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
public java.lang.String getPass()
Get password requested for transfer- Returns:
- password requested for transfer or null
-
setPass
public URIish setPass(java.lang.String n)
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
public URIish setPort(int n)
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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
eq
private static boolean eq(java.lang.String a, java.lang.String b)
-
toPrivateString
public java.lang.String toPrivateString()
Obtain the string form of the URI, with the password included.- Returns:
- the URI, including its password field, if any.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
format
private java.lang.String format(boolean includePassword, boolean escapeNonAscii)
-
toASCIIString
public java.lang.String toASCIIString()
Get the URI as an ASCII string.- Returns:
- the URI as an ASCII string. Password is not included.
-
toPrivateASCIIString
public java.lang.String 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
public java.lang.String getHumanishName() throws java.lang.IllegalArgumentExceptionGet the "humanish" part of the path. Some examples of a 'humanish' part for a full path:Path Humanish part /path/to/repo.gitrepo/path/to/repo.git//path/to/repo/.git/path/to/repo/localhostssh://localhost//path//toan empty string - Returns:
- the "humanish" part of the path. May be an empty string. Never
null. - Throws:
java.lang.IllegalArgumentException- if it's impossible to determine a humanish part, or path isnullor empty- See Also:
getPath()
-
-