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

public abstract Class RefAdvertiser

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH, org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SYMREF, .GitProtocolConstants.REF_ATTR_PEELED, .GitProtocolConstants.REF_ATTR_SYMREF_TARGET

Support for the start of org.eclipse.jgit.transport.UploadPack and org.eclipse.jgit.transport.ReceivePack.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
RefAdvertiser.PacketLineOutRefAdvertiser

Advertiser which frames lines in a PacketLineOut format.

Field Summary

Modifier and TypeField and Description
pack-priv final Set<String>
private boolean
pack-priv boolean
private Repository
private final Set<ObjectId>
private final Map<String, String>
private final char[]
private final StringBuilder
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addSymref(String
The symbolic ref, e.g. "HEAD"
from
,
String
The real ref it points to, e.g. "refs/heads/master"
to
)

Add a symbolic ref to capabilities.

private void
private void
public void
advertiseCapability(String
the name of a single protocol capability supported by the caller. The set of capabilities are sent to the client in the advertisement, allowing the client to later selectively enable features it recognizes.
name
)

Add one protocol capability to the initial advertisement.

public void
advertiseCapability(String
name of the capability.
name
,
String
value. If null the capability will not be added.
value
)

Add one protocol capability with a value ("name=value").

public void
advertiseHave(AnyObjectId
identity of the object that is assumed to exist.
id
)

Advertise one object is available using the magic .have.

public void
advertiseId(AnyObjectId
the object to advertise.
id
,
String
name of the reference to advertise the object as, can be any string not including the NUL byte.
refName
)

Advertise one object under a specific name.

protected abstract void
end()

Mark the end of the advertisements.

public void
init(Repository
the repository to read from.
src
)

Initialize this advertiser with a repository for peeling tags.

public boolean

Returns:

true if no advertisements have been sent yet.
isEmpty
()

Whether no advertisements have been sent yet.

public Set<ObjectId>

Returns:

set of ObjectIds that were advertised to the client.
send
(Collection<Ref>
zero or more refs to format for the client. The collection is sorted before display if necessary, and therefore may appear in any order.
refs
)

Format an advertisement for the supplied refs.

public void
setDerefTags(boolean
true to show the dereferenced value of a tag as the special ref $tag^{} ; false to omit it from the output.
deref
)

Toggle tag peeling.

public void
setUseProtocolV2(boolean
true if this advertiser should advertise using the protocol v2 format, false otherwise
b
)

Set whether this advertiser should use protocol v2

protected abstract void
writeOne(CharSequence
the advertisement line to be written. The line always ends with LF. Never null or the empty string.
line
)

Write a single advertisement line.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capablitiesback to summary
pack-priv final Set<String> capablities
derefTagsback to summary
private boolean derefTags
firstback to summary
pack-priv boolean first
repositoryback to summary
private Repository repository
sentback to summary
private final Set<ObjectId> sent
symrefsback to summary
private final Map<String, String> symrefs
tmpIdback to summary
private final char[] tmpId
tmpLineback to summary
private final StringBuilder tmpLine
useProtocolV2back to summary
private boolean useProtocolV2

Constructor Detail

RefAdvertiserback to summary
public RefAdvertiser()

Method Detail

addSymrefback to summary
public void addSymref(String from, String to)

Add a symbolic ref to capabilities.

This method must be invoked prior to any of the following:

Parameters
from:String

The symbolic ref, e.g. "HEAD"

to:String

The real ref it points to, e.g. "refs/heads/master"

Since
3.6
advertiseAnyback to summary
private void advertiseAny(AnyObjectId obj, String refName) throws IOException
advertiseAnyOnceback to summary
private void advertiseAnyOnce(AnyObjectId obj, String refName) throws IOException
advertiseCapabilityback to summary
public void advertiseCapability(String name)

Add one protocol capability to the initial advertisement.

This method must be invoked prior to any of the following:

Parameters
name:String

the name of a single protocol capability supported by the caller. The set of capabilities are sent to the client in the advertisement, allowing the client to later selectively enable features it recognizes.

advertiseCapabilityback to summary
public void advertiseCapability(String name, String value)

Add one protocol capability with a value ("name=value").

Parameters
name:String

name of the capability.

value:String

value. If null the capability will not be added.

Since
4.0
advertiseHaveback to summary
public void advertiseHave(AnyObjectId id) throws IOException

Advertise one object is available using the magic .have.

The magic .have advertisement is not available for fetching by a client, but can be used by a client when considering a delta base candidate before transferring data in a push. Within the record created by this method the ref name is simply the invalid string .have.

Parameters
id:AnyObjectId

identity of the object that is assumed to exist.

Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
advertiseIdback to summary
public void advertiseId(AnyObjectId id, String refName) throws IOException

Advertise one object under a specific name.

If the advertised object is a tag, this method does not advertise the peeled version of it.

Parameters
id:AnyObjectId

the object to advertise.

refName:String

name of the reference to advertise the object as, can be any string not including the NUL byte.

Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
endback to summary
protected abstract void end() throws IOException

