Top Description Methods
org.eclipse.jgit.transport

public Interface Connection

extends AutoCloseable
Known Direct Subinterfaces
org.eclipse.jgit.transport.FetchConnection, org.eclipse.jgit.transport.PushConnection
Known Direct Implementers
org.eclipse.jgit.transport.BaseConnection
Imports
java.util.Collection, .Map, org.eclipse.jgit.lib.Ref

Represent connection for operation on a remote repository.

Currently all operations on remote repository (fetch and push) provide information about remote refs. Every connection is able to be closed and should be closed - this is a connection client responsibility.

See Also
Transport

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public String

Returns:

the messages returned by the remote, most likely terminated by a newline (LF) character. The empty string is returned if the remote produced no additional messages.
getMessages
()

Get the additional messages, if any, returned by the remote process.

public String

Returns:

agent (version of Git) running on the remote server. Null if the server does not advertise this version.
getPeerUserAgent
()

User agent advertised by the remote server.

public Ref

Returns:

the requested ref; null if the remote did not advertise this ref.
getRef
(String
name of the ref to obtain.
name
)

Get a single advertised ref by name.

public Collection<Ref>

Returns:

available/advertised refs. Never null. Not modifiable. The collection can be empty if the remote side has no refs (it is an empty/newly created repository).
getRefs
()

Get the complete list of refs advertised as available for fetching or pushing.

public Map<String, Ref>

Returns:

available/advertised refs: map of refname to ref. Never null. Not modifiable. The collection can be empty if the remote side has no refs (it is an empty/newly created repository).
getRefsMap
()

Get the complete map of refs advertised as available for fetching or pushing.

Method Detail

closeback to summary
public void close()

Redeclares java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Close any resources used by this connection.

If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

If additional messages were produced by the remote peer, these should still be retained in the connection instance for getMessages().

AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

Annotations
@Override
getMessagesback to summary
public String getMessages()

Get the additional messages, if any, returned by the remote process.

These messages are most likely informational or error messages, sent by the remote peer, to help the end-user correct any problems that may have prevented the operation from completing successfully. Application UIs should try to show these in an appropriate context.

The message buffer is available after close() has been called. Prior to closing the connection, the message buffer may be empty.

Returns:String

the messages returned by the remote, most likely terminated by a newline (LF) character. The empty string is returned if the remote produced no additional messages.

getPeerUserAgentback to summary
public String getPeerUserAgent()

User agent advertised by the remote server.

Returns:String

agent (version of Git) running on the remote server. Null if the server does not advertise this version.

Since
4.0
getRefback to summary
public Ref getRef(String name)

Get a single advertised ref by name.

The name supplied should be valid ref name. To get a peeled value for a ref (aka refs/tags/v1.0^{}) use the base name (without the ^{} suffix) and look at the peeled object id.

Parameters
name:String

name of the ref to obtain.

Returns:Ref

the requested ref; null if the remote did not advertise this ref.

getRefsback to summary
public Collection<Ref> getRefs()

Get the complete list of refs advertised as available for fetching or pushing.

The returned refs may appear in any order. If the caller needs these to be sorted, they should be copied into a new array or List and then sorted by the caller as necessary.

Returns:Collection<Ref>

available/advertised refs. Never null. Not modifiable. The collection can be empty if the remote side has no refs (it is an empty/newly created repository).

getRefsMapback to summary
public Map<String, Ref> getRefsMap()

Get the complete map of refs advertised as available for fetching or pushing.

Returns:Map<String, Ref>

available/advertised refs: map of refname to ref. Never null. Not modifiable. The collection can be empty if the remote side has no refs (it is an empty/newly created repository).