Class CommandCatalog
- java.lang.Object
-
- org.eclipse.jgit.pgm.CommandCatalog
-
public class CommandCatalog extends java.lang.ObjectList of all commands known by jgit's command line tools.Commands are implementations of
TextBuiltin, with an optionalCommandclass annotation to insert additional documentation or override the default command name (which is guessed from the class name).Commands may be registered by adding them to a services file in the same JAR (or classes directory) as the command implementation. The service file name is
META-INF/services/org.eclipse.jgit.pgm.TextBuiltinand it contains one concrete implementation class name per line.Command registration is identical to Java 6's services, however the catalog uses a lightweight wrapper to delay creating a command instance as much as possible. This avoids initializing the AWT or SWT GUI toolkits even if the command's constructor might require them.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,CommandRef>commandsprivate static CommandCatalogINSTANCEprivate java.lang.ClassLoaderldr
-
Constructor Summary
Constructors Modifier Constructor Description privateCommandCatalog()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandRef[]all()Get all commands sorted by their nameprivate java.util.Enumeration<java.net.URL>catalogs()static CommandRef[]common()Get all common commands sorted by their namestatic CommandRefget(java.lang.String name)Locate a single command by its user friendly name.private voidload(java.lang.String cn)private voidscan(java.net.URL cUrl)private static CommandRef[]toSortedArray(java.util.Collection<CommandRef> c)
-
-
-
Field Detail
-
INSTANCE
private static final CommandCatalog INSTANCE
-
ldr
private final java.lang.ClassLoader ldr
-
commands
private final java.util.Map<java.lang.String,CommandRef> commands
-
-
Method Detail
-
get
public static CommandRef get(java.lang.String name)
Locate a single command by its user friendly name.- Parameters:
name- name of the command. Typically in dash-lower-case-form, which was derived from the DashLowerCaseForm class name.- Returns:
- the command instance; null if no command exists by that name.
-
all
public static CommandRef[] all()
Get all commands sorted by their name- Returns:
- all known commands, sorted by command name.
-
common
public static CommandRef[] common()
Get all common commands sorted by their name- Returns:
- all common commands, sorted by command name.
-
toSortedArray
private static CommandRef[] toSortedArray(java.util.Collection<CommandRef> c)
-
catalogs
private java.util.Enumeration<java.net.URL> catalogs()
-
scan
private void scan(java.net.URL cUrl)
-
load
private void load(java.lang.String cn)
-
-