Mark the end of the advertisements.

Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
initback to summary
public void init(Repository src)

Initialize this advertiser with a repository for peeling tags.

Parameters
src:Repository

the repository to read from.

isEmptyback to summary
public boolean isEmpty()

Whether no advertisements have been sent yet.

Returns:boolean

true if no advertisements have been sent yet.

sendback to summary
public Set<ObjectId> send(Collection<Ref> refs) throws IOException

Format an advertisement for the supplied refs.

Parameters
refs:Collection<Ref>

zero or more refs to format for the client. The collection is sorted before display if necessary, and therefore may appear in any order.

Returns:Set<ObjectId>

set of ObjectIds that were advertised to the client.

Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
Since
5.0
setDerefTagsback to summary
public void setDerefTags(boolean deref)

Toggle tag peeling.

This method must be invoked prior to any of the following:

Parameters
deref:boolean

true to show the dereferenced value of a tag as the special ref $tag^{} ; false to omit it from the output.

setUseProtocolV2back to summary
public void setUseProtocolV2(boolean b)

Set whether this advertiser should use protocol v2

Parameters
b:boolean

true if this advertiser should advertise using the protocol v2 format, false otherwise

Since
5.0
writeOneback to summary
protected abstract void writeOne(CharSequence line) throws IOException

Write a single advertisement line.

Parameters
line:CharSequence

the advertisement line to be written. The line always ends with LF. Never null or the empty string.

Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
org.eclipse.jgit.transport back to summary

public Class RefAdvertiser.PacketLineOutRefAdvertiser

extends RefAdvertiser
Class Inheritance

Advertiser which frames lines in a PacketLineOut format.

Field Summary

Modifier and TypeField and Description
private byte[]
private ByteBuffer
private char[]
private CharBuffer
private final PacketLineOut
private final CharsetEncoder
Inherited from org.eclipse.jgit.transport.RefAdvertiser:
capablitiesfirst

Constructor Summary

AccessConstructor and Description
public
PacketLineOutRefAdvertiser(PacketLineOut
the output stream.
out
)

Create a new advertiser for the supplied stream.

Method Summary

Modifier and TypeMethod and Description
public void
advertiseId(AnyObjectId
the object to advertise.
id
,
String
name of the reference to advertise the object as, can be any string not including the NUL byte.
refName
)

Overrides org.eclipse.jgit.transport.RefAdvertiser.advertiseId.

Advertise one object under a specific name.

private void
private void
append(int b)

protected void
end()

Implements abstract org.eclipse.jgit.transport.RefAdvertiser.end.

Mark the end of the advertisements.

private void
grow()

protected void
writeOne(CharSequence
the advertisement line to be written. The line always ends with LF. Never null or the empty string.
line
)

Implements abstract org.eclipse.jgit.transport.RefAdvertiser.writeOne.

Write a single advertisement line.

Inherited from org.eclipse.jgit.transport.RefAdvertiser:
addSymrefadvertiseCapabilityadvertiseCapabilityadvertiseHaveinitisEmptysendsetDerefTagssetUseProtocolV2

Field Detail

binArrback to summary
private byte[] binArr
binBufback to summary
private ByteBuffer binBuf
chArrback to summary
private char[] chArr
chBufback to summary
private CharBuffer chBuf
pckOutback to summary
private final PacketLineOut pckOut
utf8back to summary
private final CharsetEncoder utf8

Constructor Detail

PacketLineOutRefAdvertiserback to summary
public PacketLineOutRefAdvertiser(PacketLineOut out)

Create a new advertiser for the supplied stream.

Parameters
out:PacketLineOut

the output stream.

Method Detail

advertiseIdback to summary
public void advertiseId(AnyObjectId id, String refName) throws IOException

Overrides org.eclipse.jgit.transport.RefAdvertiser.advertiseId.

Doc from org.eclipse.jgit.transport.RefAdvertiser.advertiseId.

Advertise one object under a specific name.

If the advertised object is a tag, this method does not advertise the peeled version of it.

Parameters
id:AnyObjectId

the object to advertise.

refName:String

name of the reference to advertise the object as, can be any string not including the NUL byte.

Annotations
@Override
Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
appendback to summary
private void append(String str) throws CharacterCodingException
appendback to summary
private void append(int b)
endback to summary
protected void end() throws IOException

Implements abstract org.eclipse.jgit.transport.RefAdvertiser.end.

Doc from org.eclipse.jgit.transport.RefAdvertiser.end.

Mark the end of the advertisements.

Annotations
@Override
Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.
growback to summary
private void grow()
writeOneback to summary
protected void writeOne(CharSequence line) throws IOException

Implements abstract org.eclipse.jgit.transport.RefAdvertiser.writeOne.

Doc from org.eclipse.jgit.transport.RefAdvertiser.writeOne.

Write a single advertisement line.

Parameters
line:CharSequence

the advertisement line to be written. The line always ends with LF. Never null or the empty string.

Annotations
@Override
Exceptions
IOException:
the underlying output stream failed to write out an advertisement record.