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

public abstract Class BaseConnection

extends Object
implements Connection
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.Connection, java.lang.AutoCloseable
Known Direct Subclasses
org.eclipse.jgit.transport.BaseFetchConnection, org.eclipse.jgit.transport.BasePackConnection, org.eclipse.jgit.transport.WalkPushConnection
Imports
java.io.StringWriter, .Writer, java.util.Collection, .Collections, .Map, org.eclipse.jgit.errors.TransportException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Ref

Base helper class for implementing operations connections.
See Also
BasePackConnection, BaseFetchConnection

Field Summary

Modifier and TypeField and Description
private Map<String, Ref>
private Writer
private String
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
available(Map<String, Ref>
the complete list of refs the remote has to offer. This map will be wrapped in an unmodifiable way to protect it, but it does not get copied.
all
)

Denote the list of refs available on the remote repository.

public abstract void
close()

Redeclares org.eclipse.jgit.transport.Connection.close.

Closes this resource, relinquishing any underlying resources.

public String
getMessages()

Implements org.eclipse.jgit.transport.Connection.getMessages.

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

protected Writer

Returns:

writer to store messages from the remote.
getMessageWriter
()

Get the writer that buffers messages from the remote side.

public String
getPeerUserAgent()

Implements org.eclipse.jgit.transport.Connection.getPeerUserAgent.

User agent advertised by the remote server.

public final Ref
getRef(String
name of the ref to obtain.
name
)

Implements org.eclipse.jgit.transport.Connection.getRef.

Get a single advertised ref by name.

public final Collection<Ref>
getRefs()

Implements org.eclipse.jgit.transport.Connection.getRefs.

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

public Map<String, Ref>
getRefsMap()

Implements org.eclipse.jgit.transport.Connection.getRefsMap.

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

protected void
markStartedOperation()

Helper method for ensuring one-operation per connection.

protected void
setMessageWriter(Writer
the writer that messages will be delivered to. The writer's toString() method should be overridden to return the complete contents.
writer
)

Set the writer that buffers messages from the remote side.

protected void
setPeerUserAgent(String
remote peer agent string.
agent
)

Remember the remote peer's agent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

advertisedRefsback to summary
private Map<String, Ref> advertisedRefs
messageWriterback to summary
private Writer messageWriter
peerUserAgentback to summary
private String peerUserAgent
startedOperationback to summary
private boolean startedOperation

Constructor Detail

BaseConnectionback to summary
public BaseConnection()

Method Detail

availableback to summary
protected void available(Map<String, Ref> all)

Denote the list of refs available on the remote repository.

Implementors should invoke this method once they have obtained the refs that are available from the remote repository.

Parameters
all:Map<String, Ref>

the complete list of refs the remote has to offer. This map will be wrapped in an unmodifiable way to protect it, but it does not get copied.

closeback to summary
public abstract void close()

Redeclares org.eclipse.jgit.transport.Connection.close.

Doc from org.eclipse.jgit.transport.Connection.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()

Implements org.eclipse.jgit.transport.Connection.getMessages.

Doc from org.eclipse.jgit.transport.Connection.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.

Annotations
@Override
getMessageWriterback to summary
protected Writer getMessageWriter()

Get the writer that buffers messages from the remote side.

Returns:Writer

writer to store messages from the remote.

getPeerUserAgentback to summary
public String getPeerUserAgent()

Implements org.eclipse.jgit.transport.Connection.getPeerUserAgent.

Doc from org.eclipse.jgit.transport.Connection.getPeerUserAgent.

User agent advertised by the remote server. 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.

Annotations
@Override
Since
4.0
getRefback to summary
public final Ref getRef(String name)

Implements org.eclipse.jgit.transport.Connection.getRef.

Doc from org.eclipse.jgit.transport.Connection.getRef.

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.

Annotations
@Override
getRefsback to summary
public final Collection<Ref> getRefs()

Implements org.eclipse.jgit.transport.Connection.getRefs.

Doc from org.eclipse.jgit.transport.Connection.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).

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

Implements org.eclipse.jgit.transport.Connection.getRefsMap.

Doc from org.eclipse.jgit.transport.Connection.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).

Annotations
@Override
markStartedOperationback to summary
protected void markStartedOperation() throws TransportException

Helper method for ensuring one-operation per connection. Check whether operation was already marked as started, and mark it as started.

Exceptions
TransportException:
if operation was already marked as started.
setMessageWriterback to summary
protected void setMessageWriter(Writer writer)

Set the writer that buffers messages from the remote side.

Parameters
writer:Writer

the writer that messages will be delivered to. The writer's toString() method should be overridden to return the complete contents.

setPeerUserAgentback to summary
protected void setPeerUserAgent(String agent)

Remember the remote peer's agent.

Parameters
agent:String

remote peer agent string.

Since
4.0