org.eclipse.jgit.transport
Class RefAdvertiser

java.lang.Object
  extended by org.eclipse.jgit.transport.RefAdvertiser
Direct Known Subclasses:
RefAdvertiser.PacketLineOutRefAdvertiser

public abstract class RefAdvertiser
extends Object

Support for the start of UploadPack and ReceivePack.


Nested Class Summary
static class RefAdvertiser.PacketLineOutRefAdvertiser
          Advertiser which frames lines in a PacketLineOut format.
 
Constructor Summary
RefAdvertiser()
           
 
Method Summary
 void advertiseCapability(String name)
          Add one protocol capability to the initial advertisement.
 void advertiseHave(AnyObjectId id)
          Advertise one object is available using the magic .have.
 void advertiseId(AnyObjectId id, String refName)
          Advertise one object under a specific name.
protected abstract  void end()
          Mark the end of the advertisements.
 void init(Repository src)
          Initialize this advertiser with a repository for peeling tags.
 boolean isEmpty()
           
 Set<ObjectId> send(Map<String,Ref> refs)
          Format an advertisement for the supplied refs.
 void setDerefTags(boolean deref)
          Toggle tag peeling.
protected abstract  void writeOne(CharSequence line)
          Write a single advertisement line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefAdvertiser

public RefAdvertiser()
Method Detail

init

public void init(Repository src)
Initialize this advertiser with a repository for peeling tags.

Parameters:
src - the repository to read from.

setDerefTags

public void setDerefTags(boolean deref)
Toggle tag peeling.

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

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

advertiseCapability

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 - 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.

send

public Set<ObjectId> send(Map<String,Ref> refs)
                   throws IOException
Format an advertisement for the supplied refs.

Parameters:
refs - 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 of ObjectIds that were advertised to the client.
Throws:
IOException - the underlying output stream failed to write out an advertisement record.

advertiseHave

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 - identity of the object that is assumed to exist.
Throws:
IOException - the underlying output stream failed to write out an advertisement record.

isEmpty

public boolean isEmpty()
Returns:
true if no advertisements have been sent yet.

advertiseId

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 - the object to advertise.
refName - name of the reference to advertise the object as, can be any string not including the NUL byte.
Throws:
IOException - the underlying output stream failed to write out an advertisement record.

writeOne

protected abstract void writeOne(CharSequence line)
                          throws IOException
Write a single advertisement line.

Parameters:
line - the advertisement line to be written. The line always ends with LF. Never null or the empty string.
Throws:
IOException - the underlying output stream failed to write out an advertisement record.

end

protected abstract void end()
                     throws IOException
Mark the end of the advertisements.

Throws:
IOException - the underlying output stream failed to write out an advertisement record.


Copyright © 2013. All Rights Reserved.