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

public abstract Class GitCommand<T>

extends Object
implements Callable<T>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Callable
Known Direct Subclasses
org.eclipse.jgit.api.ListBranchCommand, org.eclipse.jgit.api.ListNotesCommand, org.eclipse.jgit.api.ListTagCommand, org.eclipse.jgit.api.LogCommand, org.eclipse.jgit.api.MergeCommand, org.eclipse.jgit.api.NameRevCommand, org.eclipse.jgit.api.RebaseCommand, org.eclipse.jgit.api.ReflogCommand, org.eclipse.jgit.api.RemoteAddCommand, org.eclipse.jgit.api.RemoteListCommand, org.eclipse.jgit.api.RemoteRemoveCommand, org.eclipse.jgit.api.RemoteSetUrlCommand, org.eclipse.jgit.api.RemoveNoteCommand, org.eclipse.jgit.api.RenameBranchCommand, org.eclipse.jgit.api.ResetCommand, org.eclipse.jgit.api.RevertCommand, org.eclipse.jgit.api.RmCommand, org.eclipse.jgit.api.StashApplyCommand, org.eclipse.jgit.api.StashCreateCommand, org.eclipse.jgit.api.StashDropCommand, org.eclipse.jgit.api.StashListCommand, org.eclipse.jgit.api.StatusCommand, org.eclipse.jgit.api.SubmoduleDeinitCommand, org.eclipse.jgit.api.SubmoduleInitCommand, org.eclipse.jgit.api.SubmoduleStatusCommand, org.eclipse.jgit.api.SubmoduleSyncCommand, org.eclipse.jgit.api.TagCommand, org.eclipse.jgit.api.TransportCommand, org.eclipse.jgit.api.VerifySignatureCommand, org.eclipse.jgit.api.DeleteTagCommand, org.eclipse.jgit.api.PackRefsCommand, org.eclipse.jgit.api.ShowNoteCommand, org.eclipse.jgit.gitrepo.RepoCommand, org.eclipse.jgit.api.AddCommand, org.eclipse.jgit.api.AddNoteCommand, org.eclipse.jgit.api.ApplyCommand, org.eclipse.jgit.api.ArchiveCommand, org.eclipse.jgit.api.BlameCommand, org.eclipse.jgit.api.CheckoutCommand, org.eclipse.jgit.api.CherryPickCommand, org.eclipse.jgit.api.CleanCommand, org.eclipse.jgit.api.CommitCommand, org.eclipse.jgit.api.CreateBranchCommand, org.eclipse.jgit.api.DeleteBranchCommand, org.eclipse.jgit.api.DescribeCommand, org.eclipse.jgit.api.DiffCommand, org.eclipse.jgit.api.GarbageCollectCommand
Type Parameters
<T>
the return type which is expected from call()
Imports
java.text.MessageFormat, java.util.concurrent.Callable, java.util.concurrent.atomic.AtomicBoolean, org.eclipse.jgit.api.errors.GitAPIException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Repository

Common superclass of all commands in the package org.eclipse.jgit.api

This class ensures that all commands fulfill the java.util.concurrent.Callable interface. It also has a property repo holding a reference to the git org.eclipse.jgit.lib.Repository this command should work with.

Finally this class stores a state telling whether it is allowed to call call() on this instance. Instances of org.eclipse.jgit.api.GitCommand can only be used for one single successful call to call(). Afterwards this instance may not be used anymore to set/modify any properties or to call call() again. This is achieved by setting the callable property to false after the successful execution of call() and to check the state (by calling checkCallable()) before setting of properties and inside call().

Field Summary

Modifier and TypeField and Description
private AtomicBoolean
callable

a state which tells whether it is allowed to call call() on this instance.

protected final Repository
repo

The repository this command is working with

Constructor Summary

AccessConstructor and Description
protected
GitCommand(Repository
the org.eclipse.jgit.lib.Repository this command should interact with
repo
)

Creates a new command which interacts with a single repository

Method Summary

Modifier and TypeMethod and Description
public abstract T
call()

Redeclares java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

protected void
checkCallable()

Checks that the property callable is true.

public Repository

Returns:

the org.eclipse.jgit.lib.Repository this command is interacting with
getRepository
()

Get repository this command is working on

protected void
setCallable(boolean
if true it is allowed to call call() on this instance.
callable
)

Set's the state which tells whether it is allowed to call call() on this instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callableback to summary
private AtomicBoolean callable

a state which tells whether it is allowed to call call() on this instance.

repoback to summary
protected final Repository repo

The repository this command is working with

Constructor Detail

GitCommandback to summary
protected GitCommand(Repository repo)

Creates a new command which interacts with a single repository

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository this command should interact with

Method Detail

callback to summary
public abstract T call() throws GitAPIException

Redeclares java.util.concurrent.Callable.call.

Doc from java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

Returns:T

computed result

Annotations
@Override
checkCallableback to summary
protected void checkCallable()

Checks that the property callable is true. If not then an java.lang.IllegalStateException is thrown

Exceptions
IllegalStateException:
when this method is called and the property callable is false
getRepositoryback to summary
public Repository getRepository()

Get repository this command is working on

Returns:Repository

the org.eclipse.jgit.lib.Repository this command is interacting with

setCallableback to summary
protected void setCallable(boolean callable)

Set's the state which tells whether it is allowed to call call() on this instance. checkCallable() will throw an exception when called and this property is set to false

Parameters
callable:boolean

if true it is allowed to call call() on this instance.